Skip to content
Extraits de code Groupes Projets
Valider 4f0b638c rédigé par Akihiko Odaki's avatar Akihiko Odaki Validation de Eugen Rochko
Parcourir les fichiers

Introduce access token fabricators (#4401)

parent bb96ba13
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Affichage de
avec 20 ajouts et 20 suppressions
...@@ -4,7 +4,7 @@ describe Api::V1::Accounts::CredentialsController do ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter