Commit b87ca750 authored by Valery Sizov's avatar Valery Sizov

fix specs. Stage 7

parent 88b3195e
...@@ -11,7 +11,7 @@ module Ci ...@@ -11,7 +11,7 @@ module Ci
lines.push("<a href=\"#{Ci::RoutesHelper.ci_project_url(project)}\">#{project.name}</a> - ") lines.push("<a href=\"#{Ci::RoutesHelper.ci_project_url(project)}\">#{project.name}</a> - ")
if commit.matrix? if commit.matrix?
lines.push("<a href=\"#{Ci::RoutesHelper.ci_project_ref_commit_url(project, commit.ref, commit.sha)}\">Commit ##{commit.id}</a></br>") lines.push("<a href=\"#{Ci::RoutesHelper.ci_project_ref_commits_url(project, commit.ref, commit.sha)}\">Commit ##{commit.id}</a></br>")
else else
first_build = commit.builds_without_retry.first first_build = commit.builds_without_retry.first
lines.push("<a href=\"#{Ci::RoutesHelper.ci_project_build_url(project, first_build)}\">Build '#{first_build.name}' ##{first_build.id}</a></br>") lines.push("<a href=\"#{Ci::RoutesHelper.ci_project_build_url(project, first_build)}\">Build '#{first_build.name}' ##{first_build.id}</a></br>")
......
...@@ -46,10 +46,10 @@ module Ci ...@@ -46,10 +46,10 @@ module Ci
def attachment_message def attachment_message
out = "<#{Ci::RoutesHelper.ci_project_url(project)}|#{project_name}>: " out = "<#{Ci::RoutesHelper.ci_project_url(project)}|#{project_name}>: "
if commit.matrix? if commit.matrix?
out << "Commit <#{Ci::RoutesHelper.ci_project_ref_commit_url(project, commit.ref, commit.sha)}|\##{commit.id}> " out << "Commit <#{Ci::RoutesHelper.ci_project_ref_commits_url(project, commit.ref, commit.sha)}|\##{commit.id}> "
else else
build = commit.builds_without_retry.first build = commit.builds_without_retry.first
out << "Build <#{Ci::RoutesHelper.ci_project_build_url(project, build)}|\##{build.id}> " out << "Build <#{Ci::RoutesHelper.ci_project_build_path(project, build)}|\##{build.id}> "
end end
out << "(<#{commit_sha_link}|#{commit.short_sha}>) " out << "(<#{commit_sha_link}|#{commit.short_sha}>) "
out << "of <#{commit_ref_link}|#{commit.ref}> " out << "of <#{commit_ref_link}|#{commit.ref}> "
......
require 'spec_helper' require 'spec_helper'
describe "Admin Builds" do describe "Admin Builds" do
let(:project) { FactoryGirl.create :project } let(:project) { FactoryGirl.create :ci_project }
let(:commit) { FactoryGirl.create :commit, project: project } let(:commit) { FactoryGirl.create :ci_commit, project: project }
let(:build) { FactoryGirl.create :build, commit: commit } let(:build) { FactoryGirl.create :ci_build, commit: commit }
before do before do
skip_admin_auth skip_ci_admin_auth
login_as :user login_as :user
end end
describe "GET /admin/builds" do describe "GET /admin/builds" do
before do before do
build build
visit admin_builds_path visit ci_admin_builds_path
end end
it { expect(page).to have_content "All builds" } it { expect(page).to have_content "All builds" }
...@@ -22,23 +22,23 @@ describe "Admin Builds" do ...@@ -22,23 +22,23 @@ describe "Admin Builds" do
describe "Tabs" do describe "Tabs" do
it "shows all builds" do it "shows all builds" do
build = FactoryGirl.create :build, commit: commit, status: "pending" build = FactoryGirl.create :ci_build, commit: commit, status: "pending"
build1 = FactoryGirl.create :build, commit: commit, status: "running" build1 = FactoryGirl.create :ci_build, commit: commit, status: "running"
build2 = FactoryGirl.create :build, commit: commit, status: "success" build2 = FactoryGirl.create :ci_build, commit: commit, status: "success"
build3 = FactoryGirl.create :build, commit: commit, status: "failed" build3 = FactoryGirl.create :ci_build, commit: commit, status: "failed"
visit admin_builds_path visit ci_admin_builds_path
expect(page.all(".build-link").size).to eq(4) expect(page.all(".build-link").size).to eq(4)
end end
it "shows pending builds" do it "shows pending builds" do
build = FactoryGirl.create :build, commit: commit, status: "pending" build = FactoryGirl.create :ci_build, commit: commit, status: "pending"
build1 = FactoryGirl.create :build, commit: commit, status: "running" build1 = FactoryGirl.create :ci_build, commit: commit, status: "running"
build2 = FactoryGirl.create :build, commit: commit, status: "success" build2 = FactoryGirl.create :ci_build, commit: commit, status: "success"
build3 = FactoryGirl.create :build, commit: commit, status: "failed" build3 = FactoryGirl.create :ci_build, commit: commit, status: "failed"
visit admin_builds_path visit ci_admin_builds_path
within ".nav.nav-tabs" do within ".nav.nav-tabs" do
click_on "Pending" click_on "Pending"
...@@ -51,12 +51,12 @@ describe "Admin Builds" do ...@@ -51,12 +51,12 @@ describe "Admin Builds" do
end end
it "shows running builds" do it "shows running builds" do
build = FactoryGirl.create :build, commit: commit, status: "pending" build = FactoryGirl.create :ci_build, commit: commit, status: "pending"
build1 = FactoryGirl.create :build, commit: commit, status: "running" build1 = FactoryGirl.create :ci_build, commit: commit, status: "running"
build2 = FactoryGirl.create :build, commit: commit, status: "success" build2 = FactoryGirl.create :ci_build, commit: commit, status: "success"
build3 = FactoryGirl.create :build, commit: commit, status: "failed" build3 = FactoryGirl.create :ci_build, commit: commit, status: "failed"
visit admin_builds_path visit ci_admin_builds_path
within ".nav.nav-tabs" do within ".nav.nav-tabs" do
click_on "Running" click_on "Running"
......
...@@ -4,14 +4,14 @@ describe "Admin Events" do ...@@ -4,14 +4,14 @@ describe "Admin Events" do
let(:event) { FactoryGirl.create :admin_event } let(:event) { FactoryGirl.create :admin_event }
before do before do
skip_admin_auth skip_ci_admin_auth
login_as :user login_as :user
end end
describe "GET /admin/events" do describe "GET /admin/events" do
before do before do
event event
visit admin_events_path visit ci_admin_events_path
end end
it { expect(page).to have_content "Events" } it { expect(page).to have_content "Events" }
......
require 'spec_helper' require 'spec_helper'
describe "Admin Projects" do describe "Admin Projects" do
let(:project) { FactoryGirl.create :project } let(:project) { FactoryGirl.create :ci_project }
before do before do
skip_admin_auth skip_ci_admin_auth
login_as :user login_as :user
end end
describe "GET /admin/projects" do describe "GET /admin/projects" do
before do before do
project project
visit admin_projects_path visit ci_admin_projects_path
end end
it { expect(page).to have_content "Projects" } it { expect(page).to have_content "Projects" }
......
...@@ -2,16 +2,16 @@ require 'spec_helper' ...@@ -2,16 +2,16 @@ require 'spec_helper'
describe "Admin Runners" do describe "Admin Runners" do
before do before do
skip_admin_auth skip_ci_admin_auth
login_as :user login_as :user
end end
describe "Runners page" do describe "Runners page" do
before do before do
runner = FactoryGirl.create(:runner) runner = FactoryGirl.create(:ci_runner)
commit = FactoryGirl.create(:commit) commit = FactoryGirl.create(:ci_commit)
FactoryGirl.create(:build, commit: commit, runner_id: runner.id) FactoryGirl.create(:ci_build, commit: commit, runner_id: runner.id)
visit admin_runners_path visit ci_admin_runners_path
end end
it { page.has_text? "Manage Runners" } it { page.has_text? "Manage Runners" }
...@@ -20,8 +20,8 @@ describe "Admin Runners" do ...@@ -20,8 +20,8 @@ describe "Admin Runners" do
describe 'search' do describe 'search' do
before do before do
FactoryGirl.create :runner, description: 'foo' FactoryGirl.create :ci_runner, description: 'foo'
FactoryGirl.create :runner, description: 'bar' FactoryGirl.create :ci_runner, description: 'bar'
fill_in 'search', with: 'foo' fill_in 'search', with: 'foo'
click_button 'Search' click_button 'Search'
...@@ -33,12 +33,12 @@ describe "Admin Runners" do ...@@ -33,12 +33,12 @@ describe "Admin Runners" do
end end
describe "Runner show page" do describe "Runner show page" do
let(:runner) { FactoryGirl.create :runner } let(:runner) { FactoryGirl.create :ci_runner }
before do before do
FactoryGirl.create(:project, name: "foo") FactoryGirl.create(:ci_project, name: "foo")
FactoryGirl.create(:project, name: "bar") FactoryGirl.create(:ci_project, name: "bar")
visit admin_runner_path(runner) visit ci_admin_runner_path(runner)
end end
describe 'runner info' do describe 'runner info' do
......
require 'spec_helper' require 'spec_helper'
describe "Events" do describe "Events" do
let(:project) { FactoryGirl.create :project } let(:project) { FactoryGirl.create :ci_project }
let(:event) { FactoryGirl.create :admin_event, project: project } let(:event) { FactoryGirl.create :admin_event, project: project }
before do before do
...@@ -11,7 +11,7 @@ describe "Events" do ...@@ -11,7 +11,7 @@ describe "Events" do
describe "GET /project/:id/events" do describe "GET /project/:id/events" do
before do before do
event event
visit project_events_path(project) visit ci_project_events_path(project)
end end
it { expect(page).to have_content "Events" } it { expect(page).to have_content "Events" }
......
...@@ -7,7 +7,7 @@ describe "Lint" do ...@@ -7,7 +7,7 @@ describe "Lint" do
it "Yaml parsing", js: true do it "Yaml parsing", js: true do
content = File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml')) content = File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml'))
visit lint_path visit ci_lint_path
fill_in "content", with: content fill_in "content", with: content
click_on "Validate" click_on "Validate"
within "table" do within "table" do
...@@ -19,7 +19,7 @@ describe "Lint" do ...@@ -19,7 +19,7 @@ describe "Lint" do
end end
it "Yaml parsing with error", js: true do it "Yaml parsing with error", js: true do
visit lint_path visit ci_lint_path
fill_in "content", with: "" fill_in "content", with: ""
click_on "Validate" click_on "Validate"
expect(page).to have_content("Status: syntax is incorrect") expect(page).to have_content("Status: syntax is incorrect")
......
...@@ -7,8 +7,8 @@ describe "Runners" do ...@@ -7,8 +7,8 @@ describe "Runners" do
describe "specific runners" do describe "specific runners" do
before do before do
@project = FactoryGirl.create :project @project = FactoryGirl.create :ci_project
@project2 = FactoryGirl.create :project @project2 = FactoryGirl.create :ci_project
stub_js_gitlab_calls stub_js_gitlab_calls
# all projects should be authorized for user # all projects should be authorized for user
...@@ -17,22 +17,22 @@ describe "Runners" do ...@@ -17,22 +17,22 @@ describe "Runners" do
OpenStruct.new({ id: @project2.gitlab_id }) OpenStruct.new({ id: @project2.gitlab_id })
]) ])
@shared_runner = FactoryGirl.create :shared_runner @shared_runner = FactoryGirl.create :ci_shared_runner
@specific_runner = FactoryGirl.create :specific_runner @specific_runner = FactoryGirl.create :ci_specific_runner
@specific_runner2 = FactoryGirl.create :specific_runner @specific_runner2 = FactoryGirl.create :ci_specific_runner
@project.runners << @specific_runner @project.runners << @specific_runner
@project2.runners << @specific_runner2 @project2.runners << @specific_runner2
end end
it "places runners in right places" do it "places runners in right places" do
visit project_runners_path(@project) visit ci_project_runners_path(@project)
expect(page.find(".available-specific-runners")).to have_content(@specific_runner2.display_name) expect(page.find(".available-specific-runners")).to have_content(@specific_runner2.display_name)
expect(page.find(".activated-specific-runners")).to have_content(@specific_runner.display_name) expect(page.find(".activated-specific-runners")).to have_content(@specific_runner.display_name)
expect(page.find(".available-shared-runners")).to have_content(@shared_runner.display_name) expect(page.find(".available-shared-runners")).to have_content(@shared_runner.display_name)
end end
it "enables specific runner for project" do it "enables specific runner for project" do
visit project_runners_path(@project) visit ci_project_runners_path(@project)
within ".available-specific-runners" do within ".available-specific-runners" do
click_on "Enable for this project" click_on "Enable for this project"
...@@ -44,7 +44,7 @@ describe "Runners" do ...@@ -44,7 +44,7 @@ describe "Runners" do
it "disables specific runner for project" do it "disables specific runner for project" do
@project2.runners << @specific_runner @project2.runners << @specific_runner
visit project_runners_path(@project) visit ci_project_runners_path(@project)
within ".activated-specific-runners" do within ".activated-specific-runners" do
click_on "Disable for this project" click_on "Disable for this project"
...@@ -54,7 +54,7 @@ describe "Runners" do ...@@ -54,7 +54,7 @@ describe "Runners" do
end end
it "removes specific runner for project if this is last project for that runners" do it "removes specific runner for project if this is last project for that runners" do
visit project_runners_path(@project) visit ci_project_runners_path(@project)
within ".activated-specific-runners" do within ".activated-specific-runners" do
click_on "Remove runner" click_on "Remove runner"
...@@ -66,12 +66,12 @@ describe "Runners" do ...@@ -66,12 +66,12 @@ describe "Runners" do
describe "shared runners" do describe "shared runners" do
before do before do
@project = FactoryGirl.create :project @project = FactoryGirl.create :ci_project
stub_js_gitlab_calls stub_js_gitlab_calls
end end
it "enables shared runners" do it "enables shared runners" do
visit project_runners_path(@project) visit ci_project_runners_path(@project)
click_on "Enable shared runners" click_on "Enable shared runners"
...@@ -81,14 +81,14 @@ describe "Runners" do ...@@ -81,14 +81,14 @@ describe "Runners" do
describe "show page" do describe "show page" do
before do before do
@project = FactoryGirl.create :project @project = FactoryGirl.create :ci_project
stub_js_gitlab_calls stub_js_gitlab_calls
@specific_runner = FactoryGirl.create :specific_runner @specific_runner = FactoryGirl.create :ci_specific_runner
@project.runners << @specific_runner @project.runners << @specific_runner
end end
it "shows runner information" do it "shows runner information" do
visit project_runners_path(@project) visit ci_project_runners_path(@project)
click_on @specific_runner.short_sha click_on @specific_runner.short_sha
......
require 'spec_helper' require 'spec_helper'
describe 'Variables' do describe 'Triggers' do
before do before do
login_as :user login_as :user
@project = FactoryGirl.create :project @project = FactoryGirl.create :ci_project
stub_js_gitlab_calls stub_js_gitlab_calls
visit project_triggers_path(@project) visit ci_project_triggers_path(@project)
end end
context 'create a trigger' do context 'create a trigger' do
......
...@@ -7,12 +7,12 @@ describe "Variables" do ...@@ -7,12 +7,12 @@ describe "Variables" do
describe "specific runners" do describe "specific runners" do
before do before do
@project = FactoryGirl.create :project @project = FactoryGirl.create :ci_project
stub_js_gitlab_calls stub_js_gitlab_calls
end end
it "creates variable", js: true do it "creates variable", js: true do
visit project_variables_path(@project) visit ci_project_variables_path(@project)
click_on "Add a variable" click_on "Add a variable"
fill_in "Key", with: "SECRET_KEY" fill_in "Key", with: "SECRET_KEY"
fill_in "Value", with: "SECRET_VALUE" fill_in "Value", with: "SECRET_VALUE"
......
...@@ -4,14 +4,14 @@ describe "Charts" do ...@@ -4,14 +4,14 @@ describe "Charts" do
context "build_times" do context "build_times" do
before do before do
@project = FactoryGirl.create(:project) @project = FactoryGirl.create(:ci_project)
@commit = FactoryGirl.create(:commit, project: @project) @commit = FactoryGirl.create(:ci_commit, project: @project)
FactoryGirl.create(:build, commit: @commit) FactoryGirl.create(:ci_build, commit: @commit)
end end
it 'should return build times in minutes' do it 'should return build times in minutes' do
chart = Charts::BuildTime.new(@project) chart = Ci::Charts::BuildTime.new(@project)
chart.build_times.should == [2] expect(chart.build_times).to eq([2])
end end
end end
end end
require 'spec_helper' require 'spec_helper'
describe Ci::GitlabCiYamlProcessor do module Ci
describe GitlabCiYamlProcessor do
describe "#builds_for_ref" do describe "#builds_for_ref" do
let(:type) { 'test' } let(:type) { 'test' }
...@@ -13,8 +14,8 @@ describe Ci::GitlabCiYamlProcessor do ...@@ -13,8 +14,8 @@ describe Ci::GitlabCiYamlProcessor do
config_processor = GitlabCiYamlProcessor.new(config) config_processor = GitlabCiYamlProcessor.new(config)
config_processor.builds_for_stage_and_ref(type, "master").size.should == 1 expect(config_processor.builds_for_stage_and_ref(type, "master").size).to eq(1)
config_processor.builds_for_stage_and_ref(type, "master").first.should == { expect(config_processor.builds_for_stage_and_ref(type, "master").first).to eq({
stage: "test", stage: "test",
except: nil, except: nil,
name: :rspec, name: :rspec,
...@@ -23,7 +24,7 @@ describe Ci::GitlabCiYamlProcessor do ...@@ -23,7 +24,7 @@ describe Ci::GitlabCiYamlProcessor do
tags: [], tags: [],
options: {}, options: {},
allow_failure: false allow_failure: false
} })
end end
it "does not return builds if only has another branch" do it "does not return builds if only has another branch" do
...@@ -34,7 +35,7 @@ describe Ci::GitlabCiYamlProcessor do ...@@ -34,7 +35,7 @@ describe Ci::GitlabCiYamlProcessor do
config_processor = GitlabCiYamlProcessor.new(config) config_processor = GitlabCiYamlProcessor.new(config)
config_processor.builds_for_stage_and_ref(type, "master").size.should == 0 expect(config_processor.builds_for_stage_and_ref(type, "master").size).to eq(0)
end end
it "does not return builds if only has regexp with another branch" do it "does not return builds if only has regexp with another branch" do
...@@ -45,7 +46,7 @@ describe Ci::GitlabCiYamlProcessor do ...@@ -45,7 +46,7 @@ describe Ci::GitlabCiYamlProcessor do
config_processor = GitlabCiYamlProcessor.new(config) config_processor = GitlabCiYamlProcessor.new(config)
config_processor.builds_for_stage_and_ref(type, "master").size.should == 0 expect(config_processor.builds_for_stage_and_ref(type, "master").size).to eq(0)
end end
it "returns builds if only has specified this branch" do it "returns builds if only has specified this branch" do
...@@ -56,7 +57,7 @@ describe Ci::GitlabCiYamlProcessor do ...@@ -56,7 +57,7 @@ describe Ci::GitlabCiYamlProcessor do
config_processor = GitlabCiYamlProcessor.new(config) config_processor = GitlabCiYamlProcessor.new(config)
config_processor.builds_for_stage_and_ref(type, "master").size.should == 1 expect(config_processor.builds_for_stage_and_ref(type, "master").size).to eq(1)
end end
it "does not build tags" do it "does not build tags" do
...@@ -67,7 +68,7 @@ describe Ci::GitlabCiYamlProcessor do ...@@ -67,7 +68,7 @@ describe Ci::GitlabCiYamlProcessor do
config_processor = GitlabCiYamlProcessor.new(config) config_processor = GitlabCiYamlProcessor.new(config)
config_processor.builds_for_stage_and_ref(type, "0-1", true).size.should == 0 expect(config_processor.builds_for_stage_and_ref(type, "0-1", true).size).to eq(0)
end end
it "returns builds if only has a list of branches including specified" do it "returns builds if only has a list of branches including specified" do
...@@ -78,7 +79,7 @@ describe Ci::GitlabCiYamlProcessor do ...@@ -78,7 +79,7 @@ describe Ci::GitlabCiYamlProcessor do
config_processor = GitlabCiYamlProcessor.new(config) config_processor = GitlabCiYamlProcessor.new(config)
config_processor.builds_for_stage_and_ref(type, "deploy").size.should == 1 expect(config_processor.builds_for_stage_and_ref(type, "deploy").size).to eq(1)
end end
it "returns build only for specified type" do it "returns build only for specified type" do
...@@ -93,9 +94,9 @@ describe Ci::GitlabCiYamlProcessor do ...@@ -93,9 +94,9 @@ describe Ci::GitlabCiYamlProcessor do
config_processor = GitlabCiYamlProcessor.new(config) config_processor = GitlabCiYamlProcessor.new(config)
config_processor.builds_for_stage_and_ref("production", "deploy").size.should == 0 expect(config_processor.builds_for_stage_and_ref("production", "deploy").size).to eq(0)
config_processor.builds_for_stage_and_ref(type, "deploy").size.should == 1 expect(config_processor.builds_for_stage_and_ref(type, "deploy").size).to eq(1)
config_processor.builds_for_stage_and_ref("deploy", "deploy").size.should == 2 expect(config_processor.builds_for_stage_and_ref("deploy", "deploy").size).to eq(2)
end end
end end
...@@ -110,8 +111,8 @@ describe Ci::GitlabCiYamlProcessor do ...@@ -110,8 +111,8 @@ describe Ci::GitlabCiYamlProcessor do
config_processor = GitlabCiYamlProcessor.new(config) config_processor = GitlabCiYamlProcessor.new(config)
config_processor.builds_for_stage_and_ref("test", "master").size.should == 1 expect(config_processor.builds_for_stage_and_ref("test", "master").size).to eq(1)
config_processor.builds_for_stage_and_ref("test", "master").first.should == { expect(config_processor.builds_for_stage_and_ref("test", "master").first).to eq({
except: nil, except: nil,
stage: "test", stage: "test",
name: :rspec, name: :rspec,
...@@ -123,7 +124,7 @@ describe Ci::GitlabCiYamlProcessor do ...@@ -123,7 +124,7 @@ describe Ci::GitlabCiYamlProcessor do
services: ["mysql"] services: ["mysql"]
}, },
allow_failure: false allow_failure: false
} })
end end
it "returns image and service when overridden for job" do it "returns image and service when overridden for job" do
...@@ -136,8 +137,8 @@ describe Ci::GitlabCiYamlProcessor do ...@@ -136,8 +137,8 @@ describe Ci::GitlabCiYamlProcessor do
config_processor = GitlabCiYamlProcessor.new(config) config_processor = GitlabCiYamlProcessor.new(config)
config_processor.builds_for_stage_and_ref("test", "master").size.should == 1 expect(config_processor.builds_for_stage_and_ref("test", "master").size).to eq(1)
config_processor.builds_for_stage_and_ref("test", "master").first.should == { expect(config_processor.builds_for_stage_and_ref("test", "master").first).to eq({
except: nil, except: nil,
stage: "test", stage: "test",
name: :rspec, name: :rspec,
...@@ -149,7 +150,7 @@ describe Ci::GitlabCiYamlProcessor do ...@@ -149,7 +150,7 @@ describe Ci::GitlabCiYamlProcessor do
services: ["postgresql"] services: ["postgresql"]
}, },
allow_failure: false allow_failure: false
} })
end end
end end
...@@ -166,7 +167,7 @@ describe Ci::GitlabCiYamlProcessor do ...@@ -166,7 +167,7 @@ describe Ci::GitlabCiYamlProcessor do
}) })
config_processor = GitlabCiYamlProcessor.new(config) config_processor = GitlabCiYamlProcessor.new(config)
config_processor.variables.should == variables expect(config_processor.variables).to eq(variables)
end end
end end
...@@ -308,4 +309,5 @@ describe Ci::GitlabCiYamlProcessor do ...@@ -308,4 +309,5 @@ describe Ci::GitlabCiYamlProcessor do
end.to raise_error(GitlabCiYamlProcessor::ValidationError, "variables should be a map of key-valued strings") end.to raise_error(GitlabCiYamlProcessor::ValidationError, "variables should be a map of key-valued strings")
end end
end end
end
end end
...@@ -169,7 +169,7 @@ describe Ci::MailService do ...@@ -169,7 +169,7 @@ describe Ci::MailService do
end end
it do it do
Build.retry(build) Ci::Build.retry(build)
should_email(commit.git_author_email) should_email(commit.git_author_email)
should_email("jeroen@example.com") should_email("jeroen@example.com")
mail.execute(build) if mail.can_execute?(build) mail.execute(build) if mail.can_execute?(build)
......
require 'spec_helper' require 'spec_helper'
describe Ci::SlackMessage do describe Ci::SlackMessage do
subject { SlackMessage.new(commit) } subject { Ci::SlackMessage.new(commit) }
let(:project) { FactoryGirl.create :ci_project } let(:project) { FactoryGirl.create :ci_project }
...@@ -43,7 +43,7 @@ describe Ci::SlackMessage do ...@@ -43,7 +43,7 @@ describe Ci::SlackMessage do
end end
context "Several builds" do context "Several builds" do
let(:commit) { FactoryGirl.create(:commit_with_two_jobs, project: project) } let(:commit) { FactoryGirl.create(:ci_commit_with_two_jobs, project: project) }
context 'when all matrix builds succeeded' do context 'when all matrix builds succeeded' do
let(:color) { 'good' } let(:color) { 'good' }
......
...@@ -30,7 +30,7 @@ describe Ci::SlackService do ...@@ -30,7 +30,7 @@ describe Ci::SlackService do
end end
describe "Execute" do describe "Execute" do
let(:slack) { SlackService.new } let(:slack) { Ci::SlackService.new }
let(:project) { FactoryGirl.create :ci_project } let(:project) { FactoryGirl.create :ci_project }
let(:commit) { FactoryGirl.create :ci_commit, project: project } let(:commit) { FactoryGirl.create :ci_commit, project: project }
let(:build) { FactoryGirl.create :ci_build, commit: commit, status: 'failed' } let(:build) { FactoryGirl.create :ci_build, commit: commit, status: 'failed' }
...@@ -50,7 +50,7 @@ describe Ci::SlackService do ...@@ -50,7 +50,7 @@ describe Ci::SlackService do
it "should call Slack API" do it "should call Slack API" do
slack.execute(build) slack.execute(build)
SlackNotifierWorker.drain Ci::SlackNotifierWorker.drain
expect(WebMock).to have_requested(:post, webhook_url).once expect(WebMock).to have_requested(:post, webhook_url).once
end end
......
...@@ -22,7 +22,7 @@ require 'spec_helper' ...@@ -22,7 +22,7 @@ require 'spec_helper'
describe Ci::Runner do describe Ci::Runner do
describe '#display_name' do describe '#display_name' do
it 'should return the description if it has a value' do it 'should return the description if it has a value' do
runner = FactoryGirl.build(:runner, description: 'Linux/Ruby-1.9.3-p448') runner = FactoryGirl.build(:ci_runner, description: 'Linux/Ruby-1.9.3-p448')
expect(runner.display_name).to eq 'Linux/Ruby-1.9.3-p448' expect(runner.display_name).to eq 'Linux/Ruby-1.9.3-p448'
end end
...@@ -32,7 +32,7 @@ describe Ci::Runner do ...@@ -32,7 +32,7 @@ describe Ci::Runner do
end end
it 'should return the token if the description is an empty string' do it 'should return the token if the description is an empty string' do
runner = FactoryGirl.build(:runner, description: '') runner = FactoryGirl.build(:ci_runner, description: '')
expect(runner.display_name).to eq runner.token expect(runner.display_name).to eq runner.token
end end
end end
......
...@@ -25,7 +25,7 @@ describe Ci::Service do ...@@ -25,7 +25,7 @@ describe Ci::Service do
describe "Test Button" do describe "Test Button" do
before do before do
@service = Service.new @service = Ci::Service.new
end end
describe "Testable" do describe "Testable" do
......
require 'spec_helper' require 'spec_helper'
describe Ci::CreateProjectService do describe Ci::CreateProjectService do
let(:service) { CreateProjectService.new } let(:service) { Ci::CreateProjectService.new }
let(:current_user) { double.as_null_object } let(:current_user) { double.as_null_object }
let(:project_dump) { YAML.load File.read(Rails.root.join('spec/support/gitlab_stubs/raw_project.yml')) } let(:project_dump) { YAML.load File.read(Rails.root.join('spec/support/gitlab_stubs/raw_project.yml')) }
before { allow_any_instance_of(Network).to receive_messages(enable_ci: true) }
describe :execute do describe :execute do
context 'valid params' do context 'valid params' do
let(:project) { service.execute(current_user, project_dump, 'http://localhost/projects/:project_id') } let(:project) { service.execute(current_user, project_dump, 'http://localhost/projects/:project_id') }
...@@ -23,7 +21,7 @@ describe Ci::CreateProjectService do ...@@ -23,7 +21,7 @@ describe Ci::CreateProjectService do
context "forking" do context "forking" do
it "uses project as a template for settings and jobs" do it "uses project as a template for settings and jobs" do
origin_project = FactoryGirl.create(:project) origin_project = FactoryGirl.create(:ci_project)
origin_project.shared_runners_enabled = true origin_project.shared_runners_enabled = true
origin_project.public = true origin_project.public = true
origin_project.allow_git_fetch = true origin_project.allow_git_fetch = true
......
require 'spec_helper' require 'spec_helper'
describe Ci::CreateTriggerRequestService do describe Ci::CreateTriggerRequestService do
let(:service) { CreateTriggerRequestService.new } let(:service) { Ci::CreateTriggerRequestService.new }
let(:project) { FactoryGirl.create :project } let(:project) { FactoryGirl.create :ci_project }
let(:trigger) { FactoryGirl.create :trigger, project: project } let(:trigger) { FactoryGirl.create :ci_trigger, project: project }
describe :execute do describe :execute do
context 'valid params' do context 'valid params' do
subject { service.execute(project, trigger, 'master') } subject { service.execute(project, trigger, 'master') }
before do before do
@commit = FactoryGirl.create :commit, project: project @commit = FactoryGirl.create :ci_commit, project: project
end end
it { expect(subject).to be_kind_of(TriggerRequest) } it { expect(subject).to be_kind_of(Ci::TriggerRequest) }
it { expect(subject.commit).to eq(@commit) } it { expect(subject.commit).to eq(@commit) }
end end
...@@ -27,7 +27,7 @@ describe Ci::CreateTriggerRequestService do ...@@ -27,7 +27,7 @@ describe Ci::CreateTriggerRequestService do
subject { service.execute(project, trigger, 'master') } subject { service.execute(project, trigger, 'master') }
before do before do
FactoryGirl.create :commit_without_jobs, project: project FactoryGirl.create :ci_commit_without_jobs, project: project
end end
it { expect(subject).to be_nil } it { expect(subject).to be_nil }
...@@ -37,13 +37,13 @@ describe Ci::CreateTriggerRequestService do ...@@ -37,13 +37,13 @@ describe Ci::CreateTriggerRequestService do
subject { service.execute(project, trigger, 'master') } subject { service.execute(project, trigger, 'master') }
before do before do
@commit1 = FactoryGirl.create :commit, committed_at: 2.hour.ago, project: project @commit1 = FactoryGirl.create :ci_commit, committed_at: 2.hour.ago, project: project
@commit2 = FactoryGirl.create :commit, committed_at: 1.hour.ago, project: project @commit2 = FactoryGirl.create :ci_commit, committed_at: 1.hour.ago, project: project
@commit3 = FactoryGirl.create :commit, committed_at: 3.hour.ago, project: project @commit3 = FactoryGirl.create :ci_commit, committed_at: 3.hour.ago, project: project
end end
context 'retries latest one' do context 'retries latest one' do
it { expect(subject).to be_kind_of(TriggerRequest) } it { expect(subject).to be_kind_of(Ci::TriggerRequest) }
it { expect(subject).to be_persisted } it { expect(subject).to be_persisted }
it { expect(subject.commit).to eq(@commit2) } it { expect(subject.commit).to eq(@commit2) }
end end
......
require 'spec_helper' require 'spec_helper'
describe Ci::EventService do describe Ci::EventService do
let(:project) { FactoryGirl.create :project, name: "GitLab / gitlab-shell" } let(:project) { FactoryGirl.create :ci_project, name: "GitLab / gitlab-shell" }
let(:user) { double(username: "root", id: 1) } let(:user) { double(username: "root", id: 1) }
before do before do
...@@ -10,25 +10,25 @@ describe Ci::EventService do ...@@ -10,25 +10,25 @@ describe Ci::EventService do
describe :remove_project do describe :remove_project do
it "creates event" do it "creates event" do
EventService.new.remove_project(user, project) Ci::EventService.new.remove_project(user, project)
expect(Event.admin.last.description).to eq("Project \"GitLab / gitlab-shell\" has been removed by root") expect(Ci::Event.admin.last.description).to eq("Project \"GitLab / gitlab-shell\" has been removed by root")
end end
end end
describe :create_project do describe :create_project do
it "creates event" do it "creates event" do
EventService.new.create_project(user, project) Ci::EventService.new.create_project(user, project)
expect(Event.admin.last.description).to eq("Project \"GitLab / gitlab-shell\" has been created by root") expect(Ci::Event.admin.last.description).to eq("Project \"GitLab / gitlab-shell\" has been created by root")
end end
end end
describe :change_project_settings do describe :change_project_settings do
it "creates event" do it "creates event" do
EventService.new.change_project_settings(user, project) Ci::EventService.new.change_project_settings(user, project)
expect(Event.last.description).to eq("User \"root\" updated projects settings") expect(Ci::Event.last.description).to eq("User \"root\" updated projects settings")
end end
end end
end end
require 'spec_helper' require 'spec_helper'
describe Ci::WebHookService do describe Ci::WebHookService do
let(:project) { FactoryGirl.create :project } let(:project) { FactoryGirl.create :ci_project }
let(:commit) { FactoryGirl.create :commit, project: project } let(:commit) { FactoryGirl.create :ci_commit, project: project }
let(:build) { FactoryGirl.create :build, commit: commit } let(:build) { FactoryGirl.create :ci_build, commit: commit }
let(:hook) { FactoryGirl.create :web_hook, project: project } let(:hook) { FactoryGirl.create :ci_web_hook, project: project }
describe :execute do describe :execute do
it "should execute successfully" do it "should execute successfully" do
stub_request(:post, hook.url).to_return(status: 200) stub_request(:post, hook.url).to_return(status: 200)
expect(WebHookService.new.build_end(build)).to be_truthy expect(Ci::WebHookService.new.build_end(build)).to be_truthy
end end
end end
...@@ -31,6 +31,6 @@ describe Ci::WebHookService do ...@@ -31,6 +31,6 @@ describe Ci::WebHookService do
end end
def build_data(build) def build_data(build)
WebHookService.new.send :build_data, build Ci::WebHookService.new.send :build_data, build
end end
end end
...@@ -44,4 +44,8 @@ module LoginHelpers ...@@ -44,4 +44,8 @@ module LoginHelpers
def logout_direct def logout_direct
page.driver.submit :delete, '/users/sign_out', {} page.driver.submit :delete, '/users/sign_out', {}
end end
def skip_ci_admin_auth
allow_any_instance_of(Ci::Admin::ApplicationController).to receive_messages(authenticate_admin!: true)
end
end end
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