summaryrefslogtreecommitdiff
path: root/spec/requests/oauth_tokens_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/requests/oauth_tokens_spec.rb')
-rw-r--r--spec/requests/oauth_tokens_spec.rb44
1 files changed, 22 insertions, 22 deletions
diff --git a/spec/requests/oauth_tokens_spec.rb b/spec/requests/oauth_tokens_spec.rb
index 3873e754060..9174a0c9789 100644
--- a/spec/requests/oauth_tokens_spec.rb
+++ b/spec/requests/oauth_tokens_spec.rb
@@ -1,17 +1,17 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'OAuth Tokens requests' do
+describe "OAuth Tokens requests" do
let(:user) { create :user }
- let(:application) { create :oauth_application, scopes: 'api' }
+ let(:application) { create :oauth_application, scopes: "api" }
def request_access_token(user)
- post '/oauth/token',
+ post "/oauth/token",
params: {
- grant_type: 'authorization_code',
+ grant_type: "authorization_code",
code: generate_access_grant(user).token,
redirect_uri: application.redirect_uri,
client_id: application.uid,
- client_secret: application.secret
+ client_secret: application.secret,
}
end
@@ -19,39 +19,39 @@ describe 'OAuth Tokens requests' do
create :oauth_access_grant, application: application, resource_owner_id: user.id
end
- context 'when there is already a token for the application' do
+ context "when there is already a token for the application" do
let!(:existing_token) { create :oauth_access_token, application: application, resource_owner_id: user.id }
- context 'and the request is done by the resource owner' do
- it 'reuses and returns the stored token' do
- expect do
+ context "and the request is done by the resource owner" do
+ it "reuses and returns the stored token" do
+ expect {
request_access_token(user)
- end.not_to change { Doorkeeper::AccessToken.count }
+ }.not_to change { Doorkeeper::AccessToken.count }
- expect(json_response['access_token']).to eq existing_token.token
+ expect(json_response["access_token"]).to eq existing_token.token
end
end
- context 'and the request is done by a different user' do
+ context "and the request is done by a different user" do
let(:other_user) { create :user }
- it 'generates and returns a different token for a different owner' do
- expect do
+ it "generates and returns a different token for a different owner" do
+ expect {
request_access_token(other_user)
- end.to change { Doorkeeper::AccessToken.count }.by(1)
+ }.to change { Doorkeeper::AccessToken.count }.by(1)
- expect(json_response['access_token']).not_to be_nil
+ expect(json_response["access_token"]).not_to be_nil
end
end
end
- context 'when there is no token stored for the application' do
- it 'generates and returns a new token' do
- expect do
+ context "when there is no token stored for the application" do
+ it "generates and returns a new token" do
+ expect {
request_access_token(user)
- end.to change { Doorkeeper::AccessToken.count }.by(1)
+ }.to change { Doorkeeper::AccessToken.count }.by(1)
- expect(json_response['access_token']).not_to be_nil
+ expect(json_response["access_token"]).not_to be_nil
end
end
end