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) => ({
plan_id: state.selectedPlan,
payment_method_id: state.paymentMethodId,
quantity: state.numberOfUsers,
source: state.source,
},
});
......
......@@ -45,6 +45,7 @@ export default ({
fullName,
newUser,
groupData = '[]',
source,
}) => {
const availablePlans = parsePlanData(plansData);
const isNewUser = parseBoolean(newUser);
......@@ -76,5 +77,6 @@ export default ({
isConfirmingOrder: false,
taxRate: TAX_RATE,
startDate: new Date(Date.now()),
source,
};
};
......@@ -79,7 +79,7 @@ class SubscriptionsController < ApplicationController
end
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
def find_group
......
......@@ -11,7 +11,8 @@ module SubscriptionsHelper
plan_id: params[:plan_id],
namespace_id: params[:namespace_id],
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
......
......@@ -84,7 +84,8 @@ module Subscriptions
},
gl_namespace_id: @group.id,
gl_namespace_name: @group.name,
preview: 'false'
preview: 'false',
source: subscription_params[:source]
}
end
......
......@@ -177,7 +177,7 @@ RSpec.describe SubscriptionsController do
{
setup_for_company: setup_for_company,
customer: { company: 'My company', country: 'NL' },
subscription: { plan_id: 'x', quantity: 2 }
subscription: { plan_id: 'x', quantity: 2, source: 'some_source' }
}
end
......@@ -215,7 +215,7 @@ RSpec.describe SubscriptionsController do
{
setup_for_company: setup_for_company,
customer: { country: 'NL' },
subscription: { plan_id: 'x', quantity: 1 }
subscription: { plan_id: 'x', quantity: 1, source: 'some_source' }
}
end
......@@ -282,7 +282,7 @@ RSpec.describe SubscriptionsController do
{
selected_group: selected_group.id,
customer: { country: 'NL' },
subscription: { plan_id: 'x', quantity: 1 }
subscription: { plan_id: 'x', quantity: 1, source: 'another_source' }
}
end
......@@ -357,7 +357,7 @@ RSpec.describe SubscriptionsController do
{
selected_group: non_existing_record_id,
customer: { country: 'NL' },
subscription: { plan_id: 'x', quantity: 1 }
subscription: { plan_id: 'x', quantity: 1, source: 'new_source' }
}
end
......
......@@ -30,6 +30,7 @@
},
"gl_namespace_id": 222,
"gl_namespace_name": "Group name",
"preview": "false"
"preview": "false",
"source": "some_source"
}
}
......@@ -20,6 +20,7 @@ const state = {
organizationName: 'Organization name',
paymentMethodId: 'Payment method ID',
numberOfUsers: 1,
source: 'some_source',
};
describe('Subscriptions Getters', () => {
......@@ -245,6 +246,7 @@ describe('Subscriptions Getters', () => {
plan_id: 'firstPlan',
payment_method_id: 'Payment method ID',
quantity: 1,
source: 'some_source',
},
});
});
......
......@@ -22,6 +22,7 @@ describe('projectsSelector default state', () => {
setupForCompany: 'true',
fullName: 'Full Name',
newUser: 'true',
source: 'some_source',
};
const currentDate = new Date('2020-01-07T12:44:08.135Z');
......@@ -164,6 +165,10 @@ describe('projectsSelector default state', () => {
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', () => {
expect(state.paymentFormParams).toEqual({});
});
......
......@@ -37,7 +37,7 @@ RSpec.describe SubscriptionsHelper do
let_it_be(:group) { create(:group, name: 'My Namespace') }
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)
group.add_owner(user)
group.add_guest(user2)
......@@ -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(plan_id: 'bronze_id') }
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}]}) }
describe 'new_user' do
......
......@@ -25,7 +25,8 @@ RSpec.describe Subscriptions::CreateService do
{
plan_id: 'Plan ID',
payment_method_id: 'Payment method ID',
quantity: 123
quantity: 123,
source: 'some_source'
}
end
......
......@@ -5,7 +5,8 @@ RSpec.shared_examples_for 'subscription form data' do |js_selector|
setup_for_company: 'true',
full_name: 'First Last',
plan_data: '[{"id":"bronze_id","code":"bronze","price_per_year":48.0}]',
plan_id: 'bronze_id'
plan_id: 'bronze_id',
source: 'some_source'
)
end
......@@ -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-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-source='some_source']") }
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