diff options
author | Katarzyna Kobierska <kkobierska@gmail.com> | 2016-07-26 14:57:43 +0300 |
---|---|---|
committer | Katarzyna Kobierska <kkobierska@gmail.com> | 2016-08-30 14:05:40 +0300 |
commit | c9c2503c5186a38302ed606f793b52ffa394f52c (patch) | |
tree | f03f46d41d71dcaf71bc867fa4ec949f8dc5931e /spec/views | |
parent | 2778dec131c2afac9fcdb2c42365b69099a5ae5b (diff) |
User can edit closed MR with deleted fork
Add test for closed MR without fork
Add view test visibility of Reopen and Close buttons
Fix controller tests and validation method
Fix missing space
Remove unused variables from test
closed_without_fork? method refactoring
Add information about missing fork
When closed MR without fork can't edit target branch
Tests for closed MR edit view
Fix indentation and rebase, refactoring
Diffstat (limited to 'spec/views')
-rw-r--r-- | spec/views/projects/merge_requests/edit.html.haml_spec.rb | 41 | ||||
-rw-r--r-- | spec/views/projects/merge_requests/show.html.haml_spec.rb | 40 |
2 files changed, 81 insertions, 0 deletions
diff --git a/spec/views/projects/merge_requests/edit.html.haml_spec.rb b/spec/views/projects/merge_requests/edit.html.haml_spec.rb new file mode 100644 index 00000000000..d7a1a2447ea --- /dev/null +++ b/spec/views/projects/merge_requests/edit.html.haml_spec.rb @@ -0,0 +1,41 @@ +require 'spec_helper' + +describe 'projects/merge_requests/edit.html.haml' do + include Devise::TestHelpers + + let(:user) { create(:user) } + let(:project) { create(:project) } + let(:fork_project) { create(:project, forked_from_project: project) } + let(:closed_merge_request) do + create(:closed_merge_request, + source_project: fork_project, + target_project: project, + author: user) + end + let(:unlink_project) { Projects::UnlinkForkService.new(fork_project, user) } + + before do + assign(:project, project) + assign(:merge_request, closed_merge_request) + + allow(view).to receive(:can?).and_return(true) + allow(view).to receive(:current_user).and_return(User.find(closed_merge_request.author_id)) + end + + context 'when closed MR without fork' do + it "shows editable fields" do + unlink_project.execute + closed_merge_request.reload + render + + expect(rendered).to have_field('merge_request[title]') + expect(rendered).to have_css('label', text: "Title") + expect(rendered).to have_field('merge_request[description]') + expect(rendered).to have_css('label', text: "Description") + expect(rendered).to have_css('label', text: "Assignee") + expect(rendered).to have_css('label', text: "Milestone") + expect(rendered).to have_css('label', text: "Labels") + expect(rendered).not_to have_css('label', text: "Target branch") + end + end +end diff --git a/spec/views/projects/merge_requests/show.html.haml_spec.rb b/spec/views/projects/merge_requests/show.html.haml_spec.rb new file mode 100644 index 00000000000..ed12b730eeb --- /dev/null +++ b/spec/views/projects/merge_requests/show.html.haml_spec.rb @@ -0,0 +1,40 @@ +require 'spec_helper' + +describe 'projects/merge_requests/show.html.haml' do + include Devise::TestHelpers + + let(:project) { create(:project) } + let(:fork_project) { create(:project, forked_from_project: project) } + let(:merge_request) do + create(:merge_request, + source_project: fork_project, + source_branch: 'add-submodule-version-bump', + target_branch: 'master', target_project: project) + end + + before do + assign(:project, project) + assign(:merge_request, merge_request) + assign(:commits_count, 0) + + merge_request.close! + allow(view).to receive(:can?).and_return(true) + end + + context 'closed MR' do + it 'shows Reopen button' do + render + + expect(rendered).to have_css('a', visible: true, text: 'Reopen') + expect(rendered).to have_css('a', visible: false, text: 'Close') + end + + it 'does not show Reopen button without fork' do + fork_project.destroy + render + + expect(rendered).to have_css('a', visible: false, text: 'Reopen') + expect(rendered).to have_css('a', visible: false, text: 'Close') + end + end +end |