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 7 login_api
8 8 environment = Environment.default
9 9 environment.enable_plugin(GamificationPlugin)
  10 + @community = create_merit_categorization
  11 + GamificationPlugin.gamification_set_rules(@environment)
10 12 end
11 13  
12 14 should 'get my own badges' do
... ... @@ -14,7 +16,7 @@ class APITest < ActiveSupport::TestCase
14 16 person.add_badge(badge.id)
15 17 get "/api/v1/gamification_plugin/my/badges?#{params.to_query}"
16 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 20 end
19 21  
20 22 should 'get my level' do
... ... @@ -71,7 +73,7 @@ class APITest < ActiveSupport::TestCase
71 73 another_person.visible=false
72 74 another_person.save
73 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 77 assert_equal 404, last_response.status
76 78 end
77 79  
... ...
test/unit/comment_test.rb
... ... @@ -78,7 +78,7 @@ class CommentTest < ActiveSupport::TestCase
78 78 comment = create(Comment, :source => article, :author_id => author.id)
79 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 82 Vote.where(:voteable_id => comment.id).destroy_all
83 83 end
84 84 end
... ... @@ -96,7 +96,7 @@ class CommentTest < ActiveSupport::TestCase
96 96 comment = create(Comment, :source => article, :author_id => author.id)
97 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 100 Vote.where(:voteable_id => comment.id).destroy_all
101 101 end
102 102 end
... ...