summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-04-27 00:10:25 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-04-27 00:10:25 +0000
commitbe5b24c0095930bc07c900fa25e6f2d93c6d5992 (patch)
tree3a3c505311e145411dd91b74e67db856bf738ee5 /spec
parent70cfa5e3e7e6765590a664165eac0ef00c3d05dc (diff)
downloadgitlab-ce-be5b24c0095930bc07c900fa25e6f2d93c6d5992.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/frontend/branches/components/__snapshots__/divergence_graph_spec.js.snap4
-rw-r--r--spec/frontend/branches/components/divergence_graph_spec.js12
-rw-r--r--spec/frontend/branches/divergence_graph_spec.js8
-rw-r--r--spec/helpers/groups_helper_spec.rb40
4 files changed, 43 insertions, 21 deletions
diff --git a/spec/frontend/branches/components/__snapshots__/divergence_graph_spec.js.snap b/spec/frontend/branches/components/__snapshots__/divergence_graph_spec.js.snap
index 261c406171e..2afca66b0c1 100644
--- a/spec/frontend/branches/components/__snapshots__/divergence_graph_spec.js.snap
+++ b/spec/frontend/branches/components/__snapshots__/divergence_graph_spec.js.snap
@@ -3,7 +3,7 @@
exports[`Branch divergence graph component renders ahead and behind count 1`] = `
<div
class="divergence-graph px-2 d-none d-md-block"
- title="10 commits behind master, 10 commits ahead"
+ title="10 commits behind main, 10 commits ahead"
>
<graph-bar-stub
count="10"
@@ -26,7 +26,7 @@ exports[`Branch divergence graph component renders ahead and behind count 1`] =
exports[`Branch divergence graph component renders distance count 1`] = `
<div
class="divergence-graph px-2 d-none d-md-block"
- title="More than 900 commits different with master"
+ title="More than 900 commits different with main"
>
<graph-bar-stub
count="900"
diff --git a/spec/frontend/branches/components/divergence_graph_spec.js b/spec/frontend/branches/components/divergence_graph_spec.js
index b54b2ceb233..3b565539f87 100644
--- a/spec/frontend/branches/components/divergence_graph_spec.js
+++ b/spec/frontend/branches/components/divergence_graph_spec.js
@@ -15,7 +15,7 @@ describe('Branch divergence graph component', () => {
it('renders ahead and behind count', () => {
factory({
- defaultBranch: 'master',
+ defaultBranch: 'main',
aheadCount: 10,
behindCount: 10,
maxCommits: 100,
@@ -27,18 +27,18 @@ describe('Branch divergence graph component', () => {
it('sets title for ahead and behind count', () => {
factory({
- defaultBranch: 'master',
+ defaultBranch: 'main',
aheadCount: 10,
behindCount: 10,
maxCommits: 100,
});
- expect(vm.attributes('title')).toBe('10 commits behind master, 10 commits ahead');
+ expect(vm.attributes('title')).toBe('10 commits behind main, 10 commits ahead');
});
it('renders distance count', () => {
factory({
- defaultBranch: 'master',
+ defaultBranch: 'main',
aheadCount: 0,
behindCount: 0,
distance: 900,
@@ -55,13 +55,13 @@ describe('Branch divergence graph component', () => {
${1100} | ${'999+'}
`('sets title for $distance as $titleText', ({ distance, titleText }) => {
factory({
- defaultBranch: 'master',
+ defaultBranch: 'main',
aheadCount: 0,
behindCount: 0,
distance,
maxCommits: 100,
});
- expect(vm.attributes('title')).toBe(`More than ${titleText} commits different with master`);
+ expect(vm.attributes('title')).toBe(`More than ${titleText} commits different with main`);
});
});
diff --git a/spec/frontend/branches/divergence_graph_spec.js b/spec/frontend/branches/divergence_graph_spec.js
index be97a1724d3..7c367f83add 100644
--- a/spec/frontend/branches/divergence_graph_spec.js
+++ b/spec/frontend/branches/divergence_graph_spec.js
@@ -9,14 +9,14 @@ describe('Divergence graph', () => {
mock = new MockAdapter(axios);
mock.onGet('/-/diverging_counts').reply(200, {
- master: { ahead: 1, behind: 1 },
+ main: { ahead: 1, behind: 1 },
'test/hello-world': { ahead: 1, behind: 1 },
});
jest.spyOn(axios, 'get');
document.body.innerHTML = `
- <div class="js-branch-item" data-name="master"><div class="js-branch-divergence-graph"></div></div>
+ <div class="js-branch-item" data-name="main"><div class="js-branch-divergence-graph"></div></div>
<div class="js-branch-item" data-name="test/hello-world"><div class="js-branch-divergence-graph"></div></div>
`;
});
@@ -28,7 +28,7 @@ describe('Divergence graph', () => {
it('calls axios get with list of branch names', () =>
init('/-/diverging_counts').then(() => {
expect(axios.get).toHaveBeenCalledWith('/-/diverging_counts', {
- params: { names: ['master', 'test/hello-world'] },
+ params: { names: ['main', 'test/hello-world'] },
});
}));
@@ -46,7 +46,7 @@ describe('Divergence graph', () => {
it('creates Vue components', () =>
init('/-/diverging_counts').then(() => {
- expect(document.querySelector('[data-name="master"]').innerHTML).not.toEqual('');
+ expect(document.querySelector('[data-name="main"]').innerHTML).not.toEqual('');
expect(document.querySelector('[data-name="test/hello-world"]').innerHTML).not.toEqual('');
}));
});
diff --git a/spec/helpers/groups_helper_spec.rb b/spec/helpers/groups_helper_spec.rb
index a698507cc4c..992be7258f3 100644
--- a/spec/helpers/groups_helper_spec.rb
+++ b/spec/helpers/groups_helper_spec.rb
@@ -420,13 +420,13 @@ RSpec.describe GroupsHelper do
describe '#show_invite_banner?' do
let_it_be(:current_user) { create(:user) }
let_it_be_with_refind(:group) { create(:group) }
+ let_it_be(:subgroup) { create(:group, parent: group) }
let_it_be(:users) { [current_user, create(:user)] }
- subject { helper.show_invite_banner?(group) }
-
before do
allow(helper).to receive(:current_user) { current_user }
allow(helper).to receive(:can?).with(current_user, :admin_group, group).and_return(can_admin_group)
+ allow(helper).to receive(:can?).with(current_user, :admin_group, subgroup).and_return(can_admin_group)
users.take(group_members_count).each { |user| group.add_guest(user) }
end
@@ -440,17 +440,39 @@ RSpec.describe GroupsHelper do
end
with_them do
- context 'when the group was just created' do
- before do
- flash[:notice] = "Group #{group.name} was successfully created"
+ context 'for a parent group' do
+ subject { helper.show_invite_banner?(group) }
+
+ context 'when the group was just created' do
+ before do
+ flash[:notice] = "Group #{group.name} was successfully created"
+ end
+
+ it { is_expected.to be_falsey }
end
- it { is_expected.to be_falsey }
+ context 'when no flash message' do
+ it 'returns the expected result' do
+ expect(subject).to eq(expected_result)
+ end
+ end
end
- context 'when no flash message' do
- it 'returns the expected result' do
- expect(subject).to eq(expected_result)
+ context 'for a subgroup' do
+ subject { helper.show_invite_banner?(subgroup) }
+
+ context 'when the subgroup was just created' do
+ before do
+ flash[:notice] = "Group #{subgroup.name} was successfully created"
+ end
+
+ it { is_expected.to be_falsey }
+ end
+
+ context 'when no flash message' do
+ it 'returns the expected result' do
+ expect(subject).to eq(expected_result)
+ end
end
end
end