diff --git a/test/unit/article_test.rb b/test/unit/article_test.rb index 8faffc9..cb7aea7 100644 --- a/test/unit/article_test.rb +++ b/test/unit/article_test.rb @@ -189,4 +189,24 @@ class ArticleTest < ActiveSupport::TestCase end end + should "add organization's merit badge to author when create 5 new articles" do + organization = fast_create(Organization) + GamificationPlugin::Badge.create!(:owner => organization, :name => 'article_author', :level => 1) + GamificationPlugin.gamification_set_rules(environment) + + 5.times { create(TextArticle, :profile_id => organization.id, :author => person) } + assert_equal 'article_author', person.badges.first.name + assert_equal 1, person.badges.first.level + end + + should "do not earn organization's badge when the article is not posted in the organization itself" do + organization = fast_create(Organization) + other_organization = fast_create(Organization) + GamificationPlugin::Badge.create!(:owner => organization, :name => 'article_author', :level => 1) + GamificationPlugin.gamification_set_rules(environment) + + 5.times { create(TextArticle, :profile_id => other_organization.id, :author => person) } + assert_equal [], person.badges + end + end diff --git a/test/unit/comment_test.rb b/test/unit/comment_test.rb index 169d55f..b86cfa1 100644 --- a/test/unit/comment_test.rb +++ b/test/unit/comment_test.rb @@ -276,5 +276,14 @@ class CommentTest < ActiveSupport::TestCase end end + should "add organization's merit badge to author when create 5 new comments" do + organization = fast_create(Organization) + GamificationPlugin::Badge.create!(:owner => organization, :name => 'comment_author') + GamificationPlugin.gamification_set_rules(environment) + article.profile = organization + + 5.times { create(Comment, :source => article, :author_id => person.id) } + assert_equal 'comment_author', person.badges.first.name + end end -- libgit2 0.21.2