Skip to content

Commit

Permalink
refactor: move users controller to kiqr gem
Browse files Browse the repository at this point in the history
  • Loading branch information
kjellberg committed Apr 15, 2024
1 parent decdf86 commit fadbe06
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 6 deletions.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Users::SessionsController < Devise::SessionsController
class Kiqr::SessionsController < Devise::SessionsController
# prepend_before_action :configure_permitted_parameters, if: :devise_controller?
prepend_before_action :otp_authentication, only: :create

Expand Down
2 changes: 1 addition & 1 deletion gems/kiqr/lib/kiqr/rails/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def default_controllers(options)
options[:controllers][:invitations] ||= "kiqr/invitations"
options[:controllers][:onboarding] ||= "kiqr/onboarding"
options[:controllers][:registrations] ||= "kiqr/registrations"
options[:controllers][:sessions] ||= "users/sessions"
options[:controllers][:sessions] ||= "kiqr/sessions"
options
end

Expand Down
8 changes: 4 additions & 4 deletions test/controllers/users/sessions_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Users::SessionsControllerTest < ActionDispatch::IntegrationTest
user = create(:user, :otp_enabled)
post user_session_path, params: {user: {email: user.email, password: user.password}}
assert_response :unprocessable_entity
assert_template "users/sessions/otp"
assert_template "kiqr/sessions/otp"

post user_session_path, params: {user: {otp_attempt: user.current_otp}}
assert_redirected_to dashboard_path
Expand All @@ -23,19 +23,19 @@ class Users::SessionsControllerTest < ActionDispatch::IntegrationTest
post user_session_path, params: {user: {email: user.email, password: user.password}}
post user_session_path, params: {user: {otp_attempt: "123456"}}
assert_response :unprocessable_entity
assert_template "users/sessions/otp"
assert_template "kiqr/sessions/otp"
end

test "renders form again if invalid email" do
post user_session_path, params: {user: {email: "unknown.email", password: "randompassword"}}
assert_response :unprocessable_entity
assert_template "users/sessions/new"
assert_template "kiqr/sessions/new"
end

test "renders form again if invalid password" do
user = create(:user)
post user_session_path, params: {user: {email: user.email, password: "randompassword"}}
assert_response :unprocessable_entity
assert_template "users/sessions/new"
assert_template "kiqr/sessions/new"
end
end

0 comments on commit fadbe06

Please sign in to comment.