Introduce access token fabricators (#4401)

main
Akihiko Odaki 7 years ago committed by Eugen Rochko
parent bb96ba13cf
commit 4f0b638cda

@ -4,7 +4,7 @@ describe Api::V1::Accounts::CredentialsController do
render_views
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
allow(controller).to receive(:doorkeeper_token) { token }

@ -4,7 +4,7 @@ describe Api::V1::Accounts::FollowerAccountsController do
render_views
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
Fabricate(:follow, target_account: user.account)

@ -4,7 +4,7 @@ describe Api::V1::Accounts::FollowingAccountsController do
render_views
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
Fabricate(:follow, account: user.account)

@ -4,7 +4,7 @@ describe Api::V1::Accounts::RelationshipsController do
render_views
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
allow(controller).to receive(:doorkeeper_token) { token }

@ -4,7 +4,7 @@ RSpec.describe Api::V1::Accounts::SearchController, type: :controller do
render_views
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
allow(controller).to receive(:doorkeeper_token) { token }

@ -4,7 +4,7 @@ describe Api::V1::Accounts::StatusesController do
render_views
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
allow(controller).to receive(:doorkeeper_token) { token }

@ -4,7 +4,7 @@ RSpec.describe Api::V1::AccountsController, type: :controller do
render_views
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
allow(controller).to receive(:doorkeeper_token) { token }

@ -4,7 +4,7 @@ RSpec.describe Api::V1::BlocksController, type: :controller do
render_views
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
Fabricate(:block, account: user.account)

@ -4,7 +4,7 @@ RSpec.describe Api::V1::DomainBlocksController, type: :controller do
render_views
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
user.account.block_domain!('example.com')

@ -4,7 +4,7 @@ RSpec.describe Api::V1::FavouritesController, type: :controller do
render_views
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
Fabricate(:favourite, account: user.account)

@ -4,7 +4,7 @@ RSpec.describe Api::V1::FollowRequestsController, type: :controller do
render_views
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') }
before do

@ -4,7 +4,7 @@ RSpec.describe Api::V1::FollowsController, type: :controller do
render_views
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
allow(controller).to receive(:doorkeeper_token) { token }

@ -6,7 +6,7 @@ RSpec.describe Api::V1::InstancesController, type: :controller do
render_views
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
allow(controller).to receive(:doorkeeper_token) { token }

@ -4,7 +4,7 @@ RSpec.describe Api::V1::MediaController, type: :controller do
render_views
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
allow(controller).to receive(:doorkeeper_token) { token }

@ -4,7 +4,7 @@ RSpec.describe Api::V1::MutesController, type: :controller do
render_views
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
Fabricate(:mute, account: user.account)

@ -4,7 +4,7 @@ RSpec.describe Api::V1::NotificationsController, type: :controller do
render_views
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')) }
before do

@ -6,7 +6,7 @@ RSpec.describe Api::V1::ReportsController, type: :controller do
render_views
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
allow(controller).to receive(:doorkeeper_token) { token }

@ -6,7 +6,7 @@ RSpec.describe Api::V1::SearchController, type: :controller do
render_views
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
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(: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
before do

@ -7,7 +7,7 @@ describe Api::V1::Statuses::FavouritesController do
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
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
before do

@ -7,7 +7,7 @@ describe Api::V1::Statuses::MutesController do
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
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
before do

@ -5,7 +5,7 @@ RSpec.describe Api::V1::Statuses::RebloggedByAccountsController, type: :controll
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
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
before do

@ -7,7 +7,7 @@ describe Api::V1::Statuses::ReblogsController do
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
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
before do

@ -5,7 +5,7 @@ RSpec.describe Api::V1::StatusesController, type: :controller do
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
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
before do

@ -12,7 +12,7 @@ describe Api::V1::Timelines::HomeController do
end
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
before do
@ -30,7 +30,7 @@ describe Api::V1::Timelines::HomeController do
end
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
it 'returns http unprocessable entity' do

@ -12,7 +12,7 @@ describe Api::V1::Timelines::PublicController do
end
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
before do
@ -42,7 +42,7 @@ describe Api::V1::Timelines::PublicController do
end
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
it 'returns http success' do

@ -12,7 +12,7 @@ describe Api::V1::Timelines::TagController do
end
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
before do
@ -28,7 +28,7 @@ describe Api::V1::Timelines::TagController do
end
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
it 'returns http success' do

@ -0,0 +1,2 @@
Fabricator :access_token, from: 'Doorkeeper::AccessToken' do
end

@ -0,0 +1,4 @@
Fabricator :accessible_access_token, from: :access_token do
expires_in { nil }
revoked_at { nil }
end
Loading…
Cancel
Save