Commit 2685bca3f83f127c318aef05cd30080cd885f347

Authored by Tallys Martins
1 parent f80df4d2
Exists in stable-spb-1.5

Fixing broken tests

Signed-off-by: Marcos Ronaldo <marcos.rpj2@gmail.com>
Signed-off-by: Tallys Martins <tallysmartins@gmail.com>
plugins/remote_user/test/unit/remote_user_plugin_test.rb
1 require 'test_helper' 1 require 'test_helper'
2 -require_relative '../../../../test/api/test_helper' 2 +require_relative '../../../../test/unit/api/test_helper'
3 3
4 class RemoteUserPluginTest < ActiveSupport::TestCase 4 class RemoteUserPluginTest < ActiveSupport::TestCase
5 should 'call remote user hotspot to authenticate in API' do 5 should 'call remote user hotspot to authenticate in API' do
test/unit/api/helpers_test.rb
@@ -106,24 +106,24 @@ class APIHelpersTest &lt; ActiveSupport::TestCase @@ -106,24 +106,24 @@ class APIHelpersTest &lt; ActiveSupport::TestCase
106 end 106 end
107 107
108 should 'find_article return article by id in list passed for user with permission' do 108 should 'find_article return article by id in list passed for user with permission' do
109 - user = create_user('someuser') 109 + login_api
110 a = fast_create(Article, :profile_id => user.person.id) 110 a = fast_create(Article, :profile_id => user.person.id)
111 fast_create(Article, :profile_id => user.person.id) 111 fast_create(Article, :profile_id => user.person.id)
112 fast_create(Article, :profile_id => user.person.id) 112 fast_create(Article, :profile_id => user.person.id)
113 113
114 - user.generate_private_token!  
115 - User.expects(:find_by_private_token).returns(user) 114 + self.params = {private_token: user.private_token}
  115 + User.expects(:find_by).with(private_token: user.private_token).returns(user)
116 assert_equal a, find_article(user.person.articles, a.id) 116 assert_equal a, find_article(user.person.articles, a.id)
117 end 117 end
118 118
119 should 'find_article return forbidden when a user try to access an article without permission' do 119 should 'find_article return forbidden when a user try to access an article without permission' do
120 - user = create_user('someuser') 120 + login_api
121 p = fast_create(Profile) 121 p = fast_create(Profile)
122 a = fast_create(Article, :published => false, :profile_id => p.id) 122 a = fast_create(Article, :published => false, :profile_id => p.id)
123 fast_create(Article, :profile_id => p.id) 123 fast_create(Article, :profile_id => p.id)
124 124
125 - user.generate_private_token!  
126 - User.expects(:find_by_private_token).returns(user) 125 + self.params = {private_token: user.private_token}
  126 + User.expects(:find_by).with(private_token: user.private_token).returns(user)
127 assert_equal 403, find_article(p.articles, a.id).last 127 assert_equal 403, find_article(p.articles, a.id).last
128 end 128 end
129 129