Commit 7b82ad19 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch 'clarify-billable-members-count-specs' into 'master'

Clarify Specs for Namespace#billable_members_count

See merge request gitlab-org/gitlab!76695
parents a7ab264e 4b5dbf33
...@@ -1170,16 +1170,16 @@ RSpec.describe Namespace do ...@@ -1170,16 +1170,16 @@ RSpec.describe Namespace do
group.add_guest(create(:user)) group.add_guest(create(:user))
end end
context 'with a ultimate plan' do context 'with an ultimate plan' do
before do before do
create(:gitlab_subscription, namespace: group, hosted_plan: ultimate_plan) create(:gitlab_subscription, namespace: group, hosted_plan: ultimate_plan)
end end
it 'does not count guest users and counts only active users' do it 'counts only active users with an access level higher than guest' do
expect(group.billable_members_count).to eq(1) expect(group.billable_members_count).to eq(1)
end end
context 'when group has a project and users invited to it' do context 'when group has a project with invited users' do
let(:project) { create(:project, namespace: group) } let(:project) { create(:project, namespace: group) }
before do before do
...@@ -1189,17 +1189,19 @@ RSpec.describe Namespace do ...@@ -1189,17 +1189,19 @@ RSpec.describe Namespace do
project.add_developer(create(:user, :blocked)) project.add_developer(create(:user, :blocked))
end end
it 'includes invited active users except guests to the group' do it 'includes invited active users except guests' do
expect(group.billable_members_count).to eq(2) expect(group.billable_members_count).to eq(2)
end end
context 'with project bot users' do context 'with project bot users' do
include_context 'project bot users' include_context 'project bot users'
it { expect(group.billable_members_count).to eq(2) } it 'does not include project bot users in the count' do
expect(group.billable_members_count).to eq(2)
end
end end
context 'when group is invited to the project' do context 'when another group is invited to the project' do
let(:invited_group) { create(:group) } let(:invited_group) { create(:group) }
before do before do
...@@ -1210,25 +1212,25 @@ RSpec.describe Namespace do ...@@ -1210,25 +1212,25 @@ RSpec.describe Namespace do
create(:project_group_link, project: project, group: invited_group) create(:project_group_link, project: project, group: invited_group)
end end
it 'counts the only active users except guests of the invited groups' do it 'includes active users in the invited group with an access level higher than guest' do
expect(group.billable_members_count).to eq(3) expect(group.billable_members_count).to eq(3)
end end
end end
end end
context 'when group has been shared with another group' do context 'when group has been shared with another group' do
let(:shared_group) { create(:group) } let(:other_group) { create(:group) }
before do before do
shared_group.add_developer(create(:user)) other_group.add_developer(create(:user))
shared_group.add_guest(create(:user)) other_group.add_guest(create(:user))
shared_group.add_developer(create(:user, :blocked)) other_group.add_developer(create(:user, :blocked))
create(:group_group_link, { shared_with_group: shared_group, create(:group_group_link, { shared_with_group: other_group,
shared_group: group }) shared_group: group })
end end
it 'includes active users from the shared group to the billed members count' do it 'includes active users from the other group in the billed members count' do
expect(group.billable_members_count).to eq(2) expect(group.billable_members_count).to eq(2)
end end
end end
...@@ -1259,10 +1261,12 @@ RSpec.describe Namespace do ...@@ -1259,10 +1261,12 @@ RSpec.describe Namespace do
context 'with project bot users' do context 'with project bot users' do
include_context 'project bot users' include_context 'project bot users'
it { expect(group.billable_members_count).to eq(4) } it 'does not include project bot users in the count' do
expect(group.billable_members_count).to eq(4)
end
end end
context 'when group is invited to the project' do context 'when another group is invited to the project' do
let(:invited_group) { create(:group) } let(:invited_group) { create(:group) }
before do before do
...@@ -1280,19 +1284,19 @@ RSpec.describe Namespace do ...@@ -1280,19 +1284,19 @@ RSpec.describe Namespace do
end end
context 'when group has been shared with another group' do context 'when group has been shared with another group' do
let(:shared_group) { create(:group) } let(:other_group) { create(:group) }
before do before do
create(:gitlab_subscription, namespace: group, hosted_plan: send(plan)) create(:gitlab_subscription, namespace: group, hosted_plan: send(plan))
shared_group.add_developer(create(:user)) other_group.add_developer(create(:user))
shared_group.add_guest(create(:user)) other_group.add_guest(create(:user))
shared_group.add_developer(create(:user, :blocked)) other_group.add_developer(create(:user, :blocked))
create(:group_group_link, { shared_with_group: shared_group, create(:group_group_link, { shared_with_group: other_group,
shared_group: group }) shared_group: group })
end end
it 'includes active users from the shared group including guests to the billed members count' do it 'includes active users from the other group including guests in the billed members count' do
expect(group.billable_members_count).to eq(4) expect(group.billable_members_count).to eq(4)
end end
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