Skip to content

Commit a3bbe5f

Browse files
committed
Improve test coverage for users controller and fix users redirect route name overshadow
1 parent 1695205 commit a3bbe5f

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

config/routes.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
defaults: { format: :html, locale: I18n.locale }
3232

3333
get 'search', to: 'search#search'
34-
get 'users', to: redirect('users/sign-in') # redirect for user after_sign_up
34+
# Avoid clobbering admin users_path helper; keep redirect but rename helper
35+
get 'users', to: redirect('users/sign-in'), as: :redirect_users # redirect for user after_sign_up
3536

3637
authenticated :user do # rubocop:todo Metrics/BlockLength
3738
resources :calendars
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# frozen_string_literal: true
2+
3+
require 'rails_helper'
4+
5+
RSpec.describe 'BetterTogether::UsersController', type: :request do
6+
let(:locale) { I18n.default_locale }
7+
8+
before do
9+
configure_host_platform
10+
login('[email protected]', 'password12345')
11+
end
12+
13+
describe 'GET /:locale/.../host/users' do
14+
it 'renders index' do
15+
get better_together.users_path(locale:)
16+
expect(response).to have_http_status(:ok)
17+
end
18+
19+
it 'renders show for the current user' do
20+
user = BetterTogether::User.find_by(email: '[email protected]')
21+
get better_together.user_path(locale:, id: user.id)
22+
expect(response).to have_http_status(:ok)
23+
end
24+
end
25+
end

0 commit comments

Comments
 (0)