Introduce access token fabricators (#4401)
This commit is contained in:
parent
bb96ba13cf
commit
4f0b638cda
|
@ -4,7 +4,7 @@ describe Api::V1::Accounts::CredentialsController do
|
||||||
render_views
|
render_views
|
||||||
|
|
||||||
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
|
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
|
||||||
let(:token) { double acceptable?: true, resource_owner_id: user.id }
|
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'write') }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
allow(controller).to receive(:doorkeeper_token) { token }
|
allow(controller).to receive(:doorkeeper_token) { token }
|
||||||
|
|
|
@ -4,7 +4,7 @@ describe Api::V1::Accounts::FollowerAccountsController do
|
||||||
render_views
|
render_views
|
||||||
|
|
||||||
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
|
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
|
||||||
let(:token) { double acceptable?: true, resource_owner_id: user.id }
|
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'read') }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
Fabricate(:follow, target_account: user.account)
|
Fabricate(:follow, target_account: user.account)
|
||||||
|
|
|
@ -4,7 +4,7 @@ describe Api::V1::Accounts::FollowingAccountsController do
|
||||||
render_views
|
render_views
|
||||||
|
|
||||||
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
|
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
|
||||||
let(:token) { double acceptable?: true, resource_owner_id: user.id }
|
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'read') }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
Fabricate(:follow, account: user.account)
|
Fabricate(:follow, account: user.account)
|
||||||
|
|
|
@ -4,7 +4,7 @@ describe Api::V1::Accounts::RelationshipsController do
|
||||||
render_views
|
render_views
|
||||||
|
|
||||||
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
|
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
|
||||||
let(:token) { double acceptable?: true, resource_owner_id: user.id }
|
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'read') }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
allow(controller).to receive(:doorkeeper_token) { token }
|
allow(controller).to receive(:doorkeeper_token) { token }
|
||||||
|
|
|
@ -4,7 +4,7 @@ RSpec.describe Api::V1::Accounts::SearchController, type: :controller do
|
||||||
render_views
|
render_views
|
||||||
|
|
||||||
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
|
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
|
||||||
let(:token) { double acceptable?: true, resource_owner_id: user.id }
|
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'read') }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
allow(controller).to receive(:doorkeeper_token) { token }
|
allow(controller).to receive(:doorkeeper_token) { token }
|
||||||
|
|
|
@ -4,7 +4,7 @@ describe Api::V1::Accounts::StatusesController do
|
||||||
render_views
|
render_views
|
||||||
|
|
||||||
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
|
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
|
||||||
let(:token) { double acceptable?: true, resource_owner_id: user.id }
|
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'read') }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
allow(controller).to receive(:doorkeeper_token) { token }
|
allow(controller).to receive(:doorkeeper_token) { token }
|
||||||
|
|
|
@ -4,7 +4,7 @@ RSpec.describe Api::V1::AccountsController, type: :controller do
|
||||||
render_views
|
render_views
|
||||||
|
|
||||||
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
|
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
|
||||||
let(:token) { double acceptable?: true, resource_owner_id: user.id }
|
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'follow read') }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
allow(controller).to receive(:doorkeeper_token) { token }
|
allow(controller).to receive(:doorkeeper_token) { token }
|
||||||
|
|
|
@ -4,7 +4,7 @@ RSpec.describe Api::V1::BlocksController, type: :controller do
|
||||||
render_views
|
render_views
|
||||||
|
|
||||||
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
|
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
|
||||||
let(:token) { double acceptable?: true, resource_owner_id: user.id }
|
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'follow') }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
Fabricate(:block, account: user.account)
|
Fabricate(:block, account: user.account)
|
||||||
|
|
|
@ -4,7 +4,7 @@ RSpec.describe Api::V1::DomainBlocksController, type: :controller do
|
||||||
render_views
|
render_views
|
||||||
|
|
||||||
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
|
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
|
||||||
let(:token) { double acceptable?: true, resource_owner_id: user.id }
|
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'follow') }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
user.account.block_domain!('example.com')
|
user.account.block_domain!('example.com')
|
||||||
|
|
|
@ -4,7 +4,7 @@ RSpec.describe Api::V1::FavouritesController, type: :controller do
|
||||||
render_views
|
render_views
|
||||||
|
|
||||||
let(:user) { Fabricate(:user) }
|
let(:user) { Fabricate(:user) }
|
||||||
let(:token) { double acceptable?: true, resource_owner_id: user.id }
|
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'read') }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
Fabricate(:favourite, account: user.account)
|
Fabricate(:favourite, account: user.account)
|
||||||
|
|
|
@ -4,7 +4,7 @@ RSpec.describe Api::V1::FollowRequestsController, type: :controller do
|
||||||
render_views
|
render_views
|
||||||
|
|
||||||
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice', locked: true)) }
|
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice', locked: true)) }
|
||||||
let(:token) { double acceptable?: true, resource_owner_id: user.id }
|
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'follow') }
|
||||||
let(:follower) { Fabricate(:account, username: 'bob') }
|
let(:follower) { Fabricate(:account, username: 'bob') }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
|
|
@ -4,7 +4,7 @@ RSpec.describe Api::V1::FollowsController, type: :controller do
|
||||||
render_views
|
render_views
|
||||||
|
|
||||||
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
|
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
|
||||||
let(:token) { double acceptable?: true, resource_owner_id: user.id }
|
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'follow') }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
allow(controller).to receive(:doorkeeper_token) { token }
|
allow(controller).to receive(:doorkeeper_token) { token }
|
||||||
|
|
|
@ -6,7 +6,7 @@ RSpec.describe Api::V1::InstancesController, type: :controller do
|
||||||
render_views
|
render_views
|
||||||
|
|
||||||
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
|
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
|
||||||
let(:token) { double acceptable?: true, resource_owner_id: user.id }
|
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
allow(controller).to receive(:doorkeeper_token) { token }
|
allow(controller).to receive(:doorkeeper_token) { token }
|
||||||
|
|
|
@ -4,7 +4,7 @@ RSpec.describe Api::V1::MediaController, type: :controller do
|
||||||
render_views
|
render_views
|
||||||
|
|
||||||
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
|
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
|
||||||
let(:token) { double acceptable?: true, resource_owner_id: user.id }
|
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'write') }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
allow(controller).to receive(:doorkeeper_token) { token }
|
allow(controller).to receive(:doorkeeper_token) { token }
|
||||||
|
|
|
@ -4,7 +4,7 @@ RSpec.describe Api::V1::MutesController, type: :controller do
|
||||||
render_views
|
render_views
|
||||||
|
|
||||||
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
|
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
|
||||||
let(:token) { double acceptable?: true, resource_owner_id: user.id }
|
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'follow') }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
Fabricate(:mute, account: user.account)
|
Fabricate(:mute, account: user.account)
|
||||||
|
|
|
@ -4,7 +4,7 @@ RSpec.describe Api::V1::NotificationsController, type: :controller do
|
||||||
render_views
|
render_views
|
||||||
|
|
||||||
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
|
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
|
||||||
let(:token) { double acceptable?: true, resource_owner_id: user.id }
|
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'read') }
|
||||||
let(:other) { Fabricate(:user, account: Fabricate(:account, username: 'bob')) }
|
let(:other) { Fabricate(:user, account: Fabricate(:account, username: 'bob')) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
|
|
@ -6,7 +6,7 @@ RSpec.describe Api::V1::ReportsController, type: :controller do
|
||||||
render_views
|
render_views
|
||||||
|
|
||||||
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
|
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
|
||||||
let(:token) { double acceptable?: true, resource_owner_id: user.id }
|
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'read write') }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
allow(controller).to receive(:doorkeeper_token) { token }
|
allow(controller).to receive(:doorkeeper_token) { token }
|
||||||
|
|
|
@ -6,7 +6,7 @@ RSpec.describe Api::V1::SearchController, type: :controller do
|
||||||
render_views
|
render_views
|
||||||
|
|
||||||
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
|
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
|
||||||
let(:token) { double acceptable?: true, resource_owner_id: user.id }
|
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'read') }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
allow(controller).to receive(:doorkeeper_token) { token }
|
allow(controller).to receive(:doorkeeper_token) { token }
|
||||||
|
|
|
@ -5,7 +5,7 @@ RSpec.describe Api::V1::Statuses::FavouritedByAccountsController, type: :control
|
||||||
|
|
||||||
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
|
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
|
||||||
let(:app) { Fabricate(:application, name: 'Test app', website: 'http://testapp.com') }
|
let(:app) { Fabricate(:application, name: 'Test app', website: 'http://testapp.com') }
|
||||||
let(:token) { double acceptable?: true, resource_owner_id: user.id, application: app }
|
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, application: app) }
|
||||||
|
|
||||||
context 'with an oauth token' do
|
context 'with an oauth token' do
|
||||||
before do
|
before do
|
||||||
|
|
|
@ -7,7 +7,7 @@ describe Api::V1::Statuses::FavouritesController do
|
||||||
|
|
||||||
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
|
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
|
||||||
let(:app) { Fabricate(:application, name: 'Test app', website: 'http://testapp.com') }
|
let(:app) { Fabricate(:application, name: 'Test app', website: 'http://testapp.com') }
|
||||||
let(:token) { double acceptable?: true, resource_owner_id: user.id, application: app }
|
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'write', application: app) }
|
||||||
|
|
||||||
context 'with an oauth token' do
|
context 'with an oauth token' do
|
||||||
before do
|
before do
|
||||||
|
|
|
@ -7,7 +7,7 @@ describe Api::V1::Statuses::MutesController do
|
||||||
|
|
||||||
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
|
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
|
||||||
let(:app) { Fabricate(:application, name: 'Test app', website: 'http://testapp.com') }
|
let(:app) { Fabricate(:application, name: 'Test app', website: 'http://testapp.com') }
|
||||||
let(:token) { double acceptable?: true, resource_owner_id: user.id, application: app }
|
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'write', application: app) }
|
||||||
|
|
||||||
context 'with an oauth token' do
|
context 'with an oauth token' do
|
||||||
before do
|
before do
|
||||||
|
|
|
@ -5,7 +5,7 @@ RSpec.describe Api::V1::Statuses::RebloggedByAccountsController, type: :controll
|
||||||
|
|
||||||
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
|
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
|
||||||
let(:app) { Fabricate(:application, name: 'Test app', website: 'http://testapp.com') }
|
let(:app) { Fabricate(:application, name: 'Test app', website: 'http://testapp.com') }
|
||||||
let(:token) { double acceptable?: true, resource_owner_id: user.id, application: app }
|
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, application: app) }
|
||||||
|
|
||||||
context 'with an oauth token' do
|
context 'with an oauth token' do
|
||||||
before do
|
before do
|
||||||
|
|
|
@ -7,7 +7,7 @@ describe Api::V1::Statuses::ReblogsController do
|
||||||
|
|
||||||
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
|
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
|
||||||
let(:app) { Fabricate(:application, name: 'Test app', website: 'http://testapp.com') }
|
let(:app) { Fabricate(:application, name: 'Test app', website: 'http://testapp.com') }
|
||||||
let(:token) { double acceptable?: true, resource_owner_id: user.id, application: app }
|
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'write', application: app) }
|
||||||
|
|
||||||
context 'with an oauth token' do
|
context 'with an oauth token' do
|
||||||
before do
|
before do
|
||||||
|
|
|
@ -5,7 +5,7 @@ RSpec.describe Api::V1::StatusesController, type: :controller do
|
||||||
|
|
||||||
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
|
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
|
||||||
let(:app) { Fabricate(:application, name: 'Test app', website: 'http://testapp.com') }
|
let(:app) { Fabricate(:application, name: 'Test app', website: 'http://testapp.com') }
|
||||||
let(:token) { double acceptable?: true, resource_owner_id: user.id, application: app }
|
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, application: app, scopes: 'write') }
|
||||||
|
|
||||||
context 'with an oauth token' do
|
context 'with an oauth token' do
|
||||||
before do
|
before do
|
||||||
|
|
|
@ -12,7 +12,7 @@ describe Api::V1::Timelines::HomeController do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with a user context' do
|
context 'with a user context' do
|
||||||
let(:token) { double acceptable?: true, resource_owner_id: user.id }
|
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'read') }
|
||||||
|
|
||||||
describe 'GET #show' do
|
describe 'GET #show' do
|
||||||
before do
|
before do
|
||||||
|
@ -30,7 +30,7 @@ describe Api::V1::Timelines::HomeController do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'without a user context' do
|
context 'without a user context' do
|
||||||
let(:token) { double acceptable?: true, resource_owner_id: nil }
|
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: nil, scopes: 'read') }
|
||||||
|
|
||||||
describe 'GET #show' do
|
describe 'GET #show' do
|
||||||
it 'returns http unprocessable entity' do
|
it 'returns http unprocessable entity' do
|
||||||
|
|
|
@ -12,7 +12,7 @@ describe Api::V1::Timelines::PublicController do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with a user context' do
|
context 'with a user context' do
|
||||||
let(:token) { double acceptable?: true, resource_owner_id: user.id }
|
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id) }
|
||||||
|
|
||||||
describe 'GET #show' do
|
describe 'GET #show' do
|
||||||
before do
|
before do
|
||||||
|
@ -42,7 +42,7 @@ describe Api::V1::Timelines::PublicController do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'without a user context' do
|
context 'without a user context' do
|
||||||
let(:token) { double acceptable?: true, resource_owner_id: nil }
|
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: nil) }
|
||||||
|
|
||||||
describe 'GET #show' do
|
describe 'GET #show' do
|
||||||
it 'returns http success' do
|
it 'returns http success' do
|
||||||
|
|
|
@ -12,7 +12,7 @@ describe Api::V1::Timelines::TagController do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with a user context' do
|
context 'with a user context' do
|
||||||
let(:token) { double acceptable?: true, resource_owner_id: user.id }
|
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id) }
|
||||||
|
|
||||||
describe 'GET #show' do
|
describe 'GET #show' do
|
||||||
before do
|
before do
|
||||||
|
@ -28,7 +28,7 @@ describe Api::V1::Timelines::TagController do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'without a user context' do
|
context 'without a user context' do
|
||||||
let(:token) { double acceptable?: true, resource_owner_id: nil }
|
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: nil) }
|
||||||
|
|
||||||
describe 'GET #show' do
|
describe 'GET #show' do
|
||||||
it 'returns http success' do
|
it 'returns http success' do
|
||||||
|
|
2
spec/fabricators/access_token_fabricator.rb
Normal file
2
spec/fabricators/access_token_fabricator.rb
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
Fabricator :access_token, from: 'Doorkeeper::AccessToken' do
|
||||||
|
end
|
4
spec/fabricators/accessible_access_token_fabricator.rb
Normal file
4
spec/fabricators/accessible_access_token_fabricator.rb
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
Fabricator :accessible_access_token, from: :access_token do
|
||||||
|
expires_in { nil }
|
||||||
|
revoked_at { nil }
|
||||||
|
end
|
Reference in a new issue