Skip to content

Commit

Permalink
Merge pull request #53 from WWC-Hackathon-2023/logout
Browse files Browse the repository at this point in the history
Had to merge own PR - team members unavailable
  • Loading branch information
MelTravelz authored Oct 22, 2023
2 parents 38bed36 + 4c2900f commit 0464b84
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
# resources :users, only: [:show] #for ease of understanding, we will skip resoruces for now
put '/puzzles', to: 'puzzles#index'

post '/login', to: 'sessions#create'
delete '/logout', to: 'sessions#destroy'
post '/users/:user_id/login', to: 'sessions#create'
delete '/users/:user_id/logout', to: 'sessions#destroy'

get '/users/:user_id', to: 'users#show'
get '/users/:user_id/dashboard', to: 'users#dashboard'
Expand Down
14 changes: 7 additions & 7 deletions spec/requests/api/v1/sessions_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
}

headers = { 'CONTENT_TYPE' => 'application/json' }
post '/api/v1/login', headers:, params: JSON.generate(login_data)
post "/api/v1/users/#{user.id}/login", headers:, params: JSON.generate(login_data)

expect(response).to have_http_status(201)
expect(session[:user_id]).to eq(user.id)
Expand All @@ -43,7 +43,7 @@
}

headers = { 'CONTENT_TYPE' => 'application/json' }
post '/api/v1/login', headers:, params: JSON.generate(login_data)
post "/api/v1/users/#{user.id}/login", headers:, params: JSON.generate(login_data)

expect(response).to have_http_status(401)

Expand All @@ -63,12 +63,12 @@
login_data = { email: user.email, password: user.password }

headers = { 'CONTENT_TYPE' => 'application/json' }
post '/api/v1/login', headers:, params: JSON.generate(login_data)
post "/api/v1/users/#{user.id}/login", headers:, params: JSON.generate(login_data)

expect(response).to have_http_status(201)
expect(session[:user_id]).to eq(user.id)

delete '/api/v1/logout'
delete "/api/v1/users/#{user.id}/logout"

expect(response).to have_http_status(204)
expect(session[:user_id]).to be_nil
Expand All @@ -83,14 +83,14 @@
# login_data = { email: user.email, password: user.password }

# headers = { 'CONTENT_TYPE' => 'application/json' }
# post '/api/v1/login', headers:, params: JSON.generate(login_data)
# post "/api/v1/users/#{user.id}/login", headers:, params: JSON.generate(login_data)

# expect(response).to have_http_status(201)
# expect(session[:user_id]).to eq(user.id)

# delete '/api/v1/logout'
# delete "/api/v1/users/007/logout"

# expect(response).to have_http_status(???)
# expect(response).to have_http_status(401)
# expect(session[:user_id]).to eq(user.id)
# end
end
Expand Down

0 comments on commit 0464b84

Please sign in to comment.