Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2016
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.06 KB | None | 0 0
  1.  
  2.     186: test "Same user should not be able to submit multiple ratings for photo" do
  3.     187:   user = FactoryGirl.create(:user)
  4.     188:   photo = FactoryGirl.create(:photo)
  5.     189:   user2 = FactoryGirl.create(:user2)
  6.     190:   binding.pry
  7.  => 191:   photo.rate(1,user)
  8.     192:   photo.rate(3,user2) # Must have 2nd user to bypass error.
  9.     193:   # Will return undefined method 'avg= ' without user2.
  10.     194:   photo.rate(2,user)
  11.     195:   assert_equal photo.rates.count, 2, "There are more than two ratings for the users"
  12.     196: end
  13.  
  14. [1] pry(#<UserTest>)> photo.rate(1,user)
  15. => #<RatingCache:0x007fadf4849208
  16.  id: 77,
  17.  cacheable_id: 37,
  18.  cacheable_type: "Photo",
  19.  avg: 1.0,
  20.  qty: 1,
  21.  dimension: nil,
  22.  created_at: Wed, 22 Jun 2016 19:07:19 UTC +00:00,
  23.  updated_at: Wed, 22 Jun 2016 19:07:19 UTC +00:00>
  24. [2] pry(#<UserTest>)> photo.rate(1,user)
  25. NoMethodError: undefined method `avg=' for nil:NilClass
  26. 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'
  27. [3] pry(#<UserTest>)>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement