diff options
author | Valery Sizov <vsv2711@gmail.com> | 2015-04-10 17:06:19 +0300 |
---|---|---|
committer | Valery Sizov <vsv2711@gmail.com> | 2015-04-10 17:06:19 +0300 |
commit | 0698f842b037785d6c691907bc6847b71a139174 (patch) | |
tree | 976de3fdd7e000725704414dcc91cd5f1bbdadf8 | |
parent | fa1d7aaa99d13278a83d955804077811bb65c553 (diff) | |
download | gitlab-ci-0698f842b037785d6c691907bc6847b71a139174.tar.gz |
fix adding projects
-rw-r--r-- | app/controllers/projects_controller.rb | 2 | ||||
-rw-r--r-- | spec/controllers/projects_controller_spec.rb | 25 |
2 files changed, 26 insertions, 1 deletions
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index f254c8b..d46a616 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -49,7 +49,7 @@ class ProjectsController < ApplicationController end def create - @project = CreateProjectService.new.execute(current_user, project_params, project_url(":project_id")) + @project = CreateProjectService.new.execute(current_user, params[:project], project_url(":project_id")) if @project.persisted? redirect_to project_path(@project, show_guide: true), notice: 'Project was successfully created.' diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb index b3d5eac..9a788dc 100644 --- a/spec/controllers/projects_controller_spec.rb +++ b/spec/controllers/projects_controller_spec.rb @@ -40,5 +40,30 @@ describe ProjectsController do expect(response).not_to be_success expect(response.code).to eq('403') end + + describe "POST /:projects" do + let(:project_dump) { File.read(Rails.root.join('spec/support/gitlab_stubs/raw_project.yml')) } + 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 + User.new(user_data) + end + + it "creates project" do + allow(controller).to receive(:reset_cache) { true } + allow(controller).to receive(:current_user) { user } + Network.any_instance.stub(:enable_ci).and_return(true) + + post :create, { project: project_dump }.with_indifferent_access + + Project.exists?(gitlab_id: 189).should be_true + expect(response.code).to eq('302') + end + end end end |