diff options
author | Luke "Jared" Bennett <lbennett@gitlab.com> | 2017-06-15 12:44:47 +0100 |
---|---|---|
committer | Luke "Jared" Bennett <lbennett@gitlab.com> | 2017-06-16 09:14:21 +0100 |
commit | 0bfe78d71628af28d3d7d8f743afcf6ed2447a9a (patch) | |
tree | db979b830c31cf28e0313f249c519941fc4b27b7 /spec/views | |
parent | 2ef19a24a6dcba2bc3b3d5d66658d27b4ef10e43 (diff) | |
download | gitlab-ce-0bfe78d71628af28d3d7d8f743afcf6ed2447a9a.tar.gz |
Pass more_actions_dropdown vie spec locals to render call instead of stubbing them
Diffstat (limited to 'spec/views')
-rw-r--r-- | spec/views/projects/notes/_more_actions_dropdown.html.haml_spec.rb | 59 |
1 files changed, 15 insertions, 44 deletions
diff --git a/spec/views/projects/notes/_more_actions_dropdown.html.haml_spec.rb b/spec/views/projects/notes/_more_actions_dropdown.html.haml_spec.rb index 7a17cf58231..e56c0f6be03 100644 --- a/spec/views/projects/notes/_more_actions_dropdown.html.haml_spec.rb +++ b/spec/views/projects/notes/_more_actions_dropdown.html.haml_spec.rb @@ -9,62 +9,33 @@ describe 'projects/notes/_more_actions_dropdown', :view do let!(:note) { create(:note_on_issue, author: author_user, noteable: issue, project: project) } before do - allow(view).to receive(:note).and_return(note) assign(:project, project) end - context 'not editable and not current users comment' do - before do - allow(view).to receive(:note_editable).and_return(false) - allow(view).to receive(:current_user).and_return(not_author_user) + 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 - render - end - - it 'shows Report as abuse button' do - expect(rendered).to have_link('Report as abuse') - end + expect(rendered).to have_link('Report as abuse') end - context 'not editable and current users comment' do - before do - allow(view).to receive(:note_editable).and_return(false) - allow(view).to receive(:current_user).and_return(author_user) - - render - end + 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 - it 'does not show the More actions button' do - expect(rendered).not_to have_selector('.dropdown.more-actions') - end + expect(rendered).not_to have_selector('.dropdown.more-actions') end - context 'editable and not current users comment' do - before do - allow(view).to receive(:note_editable).and_return(true) - allow(view).to receive(:current_user).and_return(not_author_user) + it 'shows Report as abuse, Edit and Delete buttons if editable and not current users comment' do + render 'projects/notes/more_actions_dropdown', current_user: not_author_user, note_editable: true, note: note - render - end - - it 'shows Report as abuse, Edit and Delete buttons' do - expect(rendered).to have_link('Report as abuse') - expect(rendered).to have_button('Edit comment') - expect(rendered).to have_link('Delete comment') - end + expect(rendered).to have_link('Report as abuse') + expect(rendered).to have_button('Edit comment') + expect(rendered).to have_link('Delete comment') end - context 'editable and current users comment' do - before do - allow(view).to receive(:note_editable).and_return(true) - allow(view).to receive(:current_user).and_return(author_user) - - render - end + it 'shows Edit and Delete buttons if editable and current users comment' do + render 'projects/notes/more_actions_dropdown', current_user: author_user, note_editable: true, note: note - it 'shows Edit and Delete buttons' do - expect(rendered).to have_button('Edit comment') - expect(rendered).to have_link('Delete comment') - end + expect(rendered).to have_button('Edit comment') + expect(rendered).to have_link('Delete comment') end end |