Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 186: test "Same user should not be able to submit multiple ratings for photo" do
- 187: user = FactoryGirl.create(:user)
- 188: photo = FactoryGirl.create(:photo)
- 189: user2 = FactoryGirl.create(:user2)
- 190: binding.pry
- => 191: photo.rate(1,user)
- 192: photo.rate(3,user2) # Must have 2nd user to bypass error.
- 193: # Will return undefined method 'avg= ' without user2.
- 194: photo.rate(2,user)
- 195: assert_equal photo.rates.count, 2, "There are more than two ratings for the users"
- 196: end
- [1] pry(#<UserTest>)> photo.rate(1,user)
- => #<RatingCache:0x007fadf4849208
- id: 77,
- cacheable_id: 37,
- cacheable_type: "Photo",
- avg: 1.0,
- qty: 1,
- dimension: nil,
- created_at: Wed, 22 Jun 2016 19:07:19 UTC +00:00,
- updated_at: Wed, 22 Jun 2016 19:07:19 UTC +00:00>
- [2] pry(#<UserTest>)> photo.rate(1,user)
- NoMethodError: undefined method `avg=' for nil:NilClass
- from /Users/rbennacer/.rvm/gems/ruby-2.3.0@mop2/gems/ratyrate-1.2.2.alpha/lib/ratyrate/model.rb:73:in `update_current_rate'
- [3] pry(#<UserTest>)>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement