2017-06-14 16:12:22 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-06-29 04:13:10 +00:00
|
|
|
describe 'projects/notes/_more_actions_dropdown' do
|
2017-06-14 16:12:22 +00:00
|
|
|
let(:author_user) { create(:user) }
|
|
|
|
let(:not_author_user) { create(:user) }
|
|
|
|
|
2017-08-02 19:55:11 +00:00
|
|
|
let(:project) { create(:project) }
|
2017-06-14 16:12:22 +00:00
|
|
|
let(:issue) { create(:issue, project: project) }
|
|
|
|
let!(:note) { create(:note_on_issue, author: author_user, noteable: issue, project: project) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
assign(:project, project)
|
|
|
|
end
|
|
|
|
|
2017-06-15 11:44:47 +00:00
|
|
|
it 'shows Report as abuse button if not editable and not current users comment' do
|
|
|
|
render 'projects/notes/more_actions_dropdown', current_user: not_author_user, note_editable: false, note: note
|
2017-06-14 16:12:22 +00:00
|
|
|
|
2017-06-15 11:44:47 +00:00
|
|
|
expect(rendered).to have_link('Report as abuse')
|
2017-06-14 16:12:22 +00:00
|
|
|
end
|
|
|
|
|
2017-06-15 11:44:47 +00:00
|
|
|
it 'does not show the More actions button if not editable and current users comment' do
|
|
|
|
render 'projects/notes/more_actions_dropdown', current_user: author_user, note_editable: false, note: note
|
2017-06-14 16:12:22 +00:00
|
|
|
|
2017-06-15 11:44:47 +00:00
|
|
|
expect(rendered).not_to have_selector('.dropdown.more-actions')
|
2017-06-14 16:12:22 +00:00
|
|
|
end
|
|
|
|
|
2017-07-18 05:09:04 +00:00
|
|
|
it 'shows Report as abuse and Delete buttons if editable and not current users comment' do
|
2017-06-15 11:44:47 +00:00
|
|
|
render 'projects/notes/more_actions_dropdown', current_user: not_author_user, note_editable: true, note: note
|
2017-06-14 16:12:22 +00:00
|
|
|
|
2017-06-15 11:44:47 +00:00
|
|
|
expect(rendered).to have_link('Report as abuse')
|
|
|
|
expect(rendered).to have_link('Delete comment')
|
2017-06-14 16:12:22 +00:00
|
|
|
end
|
|
|
|
|
2017-07-18 05:09:04 +00:00
|
|
|
it 'shows Delete button if editable and current users comment' do
|
2017-06-15 11:44:47 +00:00
|
|
|
render 'projects/notes/more_actions_dropdown', current_user: author_user, note_editable: true, note: note
|
2017-06-14 16:12:22 +00:00
|
|
|
|
2017-06-15 11:44:47 +00:00
|
|
|
expect(rendered).to have_link('Delete comment')
|
2017-06-14 16:12:22 +00:00
|
|
|
end
|
|
|
|
end
|