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

parent d13d2452
......@@ -11,14 +11,14 @@ module Public
def create
@user = get_user
@user.admin_unsubscribe!
@user.admin_unsubscribe! if @user
redirect_to new_user_session_path, notice: 'You have been unsubscribed'
end
protected
def get_user
@email = "#{params[:email]}.#{params[:format]}"
User.where(email: @email).first!
User.where(email: @email).first
end
end
end
\ No newline at end of file
......@@ -9,6 +9,12 @@ describe Public::UnsubscribesController do
assert_response :success
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
describe "create" do
......@@ -17,5 +23,12 @@ describe Public::UnsubscribesController do
assert user.reload.admin_email_unsubscribed_at
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
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