summaryrefslogtreecommitdiff
path: root/spec/helpers/notes_helper_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/helpers/notes_helper_spec.rb')
-rw-r--r--spec/helpers/notes_helper_spec.rb42
1 files changed, 26 insertions, 16 deletions
diff --git a/spec/helpers/notes_helper_spec.rb b/spec/helpers/notes_helper_spec.rb
index 355a4845afb..9921ca1af33 100644
--- a/spec/helpers/notes_helper_spec.rb
+++ b/spec/helpers/notes_helper_spec.rb
@@ -5,7 +5,7 @@ describe NotesHelper do
let(:owner) { create(:owner) }
let(:group) { create(:group) }
- let(:project) { create(:empty_project, namespace: group) }
+ let(:project) { create(:project, namespace: group) }
let(:master) { create(:user) }
let(:reporter) { create(:user) }
let(:guest) { create(:user) }
@@ -30,7 +30,7 @@ describe NotesHelper do
end
it 'handles access in different projects' do
- second_project = create(:empty_project)
+ second_project = create(:project)
second_project.team << [master, :reporter]
other_note = create(:note, author: master, project: second_project)
@@ -40,7 +40,7 @@ describe NotesHelper do
end
describe '#discussion_path' do
- let(:project) { create(:project) }
+ let(:project) { create(:project, :repository) }
context 'for a merge request discusion' do
let(:merge_request) { create(:merge_request, source_project: project, target_project: project, importing: true) }
@@ -53,7 +53,7 @@ describe NotesHelper do
let(:discussion) { create(:diff_note_on_merge_request, noteable: merge_request, project: project).to_discussion }
it 'returns the diff path with the line code' do
- expect(helper.discussion_path(discussion)).to eq(diffs_namespace_project_merge_request_path(project.namespace, project, merge_request, anchor: discussion.line_code))
+ expect(helper.discussion_path(discussion)).to eq(diffs_project_merge_request_path(project, merge_request, anchor: discussion.line_code))
end
end
@@ -77,7 +77,7 @@ describe NotesHelper do
end
it 'returns the diff version path with the line code' do
- expect(helper.discussion_path(discussion)).to eq(diffs_namespace_project_merge_request_path(project.namespace, project, merge_request, diff_id: merge_request_diff1, anchor: discussion.line_code))
+ expect(helper.discussion_path(discussion)).to eq(diffs_project_merge_request_path(project, merge_request, diff_id: merge_request_diff1, anchor: discussion.line_code))
end
end
@@ -101,7 +101,7 @@ describe NotesHelper do
end
it 'returns the diff version comparison path with the line code' do
- expect(helper.discussion_path(discussion)).to eq(diffs_namespace_project_merge_request_path(project.namespace, project, merge_request, diff_id: merge_request_diff3, start_sha: merge_request_diff1.head_commit_sha, anchor: discussion.line_code))
+ expect(helper.discussion_path(discussion)).to eq(diffs_project_merge_request_path(project, merge_request, diff_id: merge_request_diff3, start_sha: merge_request_diff1.head_commit_sha, anchor: discussion.line_code))
end
end
@@ -129,7 +129,7 @@ describe NotesHelper do
end
it 'returns the diff path with the line code' do
- expect(helper.discussion_path(discussion)).to eq(diffs_namespace_project_merge_request_path(project.namespace, project, merge_request, anchor: discussion.line_code))
+ expect(helper.discussion_path(discussion)).to eq(diffs_project_merge_request_path(project, merge_request, anchor: discussion.line_code))
end
end
@@ -160,7 +160,7 @@ describe NotesHelper do
let(:discussion) { create(:diff_note_on_commit, project: project).to_discussion }
it 'returns the commit path with the line code' do
- expect(helper.discussion_path(discussion)).to eq(namespace_project_commit_path(project.namespace, project, commit, anchor: discussion.line_code))
+ expect(helper.discussion_path(discussion)).to eq(project_commit_path(project, commit, anchor: discussion.line_code))
end
end
@@ -168,7 +168,7 @@ describe NotesHelper do
let(:discussion) { create(:legacy_diff_note_on_commit, project: project).to_discussion }
it 'returns the commit path with the line code' do
- expect(helper.discussion_path(discussion)).to eq(namespace_project_commit_path(project.namespace, project, commit, anchor: discussion.line_code))
+ expect(helper.discussion_path(discussion)).to eq(project_commit_path(project, commit, anchor: discussion.line_code))
end
end
@@ -176,7 +176,7 @@ describe NotesHelper do
let(:discussion) { create(:discussion_note_on_commit, project: project).to_discussion }
it 'returns the commit path' do
- expect(helper.discussion_path(discussion)).to eq(namespace_project_commit_path(project.namespace, project, commit))
+ expect(helper.discussion_path(discussion)).to eq(project_commit_path(project, commit))
end
end
end
@@ -191,7 +191,7 @@ describe NotesHelper do
it 'return project notes path for project snippet' do
namespace = create(:namespace, path: 'nm')
- @project = create(:empty_project, path: 'test', namespace: namespace)
+ @project = create(:project, path: 'test', namespace: namespace)
@snippet = create(:project_snippet, project: @project)
@noteable = @snippet
@@ -200,7 +200,7 @@ describe NotesHelper do
it 'return project notes path for other noteables' do
namespace = create(:namespace, path: 'nm')
- @project = create(:empty_project, path: 'test', namespace: namespace)
+ @project = create(:project, path: 'test', namespace: namespace)
@noteable = create(:issue, project: @project)
expect(helper.notes_url).to eq("/nm/test/noteable/issue/#{@noteable.id}/notes")
@@ -216,7 +216,7 @@ describe NotesHelper do
it 'return project notes path for project snippet' do
namespace = create(:namespace, path: 'nm')
- @project = create(:empty_project, path: 'test', namespace: namespace)
+ @project = create(:project, path: 'test', namespace: namespace)
note = create(:note_on_project_snippet, project: @project)
expect(helper.note_url(note)).to eq("/nm/test/notes/#{note.id}")
@@ -224,7 +224,7 @@ describe NotesHelper do
it 'return project notes path for other noteables' do
namespace = create(:namespace, path: 'nm')
- @project = create(:empty_project, path: 'test', namespace: namespace)
+ @project = create(:project, path: 'test', namespace: namespace)
note = create(:note_on_issue, project: @project)
expect(helper.note_url(note)).to eq("/nm/test/notes/#{note.id}")
@@ -241,7 +241,7 @@ describe NotesHelper do
it 'returns namespace, project and note for project snippet' do
namespace = create(:namespace, path: 'nm')
- @project = create(:empty_project, path: 'test', namespace: namespace)
+ @project = create(:project, path: 'test', namespace: namespace)
@snippet = create(:project_snippet, project: @project)
@note = create(:note_on_personal_snippet)
@@ -250,10 +250,20 @@ describe NotesHelper do
it 'returns namespace, project and note path for other noteables' do
namespace = create(:namespace, path: 'nm')
- @project = create(:empty_project, path: 'test', namespace: namespace)
+ @project = create(:project, path: 'test', namespace: namespace)
@note = create(:note_on_issue, project: @project)
expect(helper.form_resources).to eq([@project.namespace, @project, @note])
end
end
+
+ describe '#noteable_note_url' do
+ let(:project) { create(:project) }
+ let(:issue) { create(:issue, project: project) }
+ let(:note) { create(:note_on_issue, noteable: issue, project: project) }
+
+ it 'returns the noteable url with an anchor to the note' do
+ expect(noteable_note_url(note)).to match("/#{project.namespace.path}/#{project.path}/issues/#{issue.iid}##{dom_id(note)}")
+ end
+ end
end