debian-mirror-gitlab/spec/presenters/issue_presenter_spec.rb

60 lines
1.5 KiB
Ruby
Raw Normal View History

2019-09-04 21:01:54 +05:30
# frozen_string_literal: true
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe IssuePresenter do
2019-09-04 21:01:54 +05:30
include Gitlab::Routing.url_helpers
let(:user) { create(:user) }
let(:group) { create(:group) }
let(:project) { create(:project, group: group) }
let(:issue) { create(:issue, project: project) }
let(:presenter) { described_class.new(issue, current_user: user) }
before do
group.add_developer(user)
end
describe '#web_url' do
it 'returns correct path' do
2020-04-08 14:13:33 +05:30
expect(presenter.web_url).to eq("http://localhost/#{group.name}/#{project.name}/-/issues/#{issue.iid}")
2019-12-21 20:55:43 +05:30
end
end
describe '#subscribed?' do
subject { presenter.subscribed? }
it 'returns not subscribed' do
is_expected.to be(false)
end
it 'returns subscribed' do
create(:subscription, user: user, project: project, subscribable: issue, subscribed: true)
is_expected.to be(true)
2019-09-04 21:01:54 +05:30
end
end
describe '#issue_path' do
it 'returns correct path' do
2020-04-08 14:13:33 +05:30
expect(presenter.issue_path).to eq("/#{group.name}/#{project.name}/-/issues/#{issue.iid}")
2019-09-04 21:01:54 +05:30
end
end
2021-01-29 00:20:46 +05:30
describe '#project_emails_disabled?' do
subject { presenter.project_emails_disabled? }
it 'returns false when emails notifications is enabled for project' do
is_expected.to be(false)
end
context 'when emails notifications is disabled for project' do
before do
allow(project).to receive(:emails_disabled?).and_return(true)
end
it { is_expected.to be(true) }
end
end
2019-09-04 21:01:54 +05:30
end