Commit cd515461 authored by Alex Buijs's avatar Alex Buijs

Apply license to selected group

When a group is selected when a subscription
is bought, apply the license to it.
parent 38ee9c7b
......@@ -8,7 +8,8 @@ module SubscriptionsHelper
setup_for_company: (current_user.setup_for_company == true).to_s,
full_name: current_user.name,
plan_data: plan_data.to_json,
plan_id: params[:plan_id]
plan_id: params[:plan_id],
new_user: new_user?.to_s
}
end
......@@ -21,6 +22,12 @@ module SubscriptionsHelper
private
def new_user?
return false unless request.referer.present?
URI.parse(request.referer).path.in?([users_sign_up_welcome_path, users_sign_up_update_registration_path])
end
def plan_data
FetchSubscriptionPlansService.new(plan: :free).execute
.map(&:symbolize_keys)
......
......@@ -3,6 +3,8 @@
require 'spec_helper'
describe SubscriptionsHelper do
using RSpec::Parameterized::TableSyntax
let_it_be(:raw_plan_data) do
[
{
......@@ -37,6 +39,23 @@ describe SubscriptionsHelper do
it { is_expected.to include(full_name: 'First Last') }
it { is_expected.to include(plan_data: '[{"id":"bronze_id","code":"bronze","price_per_year":48.0}]') }
it { is_expected.to include(plan_id: 'bronze_id') }
describe 'new_user' do
where(:referer, :expected_result) do
'http://example.com/users/sign_up/welcome?foo=bar' | 'true'
'http://example.com/users/sign_up/update_registration?foo=bar' | 'true'
'http://example.com' | 'false'
nil | 'false'
end
with_them do
before do
allow(helper).to receive(:request).and_return(double(referer: referer))
end
it { is_expected.to include(new_user: expected_result) }
end
end
end
describe '#plan_title' do
......
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