-
-
Save anonymous/6b680397fc9cdf843506b43e6ec039b9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>)> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment