diff options
Diffstat (limited to 'spec/controllers')
-rw-r--r-- | spec/controllers/blob_controller_spec.rb | 8 | ||||
-rw-r--r-- | spec/controllers/branches_controller_spec.rb | 1 | ||||
-rw-r--r-- | spec/controllers/commit_controller_spec.rb | 24 | ||||
-rw-r--r-- | spec/controllers/commits_controller_spec.rb | 3 | ||||
-rw-r--r-- | spec/controllers/merge_requests_controller_spec.rb | 21 | ||||
-rw-r--r-- | spec/controllers/projects/uploads_controller_spec.rb | 16 | ||||
-rw-r--r-- | spec/controllers/projects_controller_spec.rb | 22 | ||||
-rw-r--r-- | spec/controllers/tree_controller_spec.rb | 8 |
8 files changed, 71 insertions, 32 deletions
diff --git a/spec/controllers/blob_controller_spec.rb b/spec/controllers/blob_controller_spec.rb index ea52e4d212a..a1102f28340 100644 --- a/spec/controllers/blob_controller_spec.rb +++ b/spec/controllers/blob_controller_spec.rb @@ -17,7 +17,10 @@ describe Projects::BlobController do describe "GET show" do render_views - before { get :show, project_id: project.to_param, id: id } + before do + get(:show, namespace_id: project.namespace.to_param, + project_id: project.to_param, id: id) + end context "valid branch, valid file" do let(:id) { 'master/README.md' } @@ -39,7 +42,8 @@ describe Projects::BlobController do render_views before do - get :show, project_id: project.to_param, id: id + get(:show, namespace_id: project.namespace.to_param, + project_id: project.to_param, id: id) controller.instance_variable_set(:@blob, nil) end diff --git a/spec/controllers/branches_controller_spec.rb b/spec/controllers/branches_controller_spec.rb index 0c39d016440..51397382cfb 100644 --- a/spec/controllers/branches_controller_spec.rb +++ b/spec/controllers/branches_controller_spec.rb @@ -19,6 +19,7 @@ describe Projects::BranchesController do before { post :create, + namespace_id: project.namespace.to_param, project_id: project.to_param, branch_name: branch, ref: ref diff --git a/spec/controllers/commit_controller_spec.rb b/spec/controllers/commit_controller_spec.rb index f0e39e674fd..3394a1f863f 100644 --- a/spec/controllers/commit_controller_spec.rb +++ b/spec/controllers/commit_controller_spec.rb @@ -13,7 +13,8 @@ describe Projects::CommitController do describe "#show" do shared_examples "export as" do |format| it "should generally work" do - get :show, project_id: project.to_param, id: commit.id, format: format + get(:show, namespace_id: project.namespace.to_param, + project_id: project.to_param, id: commit.id, format: format) expect(response).to be_success end @@ -21,11 +22,13 @@ describe Projects::CommitController do it "should generate it" do expect_any_instance_of(Commit).to receive(:"to_#{format}") - get :show, project_id: project.to_param, id: commit.id, format: format + get(:show, namespace_id: project.namespace.to_param, + project_id: project.to_param, id: commit.id, format: format) end it "should render it" do - get :show, project_id: project.to_param, id: commit.id, format: format + get(:show, namespace_id: project.namespace.to_param, + project_id: project.to_param, id: commit.id, format: format) expect(response.body).to eq(commit.send(:"to_#{format}")) end @@ -34,7 +37,8 @@ describe Projects::CommitController do allow_any_instance_of(Commit).to receive(:"to_#{format}"). and_return('HTML entities &<>" ') - get :show, project_id: project.to_param, id: commit.id, format: format + get(:show, namespace_id: project.namespace.to_param, + project_id: project.to_param, id: commit.id, format: format) expect(response.body).to_not include('&') expect(response.body).to_not include('>') @@ -48,7 +52,8 @@ describe Projects::CommitController do let(:format) { :diff } it "should really only be a git diff" do - get :show, project_id: project.to_param, id: commit.id, format: format + get(:show, namespace_id: project.namespace.to_param, + project_id: project.to_param, id: commit.id, format: format) expect(response.body).to start_with("diff --git") end @@ -59,13 +64,15 @@ describe Projects::CommitController do let(:format) { :patch } it "should really be a git email patch" do - get :show, project_id: project.to_param, id: commit.id, format: format + get(:show, namespace_id: project.namespace.to_param, + project_id: project.to_param, id: commit.id, format: format) expect(response.body).to start_with("From #{commit.id}") end it "should contain a git diff" do - get :show, project_id: project.to_param, id: commit.id, format: format + get(:show, namespace_id: project.namespace.to_param, + project_id: project.to_param, id: commit.id, format: format) expect(response.body).to match(/^diff --git/) end @@ -74,7 +81,8 @@ describe Projects::CommitController do describe "#branches" do it "contains branch and tags information" do - get :branches, project_id: project.to_param, id: commit.id + get(:branches, namespace_id: project.namespace.to_param, + project_id: project.to_param, id: commit.id) expect(assigns(:branches)).to include("master", "feature_conflict") expect(assigns(:tags)).to include("v1.1.0") diff --git a/spec/controllers/commits_controller_spec.rb b/spec/controllers/commits_controller_spec.rb index c3de01a84f2..2184b35152e 100644 --- a/spec/controllers/commits_controller_spec.rb +++ b/spec/controllers/commits_controller_spec.rb @@ -12,7 +12,8 @@ describe Projects::CommitsController do describe "GET show" do context "as atom feed" do it "should render as atom" do - get :show, project_id: project.to_param, id: "master", format: "atom" + get(:show, namespace_id: project.namespace.to_param, + project_id: project.to_param, id: "master", format: "atom") expect(response).to be_success expect(response.content_type).to eq('application/atom+xml') end diff --git a/spec/controllers/merge_requests_controller_spec.rb b/spec/controllers/merge_requests_controller_spec.rb index eedaf17941a..d6f56ed33d6 100644 --- a/spec/controllers/merge_requests_controller_spec.rb +++ b/spec/controllers/merge_requests_controller_spec.rb @@ -13,7 +13,8 @@ describe Projects::MergeRequestsController do describe "#show" do shared_examples "export merge as" do |format| it "should generally work" do - get :show, project_id: project.to_param, id: merge_request.iid, format: format + get(:show, namespace_id: project.namespace.to_param, + project_id: project.to_param, id: merge_request.iid, format: format) expect(response).to be_success end @@ -21,11 +22,13 @@ describe Projects::MergeRequestsController do it "should generate it" do expect_any_instance_of(MergeRequest).to receive(:"to_#{format}") - get :show, project_id: project.to_param, id: merge_request.iid, format: format + get(:show, namespace_id: project.namespace.to_param, + project_id: project.to_param, id: merge_request.iid, format: format) end it "should render it" do - get :show, project_id: project.to_param, id: merge_request.iid, format: format + get(:show, namespace_id: project.namespace.to_param, + project_id: project.to_param, id: merge_request.iid, format: format) expect(response.body).to eq((merge_request.send(:"to_#{format}",user)).to_s) end @@ -34,7 +37,8 @@ describe Projects::MergeRequestsController do allow_any_instance_of(MergeRequest).to receive(:"to_#{format}"). and_return('HTML entities &<>" ') - get :show, project_id: project.to_param, id: merge_request.iid, format: format + get(:show, namespace_id: project.namespace.to_param, + project_id: project.to_param, id: merge_request.iid, format: format) expect(response.body).to_not include('&') expect(response.body).to_not include('>') @@ -48,7 +52,8 @@ describe Projects::MergeRequestsController do let(:format) { :diff } it "should really only be a git diff" do - get :show, project_id: project.to_param, id: merge_request.iid, format: format + get(:show, namespace_id: project.namespace.to_param, + project_id: project.to_param, id: merge_request.iid, format: format) expect(response.body).to start_with("diff --git") end @@ -59,13 +64,15 @@ describe Projects::MergeRequestsController do let(:format) { :patch } it "should really be a git email patch with commit" do - get :show, project_id: project.to_param, id: merge_request.iid, format: format + get(:show, namespace_id: project.namespace.to_param, + project_id: project.to_param, id: merge_request.iid, format: format) expect(response.body[0..100]).to start_with("From #{merge_request.commits.last.id}") end it "should contain git diffs" do - get :show, project_id: project.to_param, id: merge_request.iid, format: format + get(:show, namespace_id: project.namespace.to_param, + project_id: project.to_param, id: merge_request.iid, format: format) expect(response.body).to match(/^diff --git/) end diff --git a/spec/controllers/projects/uploads_controller_spec.rb b/spec/controllers/projects/uploads_controller_spec.rb index 28d313b7e98..8774ee0a841 100644 --- a/spec/controllers/projects/uploads_controller_spec.rb +++ b/spec/controllers/projects/uploads_controller_spec.rb @@ -6,15 +6,18 @@ describe Projects::UploadsController do let(:jpg) { fixture_file_upload(Rails.root + 'spec/fixtures/rails_sample.jpg', 'image/jpg') } let(:txt) { fixture_file_upload(Rails.root + 'spec/fixtures/doc_sample.txt', 'text/plain') } - describe 'POST #create' do + describe "POST #create" do before do sign_in(user) project.team << [user, :developer] end context "without params['file']" do - it 'returns an error' do - post :create, project_id: project.to_param, format: :json + it "returns an error" do + post :create, + namespace_id: project.namespace.to_param, + project_id: project.to_param, + format: :json expect(response.status).to eq(422) end end @@ -22,6 +25,7 @@ describe Projects::UploadsController do context 'with valid image' do before do post :create, + namespace_id: project.namespace.to_param project_id: project.to_param, file: jpg, format: :json @@ -36,7 +40,11 @@ describe Projects::UploadsController do context 'with valid non-image file' do before do - post :create, project_id: project.to_param, file: txt, format: :json + post :create, + namespace_id: project.namespace.to_param, + project_id: project.to_param, + file: txt, + format: :json end it 'returns a content with original filename, new link, and correct type.' do diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb index 9be4c2e505c..89bb35de8fc 100644 --- a/spec/controllers/projects_controller_spec.rb +++ b/spec/controllers/projects_controller_spec.rb @@ -4,21 +4,27 @@ describe ProjectsController do let(:project) { create(:project) } let(:public_project) { create(:project, :public) } let(:user) { create(:user) } - - describe 'POST #toggle_star' do - it 'toggles star if user is signed in' do + let(:jpg) { fixture_file_upload(Rails.root + 'spec/fixtures/rails_sample.jpg', 'image/jpg') } + let(:txt) { fixture_file_upload(Rails.root + 'spec/fixtures/doc_sample.txt', 'text/plain') } + + describe "POST #toggle_star" do + it "toggles star if user is signed in" do sign_in(user) expect(user.starred?(public_project)).to be_falsey - post :toggle_star, id: public_project.to_param + post(:toggle_star, namespace_id: public_project.namespace.to_param, + id: public_project.to_param) expect(user.starred?(public_project)).to be_truthy - post :toggle_star, id: public_project.to_param + post(:toggle_star, namespace_id: public_project.namespace.to_param, + id: public_project.to_param) expect(user.starred?(public_project)).to be_falsey end - it 'does nothing if user is not signed in' do - post :toggle_star, id: public_project.to_param + it "does nothing if user is not signed in" do + post(:toggle_star, namespace_id: project.namespace.to_param, + id: public_project.to_param) expect(user.starred?(public_project)).to be_falsey - post :toggle_star, id: public_project.to_param + post(:toggle_star, namespace_id: project.namespace.to_param, + id: public_project.to_param) expect(user.starred?(public_project)).to be_falsey end end diff --git a/spec/controllers/tree_controller_spec.rb b/spec/controllers/tree_controller_spec.rb index 805e0a8795b..7b219819bbc 100644 --- a/spec/controllers/tree_controller_spec.rb +++ b/spec/controllers/tree_controller_spec.rb @@ -18,7 +18,10 @@ describe Projects::TreeController do # Make sure any errors accessing the tree in our views bubble up to this spec render_views - before { get :show, project_id: project.to_param, id: id } + before do + get(:show, namespace_id: project.namespace.to_param, + project_id: project.to_param, id: id) + end context "valid branch, no path" do let(:id) { 'master' } @@ -45,7 +48,8 @@ describe Projects::TreeController do render_views before do - get :show, project_id: project.to_param, id: id + get(:show, namespace_id: project.namespace.to_param, + project_id: project.to_param, id: id) end context 'redirect to blob' do |