diff options
Diffstat (limited to 'spec/controllers/projects/commit_controller_spec.rb')
-rw-r--r-- | spec/controllers/projects/commit_controller_spec.rb | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/spec/controllers/projects/commit_controller_spec.rb b/spec/controllers/projects/commit_controller_spec.rb index df902da86f8..7e440193d7b 100644 --- a/spec/controllers/projects/commit_controller_spec.rb +++ b/spec/controllers/projects/commit_controller_spec.rb @@ -47,25 +47,25 @@ describe Projects::CommitController do end shared_examples "export as" do |format| - it "should generally work" do + it "does generally work" do go(id: commit.id, format: format) expect(response).to be_success end - it "should generate it" do + it "generates it" do expect_any_instance_of(Commit).to receive(:"to_#{format}") go(id: commit.id, format: format) end - it "should render it" do + it "renders it" do go(id: commit.id, format: format) expect(response.body).to eq(commit.send(:"to_#{format}")) end - it "should not escape Html" do + it "does not escape Html" do allow_any_instance_of(Commit).to receive(:"to_#{format}"). and_return('HTML entities &<>" ') @@ -83,17 +83,18 @@ describe Projects::CommitController do let(:format) { :diff } it "should really only be a git diff" do - go(id: commit.id, format: format) + go(id: '66eceea0db202bb39c4e445e8ca28689645366c5', format: format) expect(response.body).to start_with("diff --git") end - it "should really only be a git diff without whitespace changes" do + it "is only be a git diff without whitespace changes" do go(id: '66eceea0db202bb39c4e445e8ca28689645366c5', format: format, w: 1) expect(response.body).to start_with("diff --git") - # without whitespace option, there are more than 2 diff_splits - diff_splits = assigns(:diffs).first.diff.split("\n") + + # without whitespace option, there are more than 2 diff_splits for other formats + diff_splits = assigns(:diffs).diff_files.first.diff.diff.split("\n") expect(diff_splits.length).to be <= 2 end end @@ -102,13 +103,13 @@ describe Projects::CommitController do include_examples "export as", :patch let(:format) { :patch } - it "should really be a git email patch" do + it "is a git email patch" do go(id: commit.id, format: format) expect(response.body).to start_with("From #{commit.id}") end - it "should contain a git diff" do + it "contains a git diff" do go(id: commit.id, format: format) expect(response.body).to match(/^diff --git/) @@ -146,7 +147,7 @@ describe Projects::CommitController do describe 'POST revert' do context 'when target branch is not provided' do - it 'should render the 404 page' do + it 'renders the 404 page' do post(:revert, namespace_id: project.namespace.to_param, project_id: project.to_param, @@ -158,7 +159,7 @@ describe Projects::CommitController do end context 'when the revert was successful' do - it 'should redirect to the commits page' do + it 'redirects to the commits page' do post(:revert, namespace_id: project.namespace.to_param, project_id: project.to_param, @@ -179,7 +180,7 @@ describe Projects::CommitController do id: commit.id) end - it 'should redirect to the commit page' do + it 'redirects to the commit page' do # Reverting a commit that has been already reverted. post(:revert, namespace_id: project.namespace.to_param, @@ -195,7 +196,7 @@ describe Projects::CommitController do describe 'POST cherry_pick' do context 'when target branch is not provided' do - it 'should render the 404 page' do + it 'renders the 404 page' do post(:cherry_pick, namespace_id: project.namespace.to_param, project_id: project.to_param, @@ -207,7 +208,7 @@ describe Projects::CommitController do end context 'when the cherry-pick was successful' do - it 'should redirect to the commits page' do + it 'redirects to the commits page' do post(:cherry_pick, namespace_id: project.namespace.to_param, project_id: project.to_param, @@ -228,7 +229,7 @@ describe Projects::CommitController do id: master_pickable_commit.id) end - it 'should redirect to the commit page' do + it 'redirects to the commit page' do # Cherry-picking a commit that has been already cherry-picked. post(:cherry_pick, namespace_id: project.namespace.to_param, @@ -266,9 +267,9 @@ describe Projects::CommitController do end it 'only renders the diffs for the path given' do - expect(controller).to receive(:render_diff_for_path).and_wrap_original do |meth, diffs, diff_refs, project| - expect(diffs.map(&:new_path)).to contain_exactly(existing_path) - meth.call(diffs, diff_refs, project) + expect(controller).to receive(:render_diff_for_path).and_wrap_original do |meth, diffs| + expect(diffs.diff_files.map(&:new_path)).to contain_exactly(existing_path) + meth.call(diffs) end diff_for_path(id: commit.id, old_path: existing_path, new_path: existing_path) |