diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2017-01-30 10:25:36 +0000 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2017-01-30 10:25:36 +0000 |
commit | 7bd3ee3bfb9deb1d13af4f8e68e41c19b15c9dfa (patch) | |
tree | 5f86027a163781c65b2177bdfa90b3ec0d863fe2 /spec | |
parent | 84d959566a9c0656a98bdc0517f1f7dcb5944225 (diff) | |
parent | 80a7c369083246fe689959906cab493a518ff980 (diff) | |
download | gitlab-ce-7bd3ee3bfb9deb1d13af4f8e68e41c19b15c9dfa.tar.gz |
Merge branch '23634-remove-project-grouping' into 'master'
Don't group issue, merge request and TODO lists by project
Closes #23634
See merge request !8519
Diffstat (limited to 'spec')
-rw-r--r-- | spec/features/todos/todos_spec.rb | 2 | ||||
-rw-r--r-- | spec/helpers/issuables_helper_spec.rb | 40 | ||||
-rw-r--r-- | spec/models/issue_spec.rb | 65 | ||||
-rw-r--r-- | spec/models/project_spec.rb | 38 | ||||
-rw-r--r-- | spec/models/todo_spec.rb | 8 |
5 files changed, 139 insertions, 14 deletions
diff --git a/spec/features/todos/todos_spec.rb b/spec/features/todos/todos_spec.rb index 3850e930b6d..1b352be9331 100644 --- a/spec/features/todos/todos_spec.rb +++ b/spec/features/todos/todos_spec.rb @@ -171,7 +171,7 @@ describe 'Dashboard Todos', feature: true do it 'links to the pipelines for the merge request' do href = pipelines_namespace_project_merge_request_path(project.namespace, project, todo.target) - expect(page).to have_link "merge request #{todo.target.to_reference}", href + expect(page).to have_link "merge request #{todo.target.to_reference(full: true)}", href end end end diff --git a/spec/helpers/issuables_helper_spec.rb b/spec/helpers/issuables_helper_spec.rb index a4f08dc4af0..df71680e44c 100644 --- a/spec/helpers/issuables_helper_spec.rb +++ b/spec/helpers/issuables_helper_spec.rb @@ -115,6 +115,46 @@ describe IssuablesHelper do end end + describe '#issuable_reference' do + context 'when show_full_reference truthy' do + it 'display issuable full reference' do + assign(:show_full_reference, true) + issue = build_stubbed(:issue) + + expect(helper.issuable_reference(issue)).to eql(issue.to_reference(full: true)) + end + end + + context 'when show_full_reference falsey' do + context 'when @group present' do + it 'display issuable reference to @group' do + project = build_stubbed(:project) + + assign(:show_full_reference, nil) + assign(:group, project.namespace) + + issue = build_stubbed(:issue) + + expect(helper.issuable_reference(issue)).to eql(issue.to_reference(project.namespace)) + end + end + + context 'when @project present' do + it 'display issuable reference to @project' do + project = build_stubbed(:project) + + assign(:show_full_reference, nil) + assign(:group, nil) + assign(:project, project) + + issue = build_stubbed(:issue) + + expect(helper.issuable_reference(issue)).to eql(issue.to_reference(project)) + end + end + end + end + describe '#issuable_filter_present?' do it 'returns true when any key is present' do allow(helper).to receive(:params).and_return( diff --git a/spec/models/issue_spec.rb b/spec/models/issue_spec.rb index 40c0a75c364..bba9058f394 100644 --- a/spec/models/issue_spec.rb +++ b/spec/models/issue_spec.rb @@ -23,21 +23,74 @@ describe Issue, models: true do end describe '#to_reference' do - let(:project) { build(:empty_project, name: 'sample-project') } - let(:issue) { build(:issue, iid: 1, project: project) } + let(:namespace) { build(:namespace, path: 'sample-namespace') } + let(:project) { build(:empty_project, name: 'sample-project', namespace: namespace) } + let(:issue) { build(:issue, iid: 1, project: project) } + let(:group) { create(:group, name: 'Group', path: 'sample-group') } + + context 'when nil argument' do + it 'returns issue id' do + expect(issue.to_reference).to eq "#1" + end + end + + context 'when full is true' do + it 'returns complete path to the issue' do + expect(issue.to_reference(full: true)).to eq 'sample-namespace/sample-project#1' + expect(issue.to_reference(project, full: true)).to eq 'sample-namespace/sample-project#1' + expect(issue.to_reference(group, full: true)).to eq 'sample-namespace/sample-project#1' + end + end - it 'returns a String reference to the object' do - expect(issue.to_reference).to eq "#1" + context 'when same project argument' do + it 'returns issue id' do + expect(issue.to_reference(project)).to eq("#1") + end end - it 'returns a String reference with the full path' do - expect(issue.to_reference(full: true)).to eq(project.path_with_namespace + '#1') + context 'when cross namespace project argument' do + let(:another_namespace_project) { create(:empty_project, name: 'another-project') } + + it 'returns complete path to the issue' do + expect(issue.to_reference(another_namespace_project)).to eq 'sample-namespace/sample-project#1' + end end it 'supports a cross-project reference' do another_project = build(:empty_project, name: 'another-project', namespace: project.namespace) expect(issue.to_reference(another_project)).to eq "sample-project#1" end + + context 'when same namespace / cross-project argument' do + let(:another_project) { create(:empty_project, namespace: namespace) } + + it 'returns path to the issue with the project name' do + expect(issue.to_reference(another_project)).to eq 'sample-project#1' + end + end + + context 'when different namespace / cross-project argument' do + let(:another_namespace) { create(:namespace, path: 'another-namespace') } + let(:another_project) { create(:empty_project, path: 'another-project', namespace: another_namespace) } + + it 'returns full path to the issue' do + expect(issue.to_reference(another_project)).to eq 'sample-namespace/sample-project#1' + end + end + + context 'when argument is a namespace' do + context 'with same project path' do + it 'returns path to the issue with the project name' do + expect(issue.to_reference(namespace)).to eq 'sample-project#1' + end + end + + context 'with different project path' do + it 'returns full path to the issue' do + expect(issue.to_reference(group)).to eq 'sample-namespace/sample-project#1' + end + end + end end describe '#is_being_reassigned?' do diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 646a1311462..527eb704036 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -282,9 +282,10 @@ describe Project, models: true do end describe '#to_reference' do - let(:owner) { create(:user, name: 'Gitlab') } + let(:owner) { create(:user, name: 'Gitlab') } let(:namespace) { create(:namespace, path: 'sample-namespace', owner: owner) } - let(:project) { create(:empty_project, path: 'sample-project', namespace: namespace) } + let(:project) { create(:empty_project, path: 'sample-project', namespace: namespace) } + let(:group) { create(:group, name: 'Group', path: 'sample-group', owner: owner) } context 'when nil argument' do it 'returns nil' do @@ -292,6 +293,14 @@ describe Project, models: true do end end + context 'when full is true' do + it 'returns complete path to the project' do + expect(project.to_reference(full: true)).to eq 'sample-namespace/sample-project' + expect(project.to_reference(project, full: true)).to eq 'sample-namespace/sample-project' + expect(project.to_reference(group, full: true)).to eq 'sample-namespace/sample-project' + end + end + context 'when same project argument' do it 'returns nil' do expect(project.to_reference(project)).to be_nil @@ -309,10 +318,33 @@ describe Project, models: true do context 'when same namespace / cross-project argument' do let(:another_project) { create(:empty_project, namespace: namespace) } - it 'returns complete path to the project' do + it 'returns path to the project' do expect(project.to_reference(another_project)).to eq 'sample-project' end end + + context 'when different namespace / cross-project argument' do + let(:another_namespace) { create(:namespace, path: 'another-namespace', owner: owner) } + let(:another_project) { create(:empty_project, path: 'another-project', namespace: another_namespace) } + + it 'returns full path to the project' do + expect(project.to_reference(another_project)).to eq 'sample-namespace/sample-project' + end + end + + context 'when argument is a namespace' do + context 'with same project path' do + it 'returns path to the project' do + expect(project.to_reference(namespace)).to eq 'sample-project' + end + end + + context 'with different project path' do + it 'returns full path to the project' do + expect(project.to_reference(group)).to eq 'sample-namespace/sample-project' + end + end + end end describe '#to_human_reference' do diff --git a/spec/models/todo_spec.rb b/spec/models/todo_spec.rb index 8017d1c3324..581305ad39f 100644 --- a/spec/models/todo_spec.rb +++ b/spec/models/todo_spec.rb @@ -109,7 +109,7 @@ describe Todo, models: true do end describe '#target_reference' do - it 'returns the short commit id for commits' do + it 'returns commit full reference with short id' do project = create(:project, :repository) commit = project.commit @@ -117,12 +117,12 @@ describe Todo, models: true do subject.target_type = 'Commit' subject.commit_id = commit.id - expect(subject.target_reference).to eq commit.short_id + expect(subject.target_reference).to eq commit.reference_link_text(full: true) end - it 'returns reference for issuables' do + it 'returns full reference for issuables' do subject.target = issue - expect(subject.target_reference).to eq issue.to_reference + expect(subject.target_reference).to eq issue.to_reference(full: true) end end end |