diff options
-rw-r--r-- | app/controllers/projects_controller.rb | 2 | ||||
-rw-r--r-- | spec/controllers/projects_controller_spec.rb | 44 | ||||
-rw-r--r-- | spec/features/projects_spec.rb | 10 |
3 files changed, 55 insertions, 1 deletions
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 7f752f5..abfe1dd 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -90,6 +90,8 @@ class ProjectsController < ApplicationController else head 500 end + rescue + head 500 end # Project status badge diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb new file mode 100644 index 0000000..730a9af --- /dev/null +++ b/spec/controllers/projects_controller_spec.rb @@ -0,0 +1,44 @@ +require "spec_helper" + +describe ProjectsController do + before do + @project = FactoryGirl.create :project + end + + describe "POST #build" do + it 'should respond 200 if params is ok' do + post :build, id: @project.id, + ref: 'master', + before: '2aa371379db71ac89ae20843fcff3b3477cf1a1d', + after: '1c8a9df454ef68c22c2a33cca8232bb50849e5c5', + token: @project.token + + + expect(response).to be_success + expect(response.code).to eq('200') + end + + it 'should respond 200 if push about removed branch' do + post :build, id: @project.id, + ref: 'master', + before: '2aa371379db71ac89ae20843fcff3b3477cf1a1d', + after: '000000000000000000000000000000000000000', + token: @project.token + + expect(response).to be_success + expect(response.code).to eq('200') + end + + it 'should respond 500 if something wrong' do + post :build, id: @project.id, token: @project.token + expect(response).not_to be_success + expect(response.code).to eq('500') + end + + it 'should respond 403 if token is wrong' do + post :build, id: @project.id, token: 'invalid-token' + expect(response).not_to be_success + expect(response.code).to eq('403') + end + end +end diff --git a/spec/features/projects_spec.rb b/spec/features/projects_spec.rb index 241d0d5..7f2b3eb 100644 --- a/spec/features/projects_spec.rb +++ b/spec/features/projects_spec.rb @@ -50,5 +50,13 @@ describe "Projects" do it { page.should have_content @project.name } it { page.should have_content 'Integration with GitLab and other services' } end -end + describe "GET /projects/:id/run" do + before do + visit run_project_path(@project, ref: 'master') + end + + it { current_path.should == project_build_path(@project, @project.builds.last) } + it { page.should have_content @project.builds.last.git_commit_message } + end +end |