summaryrefslogtreecommitdiff
path: root/spec/views
diff options
context:
space:
mode:
authorKatarzyna Kobierska <kkobierska@gmail.com>2016-08-09 15:43:15 +0200
committerKatarzyna Kobierska <kkobierska@gmail.com>2016-08-30 13:05:40 +0200
commit2e08f1156998e9cd40b5eba5762182b8cb006c57 (patch)
treefab43881da54416498b34b59b111be62369a0536 /spec/views
parentc9c2503c5186a38302ed606f793b52ffa394f52c (diff)
downloadgitlab-ce-2e08f1156998e9cd40b5eba5762182b8cb006c57.tar.gz
Improve code
Diffstat (limited to 'spec/views')
-rw-r--r--spec/views/projects/merge_requests/edit.html.haml_spec.rb30
-rw-r--r--spec/views/projects/merge_requests/show.html.haml_spec.rb13
2 files changed, 28 insertions, 15 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
index d7a1a2447ea..6fd108c5bae 100644
--- a/spec/views/projects/merge_requests/edit.html.haml_spec.rb
+++ b/spec/views/projects/merge_requests/edit.html.haml_spec.rb
@@ -6,36 +6,48 @@ describe 'projects/merge_requests/edit.html.haml' do
let(:user) { create(:user) }
let(:project) { create(:project) }
let(:fork_project) { create(:project, forked_from_project: project) }
+ let(:unlink_project) { Projects::UnlinkForkService.new(fork_project, user) }
+
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))
+ allow(view).to receive(:current_user)
+ .and_return(User.find(closed_merge_request.author_id))
end
- context 'when closed MR without fork' do
+ context 'when closed merge request 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_field('merge_request[description]')
+ expect(rendered).to have_selector('#merge_request_assignee_id', visible: false)
+ expect(rendered).to have_selector('#merge_request_milestone_id', visible: false)
+ expect(rendered).not_to have_selector('#merge_request_target_branch', visible: false)
+ end
+ end
+
+ context 'when closed merge request with fork' do
+ it "shows editable fields" do
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")
+ expect(rendered).to have_selector('#merge_request_assignee_id', visible: false)
+ expect(rendered).to have_selector('#merge_request_milestone_id', visible: false)
+ expect(rendered).to have_selector('#merge_request_target_branch', visible: false)
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
index ed12b730eeb..923c3553814 100644
--- a/spec/views/projects/merge_requests/show.html.haml_spec.rb
+++ b/spec/views/projects/merge_requests/show.html.haml_spec.rb
@@ -5,23 +5,24 @@ describe 'projects/merge_requests/show.html.haml' do
let(:project) { create(:project) }
let(:fork_project) { create(:project, forked_from_project: project) }
- let(:merge_request) do
- create(:merge_request,
+
+ let(:closed_merge_request) do
+ create(:closed_merge_request,
source_project: fork_project,
source_branch: 'add-submodule-version-bump',
- target_branch: 'master', target_project: project)
+ target_branch: 'master',
+ target_project: project)
end
before do
assign(:project, project)
- assign(:merge_request, merge_request)
+ assign(:merge_request, closed_merge_request)
assign(:commits_count, 0)
- merge_request.close!
allow(view).to receive(:can?).and_return(true)
end
- context 'closed MR' do
+ context 'when merge request is closed' do
it 'shows Reopen button' do
render