Commit ab14f92a5daa601b5dfd0b73f3424933a4d5efc0
1 parent
e8437fd4
Exists in
master
and in
1 other branch
Test badges for organizations
Showing
2 changed files
with
29 additions
and
0 deletions
Show diff stats
test/unit/article_test.rb
... | ... | @@ -189,4 +189,24 @@ class ArticleTest < ActiveSupport::TestCase |
189 | 189 | end |
190 | 190 | end |
191 | 191 | |
192 | + should "add organization's merit badge to author when create 5 new articles" do | |
193 | + organization = fast_create(Organization) | |
194 | + GamificationPlugin::Badge.create!(:owner => organization, :name => 'article_author', :level => 1) | |
195 | + GamificationPlugin.gamification_set_rules(environment) | |
196 | + | |
197 | + 5.times { create(TextArticle, :profile_id => organization.id, :author => person) } | |
198 | + assert_equal 'article_author', person.badges.first.name | |
199 | + assert_equal 1, person.badges.first.level | |
200 | + end | |
201 | + | |
202 | + should "do not earn organization's badge when the article is not posted in the organization itself" do | |
203 | + organization = fast_create(Organization) | |
204 | + other_organization = fast_create(Organization) | |
205 | + GamificationPlugin::Badge.create!(:owner => organization, :name => 'article_author', :level => 1) | |
206 | + GamificationPlugin.gamification_set_rules(environment) | |
207 | + | |
208 | + 5.times { create(TextArticle, :profile_id => other_organization.id, :author => person) } | |
209 | + assert_equal [], person.badges | |
210 | + end | |
211 | + | |
192 | 212 | end | ... | ... |
test/unit/comment_test.rb
... | ... | @@ -276,5 +276,14 @@ class CommentTest < ActiveSupport::TestCase |
276 | 276 | end |
277 | 277 | end |
278 | 278 | |
279 | + should "add organization's merit badge to author when create 5 new comments" do | |
280 | + organization = fast_create(Organization) | |
281 | + GamificationPlugin::Badge.create!(:owner => organization, :name => 'comment_author') | |
282 | + GamificationPlugin.gamification_set_rules(environment) | |
283 | + article.profile = organization | |
284 | + | |
285 | + 5.times { create(Comment, :source => article, :author_id => person.id) } | |
286 | + assert_equal 'comment_author', person.badges.first.name | |
287 | + end | |
279 | 288 | |
280 | 289 | end | ... | ... |