Do not display other behaviour if the email address does not exist

parent d13d2452
...@@ -11,14 +11,14 @@ module Public ...@@ -11,14 +11,14 @@ module Public
def create def create
@user = get_user @user = get_user
@user.admin_unsubscribe! @user.admin_unsubscribe! if @user
redirect_to new_user_session_path, notice: 'You have been unsubscribed' redirect_to new_user_session_path, notice: 'You have been unsubscribed'
end end
protected protected
def get_user def get_user
@email = "#{params[:email]}.#{params[:format]}" @email = "#{params[:email]}.#{params[:format]}"
User.where(email: @email).first! User.where(email: @email).first
end end
end end
end end
\ No newline at end of file
...@@ -9,6 +9,12 @@ describe Public::UnsubscribesController do ...@@ -9,6 +9,12 @@ describe Public::UnsubscribesController do
assert_response :success assert_response :success
end end
it "behaves the same if email address isn't known in the system" do
get :show, email: 'i@dont_exists', format: 'com'
assert_response :success
end
end end
describe "create" do describe "create" do
...@@ -17,5 +23,12 @@ describe Public::UnsubscribesController do ...@@ -17,5 +23,12 @@ describe Public::UnsubscribesController do
assert user.reload.admin_email_unsubscribed_at assert user.reload.admin_email_unsubscribed_at
end end
# Don't tell if the email does not exists
it "behaves the same if email address isn't known in the system" do
post :create, email: 'i@dont_exists', format: 'com'
assert_response :redirect
end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment