Commit 8549d709 authored by Kamil Trzcinski's avatar Kamil Trzcinski

Fix ci/projects_controller_spec.rb

parent 269b9224
...@@ -49,24 +49,17 @@ describe Ci::ProjectsController do ...@@ -49,24 +49,17 @@ describe Ci::ProjectsController do
end end
describe "POST /projects" do describe "POST /projects" do
let(:project_dump) { YAML.load File.read(Rails.root.join('spec/support/gitlab_stubs/raw_project.yml')) } let(:project_dump) { OpenStruct.new({ id: @project.gitlab_id }) }
let(:gitlab_url) { GitlabCi.config.gitlab_server.url }
let(:user_data) do
data = JSON.parse File.read(Rails.root.join('spec/support/gitlab_stubs/user.json'))
data.merge("url" => gitlab_url)
end
let(:user) do let(:user) do
create(:user) create(:user)
end end
it "creates project" do before do
allow(controller).to receive(:reset_cache) { true } sign_in(user)
allow(controller).to receive(:current_user) { user } end
allow_any_instance_of(Ci::Network).to receive(:enable_ci).and_return(true)
allow_any_instance_of(Ci::Network).to receive(:project_hooks).and_return(true)
it "creates project" do
post :create, { project: JSON.dump(project_dump.to_h) }.with_indifferent_access post :create, { project: JSON.dump(project_dump.to_h) }.with_indifferent_access
expect(response.code).to eq('302') expect(response.code).to eq('302')
...@@ -74,10 +67,6 @@ describe Ci::ProjectsController do ...@@ -74,10 +67,6 @@ describe Ci::ProjectsController do
end end
it "shows error" do it "shows error" do
allow(controller).to receive(:reset_cache) { true }
allow(controller).to receive(:current_user) { user }
allow_any_instance_of(User).to receive(:can_manage_project?).and_return(false)
post :create, { project: JSON.dump(project_dump.to_h) }.with_indifferent_access post :create, { project: JSON.dump(project_dump.to_h) }.with_indifferent_access
expect(response.code).to eq('302') expect(response.code).to eq('302')
...@@ -86,22 +75,15 @@ describe Ci::ProjectsController do ...@@ -86,22 +75,15 @@ describe Ci::ProjectsController do
end end
describe "GET /gitlab" do describe "GET /gitlab" do
let(:gitlab_url) { GitlabCi.config.gitlab_server.url }
let(:user_data) do
data = JSON.parse File.read(Rails.root.join('spec/support/gitlab_stubs/user.json'))
data.merge("url" => gitlab_url)
end
let(:user) do let(:user) do
create(:user) create(:user)
end end
it "searches projects" do before do
allow(controller).to receive(:reset_cache) { true } sign_in(user)
allow(controller).to receive(:current_user) { user } end
allow_any_instance_of(Ci::Network).to receive(:projects).with(hash_including(search: 'str'), :authorized)
it "searches projects" do
xhr :get, :gitlab, { search: "str", format: "js" }.with_indifferent_access xhr :get, :gitlab, { search: "str", format: "js" }.with_indifferent_access
expect(response).to be_success expect(response).to be_success
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment