Commit 371cfdf9aad27f7492c4f242e65be6d5e63c3c42
1 parent
9c8210cc
Exists in
master
and in
1 other branch
Fixing bug where appearances were not recorded on skip
Showing
3 changed files
with
18 additions
and
1 deletions
Show diff stats
app/models/visitor.rb
@@ -43,7 +43,7 @@ class Visitor < ActiveRecord::Base | @@ -43,7 +43,7 @@ class Visitor < ActiveRecord::Base | ||
43 | prompt = options.delete(:prompt) | 43 | prompt = options.delete(:prompt) |
44 | 44 | ||
45 | if options[:appearance_lookup] | 45 | if options[:appearance_lookup] |
46 | - @appearance = prompt.appearances.find_by_lookup(options.delete(:apperance_lookup)) | 46 | + @appearance = prompt.appearances.find_by_lookup(options.delete(:appearance_lookup)) |
47 | return nil unless @appearance | 47 | return nil unless @appearance |
48 | options.merge!(:appearance_id => @appearance.id) | 48 | options.merge!(:appearance_id => @appearance.id) |
49 | end | 49 | end |
spec/models/user_spec.rb
@@ -91,6 +91,8 @@ describe User do | @@ -91,6 +91,8 @@ describe User do | ||
91 | required_skip_params = {:prompt => @prompt } | 91 | required_skip_params = {:prompt => @prompt } |
92 | params = optional_skip_params.merge(required_skip_params) | 92 | params = optional_skip_params.merge(required_skip_params) |
93 | s = @aoi_clone.record_skip(params) | 93 | s = @aoi_clone.record_skip(params) |
94 | + s.appearance.should == @appearance | ||
95 | + s.skipper.should == @visitor | ||
94 | end | 96 | end |
95 | 97 | ||
96 | end | 98 | end |
spec/models/visitor_spec.rb
@@ -102,6 +102,21 @@ describe Visitor do | @@ -102,6 +102,21 @@ describe Visitor do | ||
102 | } | 102 | } |
103 | allparams = @required_skip_params.merge(@optional_skip_params) | 103 | allparams = @required_skip_params.merge(@optional_skip_params) |
104 | s = @visitor.skip!(allparams) | 104 | s = @visitor.skip!(allparams) |
105 | + s.appearance.should == @appearance | ||
106 | + end | ||
107 | + | ||
108 | + it "should not create a skip when the appearance look up is wrong" do | ||
109 | + skip_count = Skip.count | ||
110 | + @appearance = @aoi_clone.record_appearance(@visitor, @prompt) | ||
111 | + @optional_skip_params = { | ||
112 | + :appearance_lookup => "not a valid appearancelookup", | ||
113 | + :time_viewed => 304, | ||
114 | + :skip_reason => "some reason" | ||
115 | + } | ||
116 | + allparams = @required_skip_params.merge(@optional_skip_params) | ||
117 | + s = @visitor.skip!(allparams) | ||
118 | + s.should be_nil | ||
119 | + Skip.count.should == skip_count | ||
105 | end | 120 | end |
106 | 121 | ||
107 | it "should accurately update score counts after vote" do | 122 | it "should accurately update score counts after vote" do |