Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2015-09-28 14:35:26 +0300
committerKamil Trzcinski <ayufan@ayufan.eu>2015-09-29 11:47:03 +0300
commit0e3381470870732dff69c9298131062f786d55e7 (patch)
tree02a4a5e588c73c066fa80222b03065d3b8295e24 /spec/models/ci
parent30c78e70cba395c1336611c58891a75473f8a037 (diff)
Fix tests
Diffstat (limited to 'spec/models/ci')
-rw-r--r--spec/models/ci/commit_spec.rb12
-rw-r--r--spec/models/ci/project_services/hip_chat_message_spec.rb6
-rw-r--r--spec/models/ci/project_services/hip_chat_service_spec.rb4
-rw-r--r--spec/models/ci/project_services/slack_message_spec.rb6
-rw-r--r--spec/models/ci/project_services/slack_service_spec.rb4
-rw-r--r--spec/models/ci/project_spec.rb49
-rw-r--r--spec/models/ci/service_spec.rb2
7 files changed, 46 insertions, 37 deletions
diff --git a/spec/models/ci/commit_spec.rb b/spec/models/ci/commit_spec.rb
index c277cbd8bc0..5429151c8d9 100644
--- a/spec/models/ci/commit_spec.rb
+++ b/spec/models/ci/commit_spec.rb
@@ -18,11 +18,13 @@
require 'spec_helper'
describe Ci::Commit do
- let(:commit) { FactoryGirl.create :ci_commit }
- let(:commit_with_project) { FactoryGirl.create :ci_commit }
+ let(:project) { FactoryGirl.create :ci_project }
+ let(:gl_project) { FactoryGirl.create :empty_project, gitlab_ci_project: project }
+ let(:commit) { FactoryGirl.create :ci_commit, gl_project: gl_project }
+ let(:commit_with_project) { FactoryGirl.create :ci_commit, gl_project: gl_project }
let(:config_processor) { Ci::GitlabCiYamlProcessor.new(gitlab_ci_yaml) }
- it { is_expected.to belong_to(:project) }
+ it { is_expected.to belong_to(:gl_project) }
it { is_expected.to have_many(:builds) }
it { is_expected.to validate_presence_of :before_sha }
it { is_expected.to validate_presence_of :sha }
@@ -87,7 +89,7 @@ describe Ci::Commit do
email_add_pusher: false,
email_recipients: 'rec1 rec2'
gl_project = FactoryGirl.create :empty_project, gitlab_ci_project: project
- commit = FactoryGirl.create :ci_commit, project: gl_project
+ commit = FactoryGirl.create :ci_commit, gl_project: gl_project
expect(commit.project_recipients).to eq(['rec1', 'rec2'])
end
@@ -96,7 +98,7 @@ describe Ci::Commit do
email_add_pusher: true,
email_recipients: 'rec1 rec1 rec2'
gl_project = FactoryGirl.create :empty_project, gitlab_ci_project: project
- commit = FactoryGirl.create :ci_commit, project: gl_project
+ commit = FactoryGirl.create :ci_commit, gl_project: gl_project
expected = 'rec2'
allow(commit).to receive(:push_data) { { user_email: expected } }
expect(commit.project_recipients).to eq(['rec1', 'rec2'])
diff --git a/spec/models/ci/project_services/hip_chat_message_spec.rb b/spec/models/ci/project_services/hip_chat_message_spec.rb
index 49ac0860259..1903c036924 100644
--- a/spec/models/ci/project_services/hip_chat_message_spec.rb
+++ b/spec/models/ci/project_services/hip_chat_message_spec.rb
@@ -3,10 +3,8 @@ require 'spec_helper'
describe Ci::HipChatMessage do
subject { Ci::HipChatMessage.new(build) }
- let(:project) { FactoryGirl.create(:ci_project) }
-
context "One build" do
- let(:commit) { FactoryGirl.create(:ci_commit_with_one_job, project: project) }
+ let(:commit) { FactoryGirl.create(:ci_commit_with_one_job) }
let(:build) do
commit.create_builds
@@ -37,7 +35,7 @@ describe Ci::HipChatMessage do
end
context "Several builds" do
- let(:commit) { FactoryGirl.create(:ci_commit_with_two_jobs, project: project) }
+ let(:commit) { FactoryGirl.create(:ci_commit_with_two_jobs) }
let(:build) do
commit.builds.first
diff --git a/spec/models/ci/project_services/hip_chat_service_spec.rb b/spec/models/ci/project_services/hip_chat_service_spec.rb
index 8f91a986b3a..d9ccc855edf 100644
--- a/spec/models/ci/project_services/hip_chat_service_spec.rb
+++ b/spec/models/ci/project_services/hip_chat_service_spec.rb
@@ -39,8 +39,8 @@ describe Ci::HipChatService do
before do
allow(service).to receive_messages(
- project: project,
- project_id: project.id,
+ project: commit.project,
+ project_id: commit.project_id,
notify_only_broken_builds: false,
hipchat_room: 123,
hipchat_token: 'a1b2c3d4e5f6'
diff --git a/spec/models/ci/project_services/slack_message_spec.rb b/spec/models/ci/project_services/slack_message_spec.rb
index f5335903728..7b541802d7d 100644
--- a/spec/models/ci/project_services/slack_message_spec.rb
+++ b/spec/models/ci/project_services/slack_message_spec.rb
@@ -3,10 +3,8 @@ require 'spec_helper'
describe Ci::SlackMessage do
subject { Ci::SlackMessage.new(commit) }
- let(:project) { FactoryGirl.create :ci_project }
-
context "One build" do
- let(:commit) { FactoryGirl.create(:ci_commit_with_one_job, project: project) }
+ let(:commit) { FactoryGirl.create(:ci_commit_with_one_job) }
let(:build) do
commit.create_builds
@@ -43,7 +41,7 @@ describe Ci::SlackMessage do
end
context "Several builds" do
- let(:commit) { FactoryGirl.create(:ci_commit_with_two_jobs, project: project) }
+ let(:commit) { FactoryGirl.create(:ci_commit_with_two_jobs) }
context 'when all matrix builds succeeded' do
let(:color) { 'good' }
diff --git a/spec/models/ci/project_services/slack_service_spec.rb b/spec/models/ci/project_services/slack_service_spec.rb
index 80adadc591b..1ac7dfe568d 100644
--- a/spec/models/ci/project_services/slack_service_spec.rb
+++ b/spec/models/ci/project_services/slack_service_spec.rb
@@ -38,8 +38,8 @@ describe Ci::SlackService do
before do
allow(slack).to receive_messages(
- project: project,
- project_id: project.id,
+ project: commit.project,
+ project_id: commit.project_id,
webhook: webhook_url,
notify_only_broken_builds: notify_only_broken_builds
)
diff --git a/spec/models/ci/project_spec.rb b/spec/models/ci/project_spec.rb
index a45f1094fd6..b83eccb94e2 100644
--- a/spec/models/ci/project_spec.rb
+++ b/spec/models/ci/project_spec.rb
@@ -28,9 +28,17 @@
require 'spec_helper'
describe Ci::Project do
+ let(:gl_project) { FactoryGirl.create :empty_project, gitlab_ci_project: project }
+ let (:gl_project) { }
subject { FactoryGirl.build :ci_project }
- it { is_expected.to have_many(:commits) }
+ it { is_expected.to have_many(:runner_projects) }
+ it { is_expected.to have_many(:runners) }
+ it { is_expected.to have_many(:web_hooks) }
+ it { is_expected.to have_many(:events) }
+ it { is_expected.to have_many(:variables) }
+ it { is_expected.to have_many(:triggers) }
+ it { is_expected.to have_many(:services) }
it { is_expected.to validate_presence_of :name }
it { is_expected.to validate_presence_of :timeout }
@@ -50,41 +58,44 @@ describe Ci::Project do
describe "ordered_by_last_commit_date" do
it "returns ordered projects" do
- newest_project = FactoryGirl.create :ci_project
- oldest_project = FactoryGirl.create :ci_project
- project_without_commits = FactoryGirl.create :ci_project
+ newest_project = FactoryGirl.create :empty_project
+ newest_project.ensure_ci_project
+ oldest_project = FactoryGirl.create :empty_project
+ oldest_project.ensure_ci_project
+ project_without_commits = FactoryGirl.create :empty_project
+ project_without_commits.ensure_ci_project
- FactoryGirl.create :ci_commit, committed_at: 1.hour.ago, project: newest_project
- FactoryGirl.create :ci_commit, committed_at: 2.hour.ago, project: oldest_project
+ FactoryGirl.create :ci_commit, committed_at: 1.hour.ago, gl_project: newest_project
+ FactoryGirl.create :ci_commit, committed_at: 2.hour.ago, gl_project: oldest_project
- expect(Ci::Project.ordered_by_last_commit_date).to eq([newest_project, oldest_project, project_without_commits])
+ expect(Ci::Project.ordered_by_last_commit_date).to eq([newest_project.gitlab_ci_project, oldest_project.gitlab_ci_project, project_without_commits.gitlab_ci_project])
end
end
describe 'ordered commits' do
- let(:project) { FactoryGirl.create :ci_project }
+ let(:project) { FactoryGirl.create :empty_project }
it 'returns ordered list of commits' do
- commit1 = FactoryGirl.create :ci_commit, committed_at: 1.hour.ago, project: project
- commit2 = FactoryGirl.create :ci_commit, committed_at: 2.hour.ago, project: project
- expect(project.commits).to eq([commit2, commit1])
+ commit1 = FactoryGirl.create :ci_commit, committed_at: 1.hour.ago, gl_project: project
+ commit2 = FactoryGirl.create :ci_commit, committed_at: 2.hour.ago, gl_project: project
+ expect(project.commits).to eq([commit2.project, commit1.project])
end
it 'returns commits ordered by committed_at and id, with nulls last' do
- commit1 = FactoryGirl.create :ci_commit, committed_at: 1.hour.ago, project: project
- commit2 = FactoryGirl.create :ci_commit, committed_at: nil, project: project
- commit3 = FactoryGirl.create :ci_commit, committed_at: 2.hour.ago, project: project
- commit4 = FactoryGirl.create :ci_commit, committed_at: nil, project: project
- expect(project.commits).to eq([commit2, commit4, commit3, commit1])
+ commit1 = FactoryGirl.create :ci_commit, committed_at: 1.hour.ago, gl_project: project
+ commit2 = FactoryGirl.create :ci_commit, committed_at: nil, gl_project: project
+ commit3 = FactoryGirl.create :ci_commit, committed_at: 2.hour.ago, gl_project: project
+ commit4 = FactoryGirl.create :ci_commit, committed_at: nil, gl_project: project
+ expect(project.commits).to eq([commit2.project, commit4.project, commit3.project, commit1.project])
end
end
context :valid_project do
- let(:project) { FactoryGirl.create :ci_project }
- let(:gl_project) { FactoryGirl.create(:empty_project, gitlab_ci_project: project) }
- let(:commit) { FactoryGirl.create(:ci_commit, gl_project: gl_project) }
+ let(:commit) { FactoryGirl.create(:ci_commit) }
context :project_with_commit_and_builds do
+ let(:project) { commit.project }
+
before do
FactoryGirl.create(:ci_build, commit: commit)
end
diff --git a/spec/models/ci/service_spec.rb b/spec/models/ci/service_spec.rb
index f6354f3cbca..2df70e88888 100644
--- a/spec/models/ci/service_spec.rb
+++ b/spec/models/ci/service_spec.rb
@@ -34,7 +34,7 @@ describe Ci::Service do
before do
allow(@service).to receive_messages(
- project: project
+ project: commit.project
)
build
@testable = @service.can_test?