Commit 3026f3d5 authored by Vladlena Shumilo's avatar Vladlena Shumilo

Removes the modifications to the user factory and additional tests

These changes increase the scope and are not directly related to
the changes. Will move those as a follow up
This commit is intended to be squashed
parent a6fa9670
...@@ -43,11 +43,8 @@ module EE ...@@ -43,11 +43,8 @@ module EE
end end
def upgrade_plan_path(group) def upgrade_plan_path(group)
if group.present? return profile_billings_path if group.blank?
group_billings_path(group) group_billings_path(group)
else
profile_billings_path
end
end end
def self.url_helper(route_name) def self.url_helper(route_name)
......
...@@ -65,40 +65,8 @@ describe LicenseHelper do ...@@ -65,40 +65,8 @@ describe LicenseHelper do
end end
describe '#guest_user_count' do describe '#guest_user_count' do
let!(:inactive_owner) { create(:user, :inactive, non_guest: true) } it 'returns the number of active guest users' do
let!(:inactive_guest) { create(:user, :inactive) } expect(guest_user_count).to eq(User.active.count - User.active.excluding_guests.count)
context 'when there are no active users' do
it 'returns 0' do
expect(guest_user_count).to eq(0)
end
end
context 'when there are active users and none is a guest user' do
let!(:owner1) { create(:user, non_guest: true) }
let!(:owner2) { create(:user, non_guest: true) }
it 'returns 0' do
expect(guest_user_count).to eq(0)
end
end
context 'when there are active users and some are guest users' do
let!(:owner) { create(:user, non_guest: true) }
let!(:guest) { create(:user) }
it 'returns the count of all active guest users' do
expect(guest_user_count).to eq(1)
end
end
context 'when there are active users and all are guest users' do
let!(:guest1) { create(:user) }
let!(:guest2) { create(:user) }
it 'returns the count of all active guest users' do
expect(guest_user_count).to eq(2)
end
end end
end end
...@@ -124,39 +92,40 @@ describe LicenseHelper do ...@@ -124,39 +92,40 @@ describe LicenseHelper do
end end
describe '#current_license' do describe '#current_license' do
let(:license) { create(:license) }
it 'returns the current license' do it 'returns the current license' do
expect(license).to eq(license) license = double
allow(License).to receive(:current).and_return(license)
expect(current_license).to eq(license)
end end
end end
describe '#current_license_title' do describe '#current_license_title' do
context 'when there is a current license' do context 'when there is a current license' do
let!(:license) { create(:license, more_attrs) } context 'and it has a plan associated to it' do
let(:more_attrs) { {} } it 'returns the plan titleized' do
custom_plan = 'custom plan'
context 'and it has a custom plan associated to it' do license = double('License', plan: custom_plan)
let(:more_attrs) { { plan: License::ULTIMATE_PLAN } } allow(License).to receive(:current).and_return(license)
it 'returns the plans title' do expect(current_license_title).to eq(custom_plan.titleize)
expect(current_license_title).to eq('Ultimate')
end end
end end
context 'and it has the default plan associated to it' do context 'and it does not have a plan associated to it' do
it 'returns the plans title' do it 'returns the default title' do
expect(current_license_title).to eq('Starter') license = double('License', plan: nil)
allow(License).to receive(:current).and_return(license)
expect(current_license_title).to eq('Core')
end end
end end
end end
context 'when there is NOT a current license' do context 'when there is NOT a current license' do
before do it 'returns the default title' do
allow(License).to receive(:current).and_return(nil) allow(License).to receive(:current).and_return(nil)
end
it 'returns default title' do
expect(current_license_title).to eq('Core') expect(current_license_title).to eq('Core')
end end
end end
......
...@@ -23,10 +23,6 @@ FactoryBot.define do ...@@ -23,10 +23,6 @@ FactoryBot.define do
after(:build) { |user, _| user.block! } after(:build) { |user, _| user.block! }
end end
trait :inactive do
state_event { :deactivate }
end
trait :bot do trait :bot do
user_type { :alert_bot } user_type { :alert_bot }
end end
...@@ -87,18 +83,12 @@ FactoryBot.define do ...@@ -87,18 +83,12 @@ FactoryBot.define do
transient do transient do
developer_projects { [] } developer_projects { [] }
non_guest { false }
end end
after(:create) do |user, evaluator| after(:create) do |user, evaluator|
evaluator.developer_projects.each do |project| evaluator.developer_projects.each do |project|
project.add_developer(user) project.add_developer(user)
end end
if evaluator.non_guest
# default access_level for a group_member is owner
create(:group_member, user: user)
end
end end
factory :omniauth_user do factory :omniauth_user 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