mirror of
https://github.com/discourse/discourse-subscriptions.git
synced 2025-07-13 09:33:27 +00:00
send the current user
This commit is contained in:
parent
32bf78fa9a
commit
cb9af7c258
@ -1,11 +1,16 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module DiscoursePatrons
|
module DiscoursePatrons
|
||||||
class PatronsController < ApplicationController
|
class PatronsController < ::ApplicationController
|
||||||
skip_before_action :verify_authenticity_token, only: [:create]
|
skip_before_action :verify_authenticity_token, only: [:create]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
result = {}
|
result = {}
|
||||||
|
|
||||||
|
if current_user
|
||||||
|
result[:email] = current_user.email
|
||||||
|
end
|
||||||
|
|
||||||
render json: result
|
render json: result
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ export default Ember.Component.extend({
|
|||||||
billing.set(key, undefined);
|
billing.set(key, undefined);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
["name", "phone", "email"].forEach(key => deleteEmpty(key));
|
["name", "phone"].forEach(key => deleteEmpty(key));
|
||||||
},
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
|
@ -69,7 +69,6 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="value">
|
<div class="value">
|
||||||
{{input type="email" value=billing.email}}
|
{{input type="email" value=billing.email}}
|
||||||
<div class="desc">{{i18n 'discourse_patrons.payment.optional'}}</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="display-row">
|
<div class="display-row">
|
||||||
|
@ -11,6 +11,20 @@ module DiscoursePatrons
|
|||||||
get :index, format: :json
|
get :index, format: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(200)
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
describe 'create' do
|
describe 'create' do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user