Commit b131b903 authored by Alper Akgun's avatar Alper Akgun

Merge branch '334009-send-source-to-customersdot' into 'master'

Send source to subscriptions portal

See merge request gitlab-org/gitlab!64905
parents 33e16cec 49237198
...@@ -26,6 +26,7 @@ export const confirmOrderParams = (state, getters) => ({ ...@@ -26,6 +26,7 @@ export const confirmOrderParams = (state, getters) => ({
plan_id: state.selectedPlan, plan_id: state.selectedPlan,
payment_method_id: state.paymentMethodId, payment_method_id: state.paymentMethodId,
quantity: state.numberOfUsers, quantity: state.numberOfUsers,
source: state.source,
}, },
}); });
......
...@@ -45,6 +45,7 @@ export default ({ ...@@ -45,6 +45,7 @@ export default ({
fullName, fullName,
newUser, newUser,
groupData = '[]', groupData = '[]',
source,
}) => { }) => {
const availablePlans = parsePlanData(plansData); const availablePlans = parsePlanData(plansData);
const isNewUser = parseBoolean(newUser); const isNewUser = parseBoolean(newUser);
...@@ -76,5 +77,6 @@ export default ({ ...@@ -76,5 +77,6 @@ export default ({
isConfirmingOrder: false, isConfirmingOrder: false,
taxRate: TAX_RATE, taxRate: TAX_RATE,
startDate: new Date(Date.now()), startDate: new Date(Date.now()),
source,
}; };
}; };
...@@ -79,7 +79,7 @@ class SubscriptionsController < ApplicationController ...@@ -79,7 +79,7 @@ class SubscriptionsController < ApplicationController
end end
def subscription_params def subscription_params
params.require(:subscription).permit(:plan_id, :payment_method_id, :quantity) params.require(:subscription).permit(:plan_id, :payment_method_id, :quantity, :source)
end end
def find_group def find_group
......
...@@ -11,7 +11,8 @@ module SubscriptionsHelper ...@@ -11,7 +11,8 @@ module SubscriptionsHelper
plan_id: params[:plan_id], plan_id: params[:plan_id],
namespace_id: params[:namespace_id], namespace_id: params[:namespace_id],
new_user: new_user?.to_s, new_user: new_user?.to_s,
group_data: present_groups(eligible_groups).to_json group_data: present_groups(eligible_groups).to_json,
source: params[:source]
} }
end end
......
...@@ -84,7 +84,8 @@ module Subscriptions ...@@ -84,7 +84,8 @@ module Subscriptions
}, },
gl_namespace_id: @group.id, gl_namespace_id: @group.id,
gl_namespace_name: @group.name, gl_namespace_name: @group.name,
preview: 'false' preview: 'false',
source: subscription_params[:source]
} }
end end
......
...@@ -177,7 +177,7 @@ RSpec.describe SubscriptionsController do ...@@ -177,7 +177,7 @@ RSpec.describe SubscriptionsController do
{ {
setup_for_company: setup_for_company, setup_for_company: setup_for_company,
customer: { company: 'My company', country: 'NL' }, customer: { company: 'My company', country: 'NL' },
subscription: { plan_id: 'x', quantity: 2 } subscription: { plan_id: 'x', quantity: 2, source: 'some_source' }
} }
end end
...@@ -215,7 +215,7 @@ RSpec.describe SubscriptionsController do ...@@ -215,7 +215,7 @@ RSpec.describe SubscriptionsController do
{ {
setup_for_company: setup_for_company, setup_for_company: setup_for_company,
customer: { country: 'NL' }, customer: { country: 'NL' },
subscription: { plan_id: 'x', quantity: 1 } subscription: { plan_id: 'x', quantity: 1, source: 'some_source' }
} }
end end
...@@ -282,7 +282,7 @@ RSpec.describe SubscriptionsController do ...@@ -282,7 +282,7 @@ RSpec.describe SubscriptionsController do
{ {
selected_group: selected_group.id, selected_group: selected_group.id,
customer: { country: 'NL' }, customer: { country: 'NL' },
subscription: { plan_id: 'x', quantity: 1 } subscription: { plan_id: 'x', quantity: 1, source: 'another_source' }
} }
end end
...@@ -357,7 +357,7 @@ RSpec.describe SubscriptionsController do ...@@ -357,7 +357,7 @@ RSpec.describe SubscriptionsController do
{ {
selected_group: non_existing_record_id, selected_group: non_existing_record_id,
customer: { country: 'NL' }, customer: { country: 'NL' },
subscription: { plan_id: 'x', quantity: 1 } subscription: { plan_id: 'x', quantity: 1, source: 'new_source' }
} }
end end
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
}, },
"gl_namespace_id": 222, "gl_namespace_id": 222,
"gl_namespace_name": "Group name", "gl_namespace_name": "Group name",
"preview": "false" "preview": "false",
"source": "some_source"
} }
} }
...@@ -20,6 +20,7 @@ const state = { ...@@ -20,6 +20,7 @@ const state = {
organizationName: 'Organization name', organizationName: 'Organization name',
paymentMethodId: 'Payment method ID', paymentMethodId: 'Payment method ID',
numberOfUsers: 1, numberOfUsers: 1,
source: 'some_source',
}; };
describe('Subscriptions Getters', () => { describe('Subscriptions Getters', () => {
...@@ -245,6 +246,7 @@ describe('Subscriptions Getters', () => { ...@@ -245,6 +246,7 @@ describe('Subscriptions Getters', () => {
plan_id: 'firstPlan', plan_id: 'firstPlan',
payment_method_id: 'Payment method ID', payment_method_id: 'Payment method ID',
quantity: 1, quantity: 1,
source: 'some_source',
}, },
}); });
}); });
......
...@@ -22,6 +22,7 @@ describe('projectsSelector default state', () => { ...@@ -22,6 +22,7 @@ describe('projectsSelector default state', () => {
setupForCompany: 'true', setupForCompany: 'true',
fullName: 'Full Name', fullName: 'Full Name',
newUser: 'true', newUser: 'true',
source: 'some_source',
}; };
const currentDate = new Date('2020-01-07T12:44:08.135Z'); const currentDate = new Date('2020-01-07T12:44:08.135Z');
...@@ -164,6 +165,10 @@ describe('projectsSelector default state', () => { ...@@ -164,6 +165,10 @@ describe('projectsSelector default state', () => {
expect(state.startDate).toEqual(currentDate); expect(state.startDate).toEqual(currentDate);
}); });
it('sets the source to the initial value', () => {
expect(state.source).toEqual('some_source');
});
it('sets the paymentFormParams to an empty object', () => { it('sets the paymentFormParams to an empty object', () => {
expect(state.paymentFormParams).toEqual({}); expect(state.paymentFormParams).toEqual({});
}); });
......
...@@ -37,7 +37,7 @@ RSpec.describe SubscriptionsHelper do ...@@ -37,7 +37,7 @@ RSpec.describe SubscriptionsHelper do
let_it_be(:group) { create(:group, name: 'My Namespace') } let_it_be(:group) { create(:group, name: 'My Namespace') }
before do before do
allow(helper).to receive(:params).and_return(plan_id: 'bronze_id', namespace_id: group.id.to_s) allow(helper).to receive(:params).and_return(plan_id: 'bronze_id', namespace_id: group.id.to_s, source: 'some_source')
allow(helper).to receive(:current_user).and_return(user) allow(helper).to receive(:current_user).and_return(user)
group.add_owner(user) group.add_owner(user)
group.add_guest(user2) group.add_guest(user2)
...@@ -50,6 +50,7 @@ RSpec.describe SubscriptionsHelper do ...@@ -50,6 +50,7 @@ RSpec.describe SubscriptionsHelper do
it { is_expected.to include(available_plans: '[{"id":"bronze_id","code":"bronze","price_per_year":48.0,"name":"Bronze Plan"}]') } it { is_expected.to include(available_plans: '[{"id":"bronze_id","code":"bronze","price_per_year":48.0,"name":"Bronze Plan"}]') }
it { is_expected.to include(plan_id: 'bronze_id') } it { is_expected.to include(plan_id: 'bronze_id') }
it { is_expected.to include(namespace_id: group.id.to_s) } it { is_expected.to include(namespace_id: group.id.to_s) }
it { is_expected.to include(source: 'some_source') }
it { is_expected.to include(group_data: %Q{[{"id":#{group.id},"name":"My Namespace","users":2,"guests":1}]}) } it { is_expected.to include(group_data: %Q{[{"id":#{group.id},"name":"My Namespace","users":2,"guests":1}]}) }
describe 'new_user' do describe 'new_user' do
......
...@@ -25,7 +25,8 @@ RSpec.describe Subscriptions::CreateService do ...@@ -25,7 +25,8 @@ RSpec.describe Subscriptions::CreateService do
{ {
plan_id: 'Plan ID', plan_id: 'Plan ID',
payment_method_id: 'Payment method ID', payment_method_id: 'Payment method ID',
quantity: 123 quantity: 123,
source: 'some_source'
} }
end end
......
...@@ -5,7 +5,8 @@ RSpec.shared_examples_for 'subscription form data' do |js_selector| ...@@ -5,7 +5,8 @@ RSpec.shared_examples_for 'subscription form data' do |js_selector|
setup_for_company: 'true', setup_for_company: 'true',
full_name: 'First Last', full_name: 'First Last',
plan_data: '[{"id":"bronze_id","code":"bronze","price_per_year":48.0}]', plan_data: '[{"id":"bronze_id","code":"bronze","price_per_year":48.0}]',
plan_id: 'bronze_id' plan_id: 'bronze_id',
source: 'some_source'
) )
end end
...@@ -15,4 +16,5 @@ RSpec.shared_examples_for 'subscription form data' do |js_selector| ...@@ -15,4 +16,5 @@ RSpec.shared_examples_for 'subscription form data' do |js_selector|
it { is_expected.to have_selector("#{js_selector}[data-full-name='First Last']") } it { is_expected.to have_selector("#{js_selector}[data-full-name='First Last']") }
it { is_expected.to have_selector("#{js_selector}[data-plan-data='[{\"id\":\"bronze_id\",\"code\":\"bronze\",\"price_per_year\":48.0}]']") } it { is_expected.to have_selector("#{js_selector}[data-plan-data='[{\"id\":\"bronze_id\",\"code\":\"bronze\",\"price_per_year\":48.0}]']") }
it { is_expected.to have_selector("#{js_selector}[data-plan-id='bronze_id']") } it { is_expected.to have_selector("#{js_selector}[data-plan-id='bronze_id']") }
it { is_expected.to have_selector("#{js_selector}[data-source='some_source']") }
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