Commit 21d9701f authored by Winnie Hellmann's avatar Winnie Hellmann Committed by Bob Van Landuyt

Join IssuablesHelper specs

parent 47f3c6a9
...@@ -3,19 +3,20 @@ ...@@ -3,19 +3,20 @@
require 'spec_helper' require 'spec_helper'
describe IssuablesHelper do describe IssuablesHelper do
let_it_be(:user) { create(:user) }
describe '#issuable_initial_data' do describe '#issuable_initial_data' do
before do before do
allow(helper).to receive(:current_user).and_return(user)
allow(helper).to receive(:can?).and_return(true)
stub_commonmark_sourcepos_disabled stub_commonmark_sourcepos_disabled
end end
it 'returns the correct data for an epic' do context 'for an epic' do
user = create(:user) it 'returns the correct data' do
epic = create(:epic, author: user, description: 'epic text') epic = create(:epic, author: user, description: 'epic text')
@group = epic.group @group = epic.group
allow(helper).to receive(:current_user).and_return(user)
allow(helper).to receive(:can?).and_return(true)
expected_data = { expected_data = {
endpoint: "/groups/#{@group.full_path}/-/epics/#{epic.iid}", endpoint: "/groups/#{@group.full_path}/-/epics/#{epic.iid}",
epicLinksEndpoint: "/groups/#{@group.full_path}/-/epics/#{epic.iid}/links", epicLinksEndpoint: "/groups/#{@group.full_path}/-/epics/#{epic.iid}/links",
...@@ -41,4 +42,14 @@ describe IssuablesHelper do ...@@ -41,4 +42,14 @@ describe IssuablesHelper do
expect(helper.issuable_initial_data(epic)).to eq(expected_data) expect(helper.issuable_initial_data(epic)).to eq(expected_data)
end end
end end
context 'for an issue' do
it 'returns the correct data that includes canAdmin: true' do
issue = create(:issue, author: user, description: 'issue text')
@project = issue.project
expect(helper.issuable_initial_data(issue)).to include(canAdmin: true)
end
end
end
end end
# frozen_string_literal: true
require 'spec_helper'
describe IssuablesHelper do
describe '#issuable_initial_data' do
let(:user) { create(:user) }
before do
allow(helper).to receive(:current_user).and_return(user)
allow(helper).to receive(:can?).and_return(true)
stub_commonmark_sourcepos_disabled
end
it 'returns the correct data that includes canAdmin: true' do
issue = create(:issue, author: user, description: 'issue text')
@project = issue.project
expect(helper.issuable_initial_data(issue)).to include(canAdmin: true)
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment