1
0
mirror of synced 2026-08-04 22:26:56 +00:00

send the current user

This commit is contained in:
Rimian Perkins
2019-09-13 12:35:38 +10:00
parent 32bf78fa9a
commit cb9af7c258
4 changed files with 21 additions and 3 deletions
+6 -1
View File
@@ -1,11 +1,16 @@
# frozen_string_literal: true
module DiscoursePatrons
class PatronsController < ApplicationController
class PatronsController < ::ApplicationController
skip_before_action :verify_authenticity_token, only: [:create]
def index
result = {}
if current_user
result[:email] = current_user.email
end
render json: result
end
@@ -48,7 +48,7 @@ export default Ember.Component.extend({
billing.set(key, undefined);
}
};
["name", "phone", "email"].forEach(key => deleteEmpty(key));
["name", "phone"].forEach(key => deleteEmpty(key));
},
actions: {
@@ -69,7 +69,6 @@
</div>
<div class="value">
{{input type="email" value=billing.email}}
<div class="desc">{{i18n 'discourse_patrons.payment.optional'}}</div>
</div>
</div>
<div class="display-row">
@@ -11,6 +11,20 @@ module DiscoursePatrons
get :index, format: :json
expect(response).to have_http_status(200)
end
it 'has a current user email' do
user = Fabricate(:user, email: 'hello@example.com')
controller.expects(:current_user).at_least(1).returns(user)
get :index, format: :json
expect(JSON.parse(response.body)['email']).to eq 'hello@example.com'
end
it 'has no current user email' do
get :index, format: :json
expect(JSON.parse(response.body)['email']).to be_nil
end
end
describe 'create' do