Closed destinyd closed 8 years ago
1) KcCourses::Course scopes studing_of_user(user) studied_of_user(user) Failure/Error: expect(course4.read_percent_of_user(user)).to eq(1) expected: 1 got: 0 (compared using ==) # ./spec/models/kc_courses/course_spec.rb:79:in `block (3 levels) in <top (required)>' Finished in 26.18 seconds (files took 3.01 seconds to load) 140 examples, 1 failure Failed examples: rspec ./spec/models/kc_courses/course_spec.rb:34 # KcCourses::Course scopes studing_of_user(user) studied_of_user(user)
大致判断出是 ware.set_read_percent_by_user(user, 0.1)时
ware_reading 和 ware_reading_delta 存在差异处理,导致的BUG
问题出在app/models/kc_courses/concerns/ware_reading_method.rb的第13行 ,当read_percent小于1但不为0时,(read_percent).to_i的值为0,导致测试错误。
解决方法:将(read_percent).to_i改为(read_percent).to_f。
大致判断出是 ware.set_read_percent_by_user(user, 0.1)时
ware_reading 和 ware_reading_delta 存在差异处理,导致的BUG