2019-09-30 08:06:01 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-04-27 06:41:26 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 05:08:32 -04:00
|
|
|
RSpec.describe AwardEmojiHelper do
|
2017-04-27 06:41:26 -04:00
|
|
|
describe '.toggle_award_url' do
|
2019-11-28 10:06:57 -05:00
|
|
|
subject { helper.toggle_award_url(awardable) }
|
|
|
|
|
2017-04-27 06:41:26 -04:00
|
|
|
context 'note on personal snippet' do
|
2019-11-28 10:06:57 -05:00
|
|
|
let(:snippet) { create(:personal_snippet) }
|
|
|
|
let(:note) { create(:note_on_personal_snippet, noteable: snippet) }
|
|
|
|
let(:awardable) { note }
|
|
|
|
|
|
|
|
subject { helper.toggle_award_url(note) }
|
2017-04-27 06:41:26 -04:00
|
|
|
|
|
|
|
it 'returns correct url' do
|
2020-07-23 11:09:28 -04:00
|
|
|
expected_url = "/-/snippets/#{note.noteable.id}/notes/#{note.id}/toggle_award_emoji"
|
2017-04-27 06:41:26 -04:00
|
|
|
|
2019-11-28 10:06:57 -05:00
|
|
|
expect(subject).to eq(expected_url)
|
2017-04-27 06:41:26 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'note on project item' do
|
|
|
|
let(:note) { create(:note_on_project_snippet) }
|
2019-11-28 10:06:57 -05:00
|
|
|
let(:awardable) { note }
|
2017-04-27 06:41:26 -04:00
|
|
|
|
|
|
|
it 'returns correct url' do
|
|
|
|
@project = note.noteable.project
|
|
|
|
|
|
|
|
expected_url = "/#{@project.namespace.path}/#{@project.path}/notes/#{note.id}/toggle_award_emoji"
|
|
|
|
|
2019-11-28 10:06:57 -05:00
|
|
|
expect(subject).to eq(expected_url)
|
2017-04-27 06:41:26 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'personal snippet' do
|
|
|
|
let(:snippet) { create(:personal_snippet) }
|
2019-11-28 10:06:57 -05:00
|
|
|
let(:awardable) { snippet }
|
2017-04-27 06:41:26 -04:00
|
|
|
|
|
|
|
it 'returns correct url' do
|
2020-07-23 11:09:28 -04:00
|
|
|
expected_url = "/-/snippets/#{snippet.id}/toggle_award_emoji"
|
2017-04-27 06:41:26 -04:00
|
|
|
|
2019-11-28 10:06:57 -05:00
|
|
|
expect(subject).to eq(expected_url)
|
2017-04-27 06:41:26 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'merge request' do
|
|
|
|
let(:merge_request) { create(:merge_request) }
|
2019-11-28 10:06:57 -05:00
|
|
|
let(:awardable) { merge_request }
|
2017-04-27 06:41:26 -04:00
|
|
|
|
|
|
|
it 'returns correct url' do
|
|
|
|
@project = merge_request.project
|
|
|
|
|
2020-01-20 19:08:46 -05:00
|
|
|
expected_url = "/#{@project.namespace.path}/#{@project.path}/-/merge_requests/#{merge_request.iid}/toggle_award_emoji"
|
2017-04-27 06:41:26 -04:00
|
|
|
|
2019-11-28 10:06:57 -05:00
|
|
|
expect(subject).to eq(expected_url)
|
2017-04-27 06:41:26 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'issue' do
|
|
|
|
let(:issue) { create(:issue) }
|
2019-11-28 10:06:57 -05:00
|
|
|
let(:awardable) { issue }
|
2017-04-27 06:41:26 -04:00
|
|
|
|
|
|
|
it 'returns correct url' do
|
|
|
|
@project = issue.project
|
|
|
|
|
2020-03-02 10:08:01 -05:00
|
|
|
expected_url = "/#{@project.namespace.path}/#{@project.path}/-/issues/#{issue.iid}/toggle_award_emoji"
|
2017-04-27 06:41:26 -04:00
|
|
|
|
2019-11-28 10:06:57 -05:00
|
|
|
expect(subject).to eq(expected_url)
|
2017-04-27 06:41:26 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|