Skip to content

Commit

Permalink
Merge pull request #90 from rootstrap/fix/import_devise_token_auth_us…
Browse files Browse the repository at this point in the history
…ing_https

Import devise token auth using https
  • Loading branch information
Maicol Bentancor authored and MaicolBen committed Sep 22, 2017
2 parents c06d302 + b9b752e commit 9e62fe6
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 44 deletions.
21 changes: 20 additions & 1 deletion .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
engines:
brakeman:
enabled: true
bundler-audit:
enabled: true
csslint:
enabled: true
duplication:
enabled: true
exclude_paths:
- spec/**/*
flog:
enabled: true
exclude_paths:
- db/**/*
- config/**/*
- spec/**/*
rubocop:
enabled: true
exclude_paths:
- db/**/*
channel: rubocop-0-49
checks:
Insecure Source:
Rubocop/Style/FrozenStringLiteralComment:
enabled: false
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ gem 'carrierwave', '~> 0.11.2'
gem 'carrierwave-base64', '~> 2.3.4'
gem 'delayed_job_active_record', '~> 4.1.2'
gem 'devise', '~> 4.3.0'
gem 'devise_token_auth', github: 'rootstrap/devise_token_auth'
gem 'devise_token_auth', git: 'https://github.com/rootstrap/devise_token_auth'
gem 'draper', '~> 3.0.0'
gem 'fog-aws', '~> 0.12.0'
gem 'haml-rails', '~> 1.0.0'
Expand Down Expand Up @@ -65,4 +65,4 @@ group :assets do
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby]
gem 'tzinfo-data', platforms: %i(mingw mswin x64_mingw jruby)
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
GIT
remote: git://github.com/rootstrap/devise_token_auth.git
remote: https://github.com/rootstrap/devise_token_auth
revision: c1bb7120a6be2c71c635a04aa12605347588bca1
specs:
devise_token_auth (0.1.42)
Expand Down
62 changes: 24 additions & 38 deletions spec/requests/api/v1/sessions/create_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
require 'rails_helper'

describe 'POST api/v1/users/sign_in', type: :request do
shared_context 'log in successfully' do
it 'returns success' do
expect(response).to be_success
end

it 'returns the user' do
expect(json[:user][:id]).to eq(user.id)
expect(json[:user][:email]).to eq(user.email)
expect(json[:user][:username]).to eq(user.username)
expect(json[:user][:uid]).to eq(user.uid)
expect(json[:user][:provider]).to eq('email')
expect(json[:user][:first_name]).to eq(user.first_name)
expect(json[:user][:last_name]).to eq(user.last_name)
end

it 'returns a valid client and access token' do
token = response.header['access-token']
client = response.header['client']
expect(user.reload.valid_token?(token, client)).to be_truthy
end
end

let(:password) { 'password' }
let(:token) do
{
Expand Down Expand Up @@ -33,25 +55,7 @@
post new_user_session_path, params: params, as: :json
end

it 'returns success' do
expect(response).to be_success
end

it 'returns the user' do
expect(json[:user][:id]).to eq(user.id)
expect(json[:user][:email]).to eq(user.email)
expect(json[:user][:username]).to eq(user.username)
expect(json[:user][:uid]).to eq(user.uid)
expect(json[:user][:provider]).to eq('email')
expect(json[:user][:first_name]).to eq(user.first_name)
expect(json[:user][:last_name]).to eq(user.last_name)
end

it 'returns a valid client and access token' do
token = response.header['access-token']
client = response.header['client']
expect(user.reload.valid_token?(token, client)).to be_truthy
end
it_behaves_like 'log in successfully'
end

context 'with incorrect params' do
Expand Down Expand Up @@ -85,24 +89,6 @@
post new_user_session_path, params: params, as: :json
end

it 'returns success' do
expect(response).to be_success
end

it 'returns the user' do
expect(json[:user][:id]).to eq(user.id)
expect(json[:user][:email]).to eq(user.email)
expect(json[:user][:username]).to eq(user.username)
expect(json[:user][:uid]).to eq(user.uid)
expect(json[:user][:provider]).to eq('email')
expect(json[:user][:first_name]).to eq(user.first_name)
expect(json[:user][:last_name]).to eq(user.last_name)
end

it 'returns a valid client and access token' do
token = response.header['access-token']
client = response.header['client']
expect(user.reload.valid_token?(token, client)).to be_truthy
end
it_behaves_like 'log in successfully'
end
end
2 changes: 0 additions & 2 deletions spec/requests/api/v1/users/create_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@
context 'when the password is incorrect' do
let(:password) { 'short' }
let(:password_confirmation) { 'short' }

let(:new_user) { User.find_by_email(email) }

it 'does not create a user' do
Expand All @@ -87,7 +86,6 @@
context 'when passwords don\'t match' do
let(:password) { 'shouldmatch' }
let(:password_confirmation) { 'dontmatch' }

let(:new_user) { User.find_by_email(email) }

it 'does not create a user' do
Expand Down

0 comments on commit 9e62fe6

Please sign in to comment.