session creation
This commit is contained in:
parent
0b2bd70f16
commit
f8093d2c09
9 changed files with 63 additions and 3 deletions
18
spec/controllers/application_controller_spec.rb
Normal file
18
spec/controllers/application_controller_spec.rb
Normal file
|
@ -0,0 +1,18 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe ApplicationController do
|
||||
describe 'current_user' do
|
||||
before(:all) do
|
||||
User.create(username: 'karol.selak@gmail.com', password: 'abcde')
|
||||
end
|
||||
context 'when a user is logged in' do
|
||||
it 'returns the user' do
|
||||
# TODO
|
||||
# expect(current_user.username).to eql('karol.selak@gmail.com')
|
||||
end
|
||||
end
|
||||
end
|
||||
describe 'logged_in?' do
|
||||
# TODO
|
||||
end
|
||||
end
|
|
@ -8,6 +8,11 @@ RSpec.describe SessionsController do
|
|||
end
|
||||
end
|
||||
describe 'get create' do
|
||||
# TODO test session status
|
||||
subject { get 'create' }
|
||||
it 'redirects to /welcome' do
|
||||
expect(subject).to redirect_to('/welcome')
|
||||
end
|
||||
end
|
||||
describe 'get welcome' do
|
||||
subject { get 'welcome' }
|
||||
|
|
|
@ -8,5 +8,19 @@ RSpec.describe UsersController do
|
|||
end
|
||||
end
|
||||
describe 'get create' do
|
||||
before(:all) do # TODO change it to cleanup after each test
|
||||
User.destroy_all
|
||||
end
|
||||
subject {
|
||||
get :create, params: {user: {username: 'karol.selak@gmail.com', password: 'abcde'}}
|
||||
}
|
||||
it 'creates a user' do
|
||||
subject
|
||||
expect(User.where(username: 'karol.selak@gmail.com').size).to eql(1)
|
||||
end
|
||||
it 'redirects to /welcome' do
|
||||
subject
|
||||
expect(subject).to redirect_to('/welcome')
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue