debian-mirror-gitlab/spec/helpers/award_emoji_helper_spec.rb

74 lines
2 KiB
Ruby
Raw Normal View History

2019-12-21 20:55:43 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe AwardEmojiHelper do
2017-08-17 22:00:37 +05:30
describe '.toggle_award_url' do
2020-01-01 13:55:28 +05:30
subject { helper.toggle_award_url(awardable) }
2017-08-17 22:00:37 +05:30
context 'note on personal snippet' do
2020-01-01 13:55:28 +05:30
let(:snippet) { create(:personal_snippet) }
let(:note) { create(:note_on_personal_snippet, noteable: snippet) }
let(:awardable) { note }
subject { helper.toggle_award_url(note) }
2017-08-17 22:00:37 +05:30
it 'returns correct url' do
2020-10-24 23:57:45 +05:30
expected_url = "/-/snippets/#{note.noteable.id}/notes/#{note.id}/toggle_award_emoji"
2017-08-17 22:00:37 +05:30
2020-01-01 13:55:28 +05:30
expect(subject).to eq(expected_url)
2017-08-17 22:00:37 +05:30
end
end
context 'note on project item' do
let(:note) { create(:note_on_project_snippet) }
2020-01-01 13:55:28 +05:30
let(:awardable) { note }
2017-08-17 22:00:37 +05:30
it 'returns correct url' do
@project = note.noteable.project
expected_url = "/#{@project.namespace.path}/#{@project.path}/notes/#{note.id}/toggle_award_emoji"
2020-01-01 13:55:28 +05:30
expect(subject).to eq(expected_url)
2017-08-17 22:00:37 +05:30
end
end
context 'personal snippet' do
let(:snippet) { create(:personal_snippet) }
2020-01-01 13:55:28 +05:30
let(:awardable) { snippet }
2017-08-17 22:00:37 +05:30
it 'returns correct url' do
2020-10-24 23:57:45 +05:30
expected_url = "/-/snippets/#{snippet.id}/toggle_award_emoji"
2017-08-17 22:00:37 +05:30
2020-01-01 13:55:28 +05:30
expect(subject).to eq(expected_url)
2017-08-17 22:00:37 +05:30
end
end
context 'merge request' do
let(:merge_request) { create(:merge_request) }
2020-01-01 13:55:28 +05:30
let(:awardable) { merge_request }
2017-08-17 22:00:37 +05:30
it 'returns correct url' do
@project = merge_request.project
2020-03-13 15:44:24 +05:30
expected_url = "/#{@project.namespace.path}/#{@project.path}/-/merge_requests/#{merge_request.iid}/toggle_award_emoji"
2017-08-17 22:00:37 +05:30
2020-01-01 13:55:28 +05:30
expect(subject).to eq(expected_url)
2017-08-17 22:00:37 +05:30
end
end
context 'issue' do
let(:issue) { create(:issue) }
2020-01-01 13:55:28 +05:30
let(:awardable) { issue }
2017-08-17 22:00:37 +05:30
it 'returns correct url' do
@project = issue.project
2020-04-08 14:13:33 +05:30
expected_url = "/#{@project.namespace.path}/#{@project.path}/-/issues/#{issue.iid}/toggle_award_emoji"
2017-08-17 22:00:37 +05:30
2020-01-01 13:55:28 +05:30
expect(subject).to eq(expected_url)
2017-08-17 22:00:37 +05:30
end
end
end
end