From 7f7bd5255269d0a0b0b2f282536630d9406f060d Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Fri, 13 Sep 2019 12:58:17 +1000 Subject: [PATCH] return empty email if not current user --- app/controllers/patrons_controller.rb | 2 +- spec/controllers/discourse_patrons/patrons_controller_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/patrons_controller.rb b/app/controllers/patrons_controller.rb index 9417a0d..6b4a8c0 100644 --- a/app/controllers/patrons_controller.rb +++ b/app/controllers/patrons_controller.rb @@ -5,7 +5,7 @@ module DiscoursePatrons skip_before_action :verify_authenticity_token, only: [:create] def index - result = {} + result = { email: '' } if current_user result[:email] = current_user.email diff --git a/spec/controllers/discourse_patrons/patrons_controller_spec.rb b/spec/controllers/discourse_patrons/patrons_controller_spec.rb index 17e4f9a..e3455c5 100644 --- a/spec/controllers/discourse_patrons/patrons_controller_spec.rb +++ b/spec/controllers/discourse_patrons/patrons_controller_spec.rb @@ -23,7 +23,7 @@ module DiscoursePatrons it 'has no current user email' do get :index, format: :json - expect(JSON.parse(response.body)['email']).to be_nil + expect(JSON.parse(response.body)['email']).to be_empty end end