Commit 8f6e8ef9bb963dc09e895d2273520156711b3f95
1 parent
60cdf17d
Exists in
master
and in
1 other branch
Add more tests
Showing
2 changed files
with
234 additions
and
235 deletions
Show diff stats
test/unit/article_test.rb
... | ... | @@ -118,108 +118,116 @@ class ArticleTest < ActiveSupport::TestCase |
118 | 118 | assert_equal 'negative_votes_received', person.reload.badges.first.name |
119 | 119 | end |
120 | 120 | |
121 | -# FIXME Put the tests above to works in profile context. | |
122 | -# They are the same tests of the general context | |
123 | -# | |
124 | -# should 'add merit points to author when create a new article' do | |
125 | -# create(TextArticle, :profile_id => community.id, :author => person) | |
126 | -# assert_equal 1, person.score_points.count | |
127 | -# assert person.score_points.first.action.present? | |
128 | -# end | |
129 | -# | |
130 | -# should 'subtract merit points to author when destroy an article' do | |
131 | -# article = create(TextArticle, :profile_id => @community.id, :author => person) | |
132 | -# assert_equal 1, person.score_points.count | |
133 | -# article.destroy | |
134 | -# assert_equal 2, person.score_points.count | |
135 | -# assert_equal 0, person.points | |
136 | -# end | |
137 | -# | |
138 | -# should 'add merit badge to author when create 5 new articles' do | |
139 | -# GamificationPlugin::Badge.create!(:owner => environment, :name => 'article_author', :level => 1) | |
140 | -# GamificationPlugin.gamification_set_rules(environment) | |
141 | -# | |
142 | -# 5.times { create(TextArticle, :profile_id => person.id, :author => person) } | |
143 | -# assert_equal 'article_author', person.badges.first.name | |
144 | -# assert_equal 1, person.badges.first.level | |
145 | -# end | |
146 | -# | |
147 | -# should 'add merit badge level 2 to author when create 10 new articles' do | |
148 | -# GamificationPlugin::Badge.create!(:owner => environment, :name => 'article_author', :level => 1) | |
149 | -# GamificationPlugin::Badge.create!(:owner => environment, :name => 'article_author', :level => 2, :custom_fields => {:threshold => 10}) | |
150 | -# GamificationPlugin.gamification_set_rules(environment) | |
151 | -# | |
152 | -# 10.times { create(TextArticle, :profile_id => person.id, :author => person) } | |
153 | -# assert_equal ['article_author'], person.badges.map(&:name).uniq | |
154 | -# assert_equal [1, 2], person.badges.map(&:level) | |
155 | -# end | |
156 | -# | |
157 | -# should 'add merit points to community article owner when an user like it' do | |
158 | -# article = create(TextArticle, :name => 'Test', :profile => @community, :author => person) | |
159 | -# | |
160 | -# c = GamificationPlugin::PointsCategorization.for_type(:vote_voteable_author).where(profile_id: @community.id).first | |
161 | -# assert_difference 'article.author.points(:category => c.id.to_s)', c.weight do | |
162 | -# Vote.create!(:voter => person, :voteable => article, :vote => 1) | |
163 | -# end | |
164 | -# end | |
165 | -# | |
166 | -# should 'add merit points to article when an user like it' do | |
167 | -# article = create(TextArticle, :name => 'Test', :profile => @community, :author => person) | |
168 | -# article = article.reload | |
169 | -# | |
170 | -# c = GamificationPlugin::PointsCategorization.for_type(:vote_voteable).where(profile_id: @community.id).first | |
171 | -# assert_difference 'article.points(:category => c.id.to_s)', c.weight do | |
172 | -# Vote.create!(:voter => person, :voteable => article, :vote => 1) | |
173 | -# end | |
174 | -# end | |
175 | -# | |
176 | -# should 'add merit points to community when create a new article' do | |
177 | -# assert_difference 'community.score_points.count' do | |
178 | -# create(TextArticle, :profile_id => @community.id, :author => person) | |
179 | -# end | |
180 | -# end | |
181 | -# | |
182 | -# should 'add merit points to voter when he likes an article' do | |
183 | -# article = create(TextArticle, :name => 'Test', :profile => @community, :author => person) | |
184 | -# | |
185 | -# c = GamificationPlugin::PointsCategorization.for_type(:vote_voter).where(profile_id: @community.id).first | |
186 | -# assert_difference 'article.author.points(:category => c.id.to_s)', c.weight do | |
187 | -# Vote.create!(:voter => person, :voteable => article, :vote => 1) | |
188 | -# end | |
189 | -# end | |
190 | -# | |
191 | -# should 'add merit points to voter when he dislikes an article' do | |
192 | -# article = create(TextArticle, :name => 'Test', :profile => @community, :author => person) | |
193 | -# | |
194 | -# c = GamificationPlugin::PointsCategorization.for_type(:vote_voter).where(profile_id: @community.id).first | |
195 | -# assert_difference 'article.author.points(:category => c.id.to_s)', c.weight do | |
196 | -# Vote.create!(:voter => person, :voteable => article, :vote => -1) | |
197 | -# end | |
198 | -# end | |
199 | -# | |
200 | -# should 'add badge to author when users like his article' do | |
201 | -# GamificationPlugin::Badge.create!(:owner => environment, :name => 'positive_votes_received') | |
202 | -# GamificationPlugin.gamification_set_rules(environment) | |
203 | -# | |
204 | -# article = create(TextArticle, :name => 'Test', :profile => person, :author => person) | |
205 | -# 4.times { Vote.create!(:voter => fast_create(Person), :voteable => article, :vote => 1) } | |
206 | -# Vote.create!(:voter => fast_create(Person), :voteable => article, :vote => -1) | |
207 | -# assert_equal [], person.badges | |
208 | -# Vote.create!(:voter => fast_create(Person), :voteable => article, :vote => 1) | |
209 | -# assert_equal 'positive_votes_received', person.reload.badges.first.name | |
210 | -# end | |
211 | -# | |
212 | -# should 'add badge to author when users dislike his article' do | |
213 | -# GamificationPlugin::Badge.create!(:owner => environment, :name => 'negative_votes_received') | |
214 | -# GamificationPlugin.gamification_set_rules(environment) | |
215 | -# | |
216 | -# article = create(TextArticle, :name => 'Test', :profile => person, :author => person) | |
217 | -# 4.times { Vote.create!(:voter => fast_create(Person), :voteable => article, :vote => -1) } | |
218 | -# Vote.create!(:voter => fast_create(Person), :voteable => article, :vote => 1) | |
219 | -# assert_equal [], person.badges | |
220 | -# Vote.create!(:voter => fast_create(Person), :voteable => article, :vote => -1) | |
221 | -# assert_equal 'negative_votes_received', person.reload.badges.first.name | |
222 | -# end | |
223 | -# | |
121 | + # community related tests | |
122 | + should 'add merit community points to author when create a new article on community' do | |
123 | + community = fast_create(Community) | |
124 | + create_point_rule_definition('article_author', community) | |
125 | + create(TextArticle, profile_id: community.id, author_id: person.id) | |
126 | + assert_equal 1, person.score_points.count | |
127 | + assert person.score_points.first.action.present? | |
128 | + end | |
129 | + | |
130 | + should 'subtract merit points to author when destroy an article on community' do | |
131 | + community = fast_create(Community) | |
132 | + create_point_rule_definition('article_author', community) | |
133 | + article = create(TextArticle, profile_id: community.id, author_id: person.id) | |
134 | + assert_equal 1, person.score_points.count | |
135 | + article.destroy | |
136 | + assert_equal 2, person.score_points.count | |
137 | + assert_equal 0, person.points | |
138 | + end | |
139 | + | |
140 | + #should 'add merit badge to author when create 5 new articles on community' do | |
141 | + #GamificationPlugin::Badge.create!(:owner => environment, :name => 'article_author', :level => 1) | |
142 | + #GamificationPlugin.gamification_set_rules(environment) | |
143 | + | |
144 | + #5.times { create(TextArticle, :profile_id => person.id, :author => person) } | |
145 | + #assert_equal 'article_author', person.badges.first.name | |
146 | + #assert_equal 1, person.badges.first.level | |
147 | + #end | |
148 | + | |
149 | + #should 'add merit badge level 2 to author when create 10 new articles on community' do | |
150 | + #GamificationPlugin::Badge.create!(:owner => environment, :name => 'article_author', :level => 1) | |
151 | + #GamificationPlugin::Badge.create!(:owner => environment, :name => 'article_author', :level => 2, :custom_fields => {:threshold => 10}) | |
152 | + #GamificationPlugin.gamification_set_rules(environment) | |
153 | + | |
154 | + #10.times { create(TextArticle, :profile_id => person.id, :author => person) } | |
155 | + #assert_equal ['article_author'], person.badges.map(&:name).uniq | |
156 | + #assert_equal [1, 2], person.badges.map(&:level) | |
157 | + #end | |
158 | + | |
159 | + #should 'add merit points to community article owner when an user like it on community' do | |
160 | + #create_point_rule_definition('vote_voteable_author') | |
161 | + #community = fast_create(Community) | |
162 | + #article = create(TextArticle, :name => 'Test', :profile => community, :author => person) | |
163 | + | |
164 | + #c = GamificationPlugin::PointsCategorization.for_type(:vote_voteable_author).first | |
165 | + #assert_difference 'article.author.points(:category => c.id.to_s)', c.weight do | |
166 | + #Vote.create!(:voter => person, :voteable => article, :vote => 1) | |
167 | + #end | |
168 | + #end | |
169 | + | |
170 | + #should 'add merit points to article when an user like it on community' do | |
171 | + #create_point_rule_definition('vote_voteable') | |
172 | + #article = create(TextArticle, :name => 'Test', :profile => person, :author => person) | |
173 | + #article = article.reload | |
174 | + | |
175 | + #c = GamificationPlugin::PointsCategorization.for_type(:vote_voteable).first | |
176 | + #assert_difference 'article.points(:category => c.id.to_s)', c.weight do | |
177 | + #Vote.create!(:voter => person, :voteable => article, :vote => 1) | |
178 | + #end | |
179 | + #end | |
180 | + | |
181 | + #should 'add merit points to community when create a new article on community' do | |
182 | + #create_point_rule_definition('article_community') | |
183 | + #community = fast_create(Community) | |
184 | + #assert_difference 'community.score_points.count' do | |
185 | + #create(TextArticle, :profile_id => community.id, :author => person) | |
186 | + #end | |
187 | + #end | |
188 | + | |
189 | + #should 'add merit points to voter when he likes an article on community' do | |
190 | + #create_point_rule_definition('vote_voter') | |
191 | + #article = create(TextArticle, :name => 'Test', :profile => person, :author => person) | |
192 | + | |
193 | + #c = GamificationPlugin::PointsCategorization.for_type(:vote_voter).first | |
194 | + #assert_difference 'article.author.points(:category => c.id.to_s)', c.weight do | |
195 | + #Vote.create!(:voter => person, :voteable => article, :vote => 1) | |
196 | + #end | |
197 | + #end | |
198 | + | |
199 | + #should 'add merit points to voter when he dislikes an article on community' do | |
200 | + #create_point_rule_definition('vote_voter') | |
201 | + #article = create(TextArticle, :name => 'Test', :profile => person, :author => person) | |
202 | + | |
203 | + #c = GamificationPlugin::PointsCategorization.for_type(:vote_voter).first | |
204 | + #assert_difference 'article.author.points(:category => c.id.to_s)', c.weight do | |
205 | + #Vote.create!(:voter => person, :voteable => article, :vote => -1) | |
206 | + #end | |
207 | + #end | |
208 | + | |
209 | + #should 'add badge to author when users like his article on community' do | |
210 | + #GamificationPlugin::Badge.create!(:owner => environment, :name => 'positive_votes_received') | |
211 | + #GamificationPlugin.gamification_set_rules(environment) | |
212 | + | |
213 | + #article = create(TextArticle, :name => 'Test', :profile => person, :author => person) | |
214 | + #4.times { Vote.create!(:voter => fast_create(Person), :voteable => article, :vote => 1) } | |
215 | + #Vote.create!(:voter => fast_create(Person), :voteable => article, :vote => -1) | |
216 | + #assert_equal [], person.badges | |
217 | + #Vote.create!(:voter => fast_create(Person), :voteable => article, :vote => 1) | |
218 | + #assert_equal 'positive_votes_received', person.reload.badges.first.name | |
219 | + #end | |
220 | + | |
221 | + #should 'add badge to author when users dislike his article on community' do | |
222 | + #GamificationPlugin::Badge.create!(:owner => environment, :name => 'negative_votes_received') | |
223 | + #GamificationPlugin.gamification_set_rules(environment) | |
224 | + | |
225 | + #article = create(TextArticle, :name => 'Test', :profile => person, :author => person) | |
226 | + #4.times { Vote.create!(:voter => fast_create(Person), :voteable => article, :vote => -1) } | |
227 | + #Vote.create!(:voter => fast_create(Person), :voteable => article, :vote => 1) | |
228 | + #assert_equal [], person.badges | |
229 | + #Vote.create!(:voter => fast_create(Person), :voteable => article, :vote => -1) | |
230 | + #assert_equal 'negative_votes_received', person.reload.badges.first.name | |
231 | + #end | |
224 | 232 | |
225 | 233 | end | ... | ... |
test/unit/comment_test.rb
... | ... | @@ -153,138 +153,129 @@ class CommentTest < ActiveSupport::TestCase |
153 | 153 | end |
154 | 154 | end |
155 | 155 | |
156 | + ## Community related tests | |
157 | + should 'add merit community points to author when create a new comment in a community' do | |
158 | + community = fast_create(Community) | |
159 | + article = create(TextArticle, profile_id: community.id, author_id: person.id) | |
160 | + create_point_rule_definition('comment_author', article.profile) | |
161 | + create(Comment, :source => article, :author_id => person.id) | |
162 | + assert_equal 1, person.score_points.count | |
163 | + end | |
164 | + | |
165 | + should 'subtract merit community points from author when destroy a community comment' do | |
166 | + community = fast_create(Community) | |
167 | + article = create(TextArticle, profile_id: community.id, author_id: person.id) | |
168 | + create_point_rule_definition('comment_author', article.profile) | |
169 | + comment = create(Comment, :source => article, :author_id => person.id) | |
170 | + assert_equal 1, person.score_points.count | |
171 | + comment.destroy | |
172 | + assert_equal 2, person.score_points.count | |
173 | + assert_equal 0, person.points | |
174 | + end | |
175 | + | |
176 | + should 'add merit communty points to comment owner when an user like his comment inside a community' do | |
177 | + community = fast_create(Community) | |
178 | + article = create(TextArticle, profile_id: community.id, author_id: person.id) | |
179 | + create_point_rule_definition('vote_voteable_author', community) | |
180 | + comment = create(Comment, :source => article, :author_id => person.id) | |
181 | + | |
182 | + c = GamificationPlugin::PointsCategorization.for_type(:vote_voteable_author).where(profile_id: article.profile.id).first | |
183 | + assert_difference 'comment.author.points(:category => c.id.to_s)', c.weight do | |
184 | + Vote.create!(:voter => person, :voteable => comment, :vote => 1) | |
185 | + end | |
186 | + end | |
187 | + | |
188 | + should 'subtract merit community points to comment owner when an user unlike his comment inside a community' do | |
189 | + community = fast_create(Community) | |
190 | + article = create(TextArticle, profile_id: community.id, author_id: person.id) | |
191 | + create_point_rule_definition('vote_voteable_author', community) | |
192 | + comment = create(Comment, :source => article, :author_id => author.id) | |
193 | + Vote.create!(:voter => person, :voteable => comment, :vote => 1) | |
194 | + | |
195 | + c = GamificationPlugin::PointsCategorization.for_type(:vote_voteable_author).first | |
196 | + assert_difference 'comment.author.points', -1*c.weight do | |
197 | + Vote.where(:voteable_id => comment.id).destroy_all | |
198 | + end | |
199 | + end | |
200 | + | |
201 | + should 'subtract merit community points from comment owner when an user dislike his comment inside a community' do | |
202 | + community = fast_create(Community) | |
203 | + article = create(TextArticle, profile_id: community.id, author_id: person.id) | |
204 | + create_point_rule_definition('vote_voteable_author', community) | |
205 | + comment = create(Comment, :source => article, :author_id => person.id) | |
206 | + | |
207 | + c = GamificationPlugin::PointsCategorization.for_type(:vote_voteable_author).where(profile_id: article.profile.id).first | |
208 | + assert_difference 'comment.author.points(:category => c.id.to_s)', -1*c.weight do | |
209 | + Vote.create!(:voter => person, :voteable => comment, :vote => -1) | |
210 | + end | |
211 | + end | |
212 | + | |
213 | + should 'add merit community points from comment owner when an user remove a dislike in his comment inside a community' do | |
214 | + community = fast_create(Community) | |
215 | + article = create(TextArticle, profile_id: community.id, author_id: person.id) | |
216 | + create_point_rule_definition('vote_voteable_author', community) | |
217 | + comment = create(Comment, :source => article, :author_id => author.id) | |
218 | + Vote.create!(:voter => person, :voteable => comment, :vote => -1) | |
219 | + | |
220 | + c = GamificationPlugin::PointsCategorization.for_type(:vote_voteable_author).first | |
221 | + assert_difference 'comment.author.points', c.weight do | |
222 | + Vote.where(:voteable_id => comment.id).destroy_all | |
223 | + end | |
224 | + end | |
225 | + | |
226 | + should 'add merit community points to article author when create a new comment inside a community' do | |
227 | + community = fast_create(Community) | |
228 | + article = create(TextArticle, profile_id: community.id, author_id: author.id) | |
229 | + create_point_rule_definition('comment_article_author', community) | |
230 | + assert_difference 'author.score_points.count' do | |
231 | + create(Comment, :source => article, :author_id => author.id) | |
232 | + end | |
233 | + end | |
234 | + | |
235 | + should 'add merit community points to voter when he likes a comment inside a community' do | |
236 | + community = fast_create(Community) | |
237 | + article = create(TextArticle, profile_id: community.id, author_id: person.id) | |
238 | + create_point_rule_definition('vote_voter') | |
239 | + comment = create(Comment, :source => article, :author_id => person.id) | |
240 | + | |
241 | + c = GamificationPlugin::PointsCategorization.for_type(:vote_voter).first | |
242 | + assert_difference 'comment.author.points(:category => c.id.to_s)', c.weight do | |
243 | + Vote.create!(:voter => person, :voteable => comment, :vote => 1) | |
244 | + end | |
245 | + end | |
246 | + | |
247 | + should 'add merit community points to voter when he dislikes a comment inside a community' do | |
248 | + community = fast_create(Community) | |
249 | + article = create(TextArticle, profile_id: community.id, author_id: person.id) | |
250 | + create_point_rule_definition('vote_voter') | |
251 | + comment = create(Comment, :source => article, :author_id => person.id) | |
252 | + | |
253 | + c = GamificationPlugin::PointsCategorization.for_type(:vote_voter).first | |
254 | + assert_difference 'comment.author.points(:category => c.id.to_s)', c.weight do | |
255 | + Vote.create!(:voter => person, :voteable => comment, :vote => -1) | |
256 | + end | |
257 | + end | |
258 | + | |
259 | + should 'add merit community points to source article when create a comment inside a community' do | |
260 | + community = fast_create(Community) | |
261 | + article = create(TextArticle, profile_id: community.id, author_id: person.id) | |
262 | + create_point_rule_definition('comment_article') | |
263 | + c = GamificationPlugin::PointsCategorization.for_type(:comment_article).first | |
264 | + assert_difference 'article.points(:category => c.id.to_s)', c.weight do | |
265 | + create(Comment, :source => article, :author_id => person.id) | |
266 | + end | |
267 | + end | |
268 | + | |
269 | + should 'add merit community points to source community when create a comment' do | |
270 | + create_point_rule_definition('comment_community') | |
271 | + community = fast_create(Community) | |
272 | + article = create(TextileArticle, :profile_id => community.id, :author_id => author.id) | |
273 | + | |
274 | + c = GamificationPlugin::PointsCategorization.for_type(:comment_community).first | |
275 | + assert_difference 'community.points(:category => c.id.to_s)', c.weight do | |
276 | + create(Comment, :source => article, :author_id => person.id) | |
277 | + end | |
278 | + end | |
156 | 279 | |
157 | -# FIXME Put the tests above to works in profile context. | |
158 | -# They are the same tests of the general context | |
159 | -# | |
160 | -# should 'add merit points to author when create a new comment' do | |
161 | -# create(Comment, :source => article, :author_id => person.id) | |
162 | -# assert_equal 1, person.score_points.count | |
163 | -# end | |
164 | -# | |
165 | -# should 'subtract merit points from author when destroy a comment' do | |
166 | -# comment = create(Comment, :source => article, :author_id => person.id) | |
167 | -# assert_equal 1, person.score_points.count | |
168 | -# comment.destroy | |
169 | -# assert_equal 2, person.score_points.count | |
170 | -# assert_equal 0, person.points | |
171 | -# end | |
172 | -# | |
173 | -# should 'add merit badge to author when create 5 new comments' do | |
174 | -# GamificationPlugin::Badge.create!(:owner => environment, :name => 'comment_author') | |
175 | -# GamificationPlugin.gamification_set_rules(environment) | |
176 | -# | |
177 | -# 5.times { create(Comment, :source => article, :author_id => person.id) } | |
178 | -# assert_equal 'comment_author', person.badges.first.name | |
179 | -# end | |
180 | -# | |
181 | -# should 'add merit badge to source author when create 5 new comments' do | |
182 | -# GamificationPlugin::Badge.create!(:owner => environment, :name => 'comment_received') | |
183 | -# GamificationPlugin.gamification_set_rules(environment) | |
184 | -# | |
185 | -# 5.times { create(Comment, :source => article, :author_id => person.id) } | |
186 | -# assert_equal 'comment_received', author.badges.first.name | |
187 | -# end | |
188 | -# | |
189 | -# should 'add badge to author when users like his comment' do | |
190 | -# GamificationPlugin::Badge.create!(:owner => environment, :name => 'positive_votes_received') | |
191 | -# GamificationPlugin.gamification_set_rules(environment) | |
192 | -# | |
193 | -# comment = create(Comment, :source => article, :author_id => person.id) | |
194 | -# 4.times { Vote.create!(:voter => fast_create(Person), :voteable => comment, :vote => 1) } | |
195 | -# Vote.create!(:voter => fast_create(Person), :voteable => comment, :vote => -1) | |
196 | -# assert_equal [], person.badges | |
197 | -# Vote.create!(:voter => fast_create(Person), :voteable => comment, :vote => 1) | |
198 | -# assert_equal 'positive_votes_received', person.reload.badges.first.name | |
199 | -# end | |
200 | -# | |
201 | -# should 'add badge to author when users dislike his comment' do | |
202 | -# GamificationPlugin::Badge.create!(:owner => environment, :name => 'negative_votes_received') | |
203 | -# GamificationPlugin.gamification_set_rules(environment) | |
204 | -# | |
205 | -# comment = create(Comment, :source => article, :author_id => person.id) | |
206 | -# 4.times { Vote.create!(:voter => fast_create(Person), :voteable => comment, :vote => -1) } | |
207 | -# Vote.create!(:voter => fast_create(Person), :voteable => comment, :vote => 1) | |
208 | -# assert_equal [], person.badges | |
209 | -# Vote.create!(:voter => fast_create(Person), :voteable => comment, :vote => -1) | |
210 | -# assert_equal 'negative_votes_received', person.reload.badges.first.name | |
211 | -# end | |
212 | -# | |
213 | -# should 'add merit points to comment owner when an user like his comment' do | |
214 | -# comment = create(Comment, :source => article, :author_id => person.id) | |
215 | -# | |
216 | -# c = GamificationPlugin::PointsCategorization.for_type(:vote_voteable_author).where(profile_id: article.profile.id).first | |
217 | -# assert_difference 'comment.author.points(:category => c.id.to_s)', c.weight do | |
218 | -# Vote.create!(:voter => person, :voteable => comment, :vote => 1) | |
219 | -# end | |
220 | -# end | |
221 | -# | |
222 | -# should 'subtract merit points to comment owner when an user unlike his comment' do | |
223 | -# comment = create(Comment, :source => article, :author_id => author.id) | |
224 | -# Vote.create!(:voter => person, :voteable => comment, :vote => 1) | |
225 | -# | |
226 | -# assert_difference 'comment.author.points', -20 do | |
227 | -# Vote.where(:voteable_id => comment.id).destroy_all | |
228 | -# end | |
229 | -# end | |
230 | -# | |
231 | -# should 'subtract merit points from comment owner when an user dislike his comment' do | |
232 | -# comment = create(Comment, :source => article, :author_id => person.id) | |
233 | -# | |
234 | -# c = GamificationPlugin::PointsCategorization.for_type(:vote_voteable_author).where(profile_id: article.profile.id).first | |
235 | -# assert_difference 'comment.author.points(:category => c.id.to_s)', -1*c.weight do | |
236 | -# Vote.create!(:voter => person, :voteable => comment, :vote => -1) | |
237 | -# end | |
238 | -# end | |
239 | -# | |
240 | -# should 'add merit points from comment owner when an user remove a dislike in his comment' do | |
241 | -# comment = create(Comment, :source => article, :author_id => author.id) | |
242 | -# Vote.create!(:voter => person, :voteable => comment, :vote => -1) | |
243 | -# | |
244 | -# assert_difference 'comment.author.points', 20 do | |
245 | -# Vote.where(:voteable_id => comment.id).destroy_all | |
246 | -# end | |
247 | -# end | |
248 | -# | |
249 | -# should 'add merit points to article author when create a new comment' do | |
250 | -# assert_difference 'author.score_points.count' do | |
251 | -# create(Comment, :source => article, :author_id => person.id) | |
252 | -# end | |
253 | -# end | |
254 | -# | |
255 | -# should 'add merit points to voter when he likes a comment' do | |
256 | -# comment = create(Comment, :source => article, :author_id => person.id) | |
257 | -# | |
258 | -# c = GamificationPlugin::PointsCategorization.for_type(:vote_voter).where(profile_id: community.id).first | |
259 | -# assert_difference 'comment.author.points(:category => c.id.to_s)', c.weight do | |
260 | -# Vote.create!(:voter => person, :voteable => comment, :vote => 1) | |
261 | -# end | |
262 | -# end | |
263 | -# | |
264 | -# should 'add merit points to voter when he dislikes a comment' do | |
265 | -# comment = create(Comment, :source => article, :author_id => person.id) | |
266 | -# | |
267 | -# c = GamificationPlugin::PointsCategorization.for_type(:vote_voter).where(profile_id: community.id).first | |
268 | -# assert_difference 'comment.author.points(:category => c.id.to_s)', c.weight do | |
269 | -# Vote.create!(:voter => person, :voteable => comment, :vote => -1) | |
270 | -# end | |
271 | -# end | |
272 | -# | |
273 | -# should 'add merit points to source article when create a comment' do | |
274 | -# c = GamificationPlugin::PointsCategorization.for_type(:comment_article).where(profile_id: community.id).first | |
275 | -# assert_difference 'article.points(:category => c.id.to_s)', c.weight do | |
276 | -# create(Comment, :source => article, :author_id => person.id) | |
277 | -# end | |
278 | -# end | |
279 | -# | |
280 | -# should 'add merit points to source community when create a comment' do | |
281 | -# article = create(TextileArticle, :profile_id => community.id, :author_id => author.id) | |
282 | -# | |
283 | -# c = GamificationPlugin::PointsCategorization.for_type(:comment_community).where(profile_id: community.id).first | |
284 | -# assert_difference 'community.points(:category => c.id.to_s)', c.weight do | |
285 | -# create(Comment, :source => article, :author_id => person.id) | |
286 | -# end | |
287 | -# end | |
288 | -# | |
289 | 280 | |
290 | 281 | end | ... | ... |