diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2015-12-10 18:12:19 +0100 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2015-12-11 18:02:09 +0100 |
commit | 3578153d3e838da92587fed88a608d9a5458c37c (patch) | |
tree | 5b7f1b21ef9361e63bb83b3be9973aec492de3af /spec/requests/ci | |
parent | 91cdb08d5fa83a86f5f18088bf148e832732bed9 (diff) | |
download | gitlab-ce-3578153d3e838da92587fed88a608d9a5458c37c.tar.gz |
Fix triggers tests
Diffstat (limited to 'spec/requests/ci')
-rw-r--r-- | spec/requests/ci/api/triggers_spec.rb | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/spec/requests/ci/api/triggers_spec.rb b/spec/requests/ci/api/triggers_spec.rb index cd33a96e1a6..0ef03f9371b 100644 --- a/spec/requests/ci/api/triggers_spec.rb +++ b/spec/requests/ci/api/triggers_spec.rb @@ -5,16 +5,14 @@ describe Ci::API::API do describe 'POST /projects/:project_id/refs/:ref/trigger' do let!(:trigger_token) { 'secure token' } - let!(:project) { FactoryGirl.create(:project) } - let!(:project2) { FactoryGirl.create(:empty_project) } + let!(:project) { FactoryGirl.create(:project, ci_id: 10) } + let!(:project2) { FactoryGirl.create(:empty_project, ci_id: 11) } let!(:trigger) { FactoryGirl.create(:ci_trigger, project: project, token: trigger_token) } let(:options) do { token: trigger_token } end - let(:project_ci_id) { create_ci_id(project) } - let(:project2_ci_id) { create_ci_id(project2) } before do stub_ci_commit_to_return_yaml_file @@ -22,7 +20,7 @@ describe Ci::API::API do context 'Handles errors' do it 'should return bad request if token is missing' do - post ci_api("/projects/#{project_ci_id}/refs/master/trigger") + post ci_api("/projects/#{project.ci_id}/refs/master/trigger") expect(response.status).to eq(400) end @@ -32,7 +30,7 @@ describe Ci::API::API do end it 'should return unauthorized if token is for different project' do - post ci_api("/projects/#{project2_ci_id}/refs/master/trigger"), options + post ci_api("/projects/#{project2.ci_id}/refs/master/trigger"), options expect(response.status).to eq(401) end end @@ -41,14 +39,14 @@ describe Ci::API::API do let(:commit) { project.ci_commits.last } it 'should create builds' do - post ci_api("/projects/#{project_ci_id}/refs/master/trigger"), options + post ci_api("/projects/#{project.ci_id}/refs/master/trigger"), options expect(response.status).to eq(201) commit.builds.reload expect(commit.builds.size).to eq(2) end it 'should return bad request with no builds created if there\'s no commit for that ref' do - post ci_api("/projects/#{project_ci_id}/refs/other-branch/trigger"), options + post ci_api("/projects/#{project.ci_id}/refs/other-branch/trigger"), options expect(response.status).to eq(400) expect(json_response['message']).to eq('No builds created') end @@ -59,19 +57,19 @@ describe Ci::API::API do end it 'should validate variables to be a hash' do - post ci_api("/projects/#{project_ci_id}/refs/master/trigger"), options.merge(variables: 'value') + post ci_api("/projects/#{project.ci_id}/refs/master/trigger"), options.merge(variables: 'value') expect(response.status).to eq(400) expect(json_response['message']).to eq('variables needs to be a hash') end it 'should validate variables needs to be a map of key-valued strings' do - post ci_api("/projects/#{project_ci_id}/refs/master/trigger"), options.merge(variables: { key: %w(1 2) }) + post ci_api("/projects/#{project.ci_id}/refs/master/trigger"), options.merge(variables: { key: %w(1 2) }) expect(response.status).to eq(400) expect(json_response['message']).to eq('variables needs to be a map of key-valued strings') end it 'create trigger request with variables' do - post ci_api("/projects/#{project_ci_id}/refs/master/trigger"), options.merge(variables: variables) + post ci_api("/projects/#{project.ci_id}/refs/master/trigger"), options.merge(variables: variables) expect(response.status).to eq(201) commit.builds.reload expect(commit.builds.first.trigger_request.variables).to eq(variables) @@ -79,8 +77,4 @@ describe Ci::API::API do end end end - - def create_ci_id(project) - ActiveRecord::Base.connection.insert("INSERT INTO ci_projects (gitlab_id) VALUES(#{project.id})") - end end |