Commit b581fa5755ab4e92c50dc21dae27e031ed5cf5ae

Authored by Hugo Melo
1 parent e647c029

Fix testings

test/unit/api_test.rb
@@ -7,6 +7,8 @@ class APITest < ActiveSupport::TestCase @@ -7,6 +7,8 @@ class APITest < ActiveSupport::TestCase
7 login_api 7 login_api
8 environment = Environment.default 8 environment = Environment.default
9 environment.enable_plugin(GamificationPlugin) 9 environment.enable_plugin(GamificationPlugin)
  10 + @community = create_merit_categorization
  11 + GamificationPlugin.gamification_set_rules(@environment)
10 end 12 end
11 13
12 should 'get my own badges' do 14 should 'get my own badges' do
@@ -14,7 +16,7 @@ class APITest < ActiveSupport::TestCase @@ -14,7 +16,7 @@ class APITest < ActiveSupport::TestCase
14 person.add_badge(badge.id) 16 person.add_badge(badge.id)
15 get "/api/v1/gamification_plugin/my/badges?#{params.to_query}" 17 get "/api/v1/gamification_plugin/my/badges?#{params.to_query}"
16 json = JSON.parse(last_response.body) 18 json = JSON.parse(last_response.body)
17 - assert_equal 'test_badge', json.first['name'] 19 + assert_equal 'test_badge', json['badges'].first['name']
18 end 20 end
19 21
20 should 'get my level' do 22 should 'get my level' do
@@ -71,7 +73,7 @@ class APITest < ActiveSupport::TestCase @@ -71,7 +73,7 @@ class APITest < ActiveSupport::TestCase
71 another_person.visible=false 73 another_person.visible=false
72 another_person.save 74 another_person.save
73 get "/api/v1/gamification_plugin/people/#{another_person.id}/level?#{params.to_query}" 75 get "/api/v1/gamification_plugin/people/#{another_person.id}/level?#{params.to_query}"
74 - json = JSON.parse(last_response.body) 76 + JSON.parse(last_response.body)
75 assert_equal 404, last_response.status 77 assert_equal 404, last_response.status
76 end 78 end
77 79
test/unit/comment_test.rb
@@ -78,7 +78,7 @@ class CommentTest < ActiveSupport::TestCase @@ -78,7 +78,7 @@ class CommentTest < ActiveSupport::TestCase
78 comment = create(Comment, :source => article, :author_id => author.id) 78 comment = create(Comment, :source => article, :author_id => author.id)
79 Vote.create!(:voter => person, :voteable => comment, :vote => 1) 79 Vote.create!(:voter => person, :voteable => comment, :vote => 1)
80 80
81 - assert_difference 'comment.author.points', -50 do 81 + assert_difference 'comment.author.points', -20 do
82 Vote.where(:voteable_id => comment.id).destroy_all 82 Vote.where(:voteable_id => comment.id).destroy_all
83 end 83 end
84 end 84 end
@@ -96,7 +96,7 @@ class CommentTest < ActiveSupport::TestCase @@ -96,7 +96,7 @@ class CommentTest < ActiveSupport::TestCase
96 comment = create(Comment, :source => article, :author_id => author.id) 96 comment = create(Comment, :source => article, :author_id => author.id)
97 Vote.create!(:voter => person, :voteable => comment, :vote => -1) 97 Vote.create!(:voter => person, :voteable => comment, :vote => -1)
98 98
99 - assert_difference 'comment.author.points', 50 do 99 + assert_difference 'comment.author.points', 20 do
100 Vote.where(:voteable_id => comment.id).destroy_all 100 Vote.where(:voteable_id => comment.id).destroy_all
101 end 101 end
102 end 102 end