Introduce access token fabricators (#4401)

main
Akihiko Odaki 2017-07-27 22:16:07 +09:00 committed by Eugen Rochko
parent bb96ba13cf
commit 4f0b638cda
29 changed files with 36 additions and 30 deletions

View File

@ -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 }

View File

@ -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)

View File

@ -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)

View File

@ -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 }

View File

@ -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 }

View File

@ -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 }

View File

@ -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 }

View File

@ -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)

View File

@ -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')

View File

@ -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)

View File

@ -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

View File

@ -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 }

View File

@ -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 }

View File

@ -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 }

View File

@ -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)

View File

@ -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

View File

@ -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 }

View File

@ -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 }

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

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

View File

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