diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-09-09 14:17:16 +0200 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-09-09 14:17:16 +0200 |
commit | cc4ef4da11d46761ab0ce4fbd6b032a7e01baba9 (patch) | |
tree | 2ed2caa8a9c1202148b5bed477e4c50ee09a3fd7 /spec | |
parent | 76c6aeb9bc9855e9a65bb08db862e92ac923255e (diff) | |
download | gitlab-ce-cc4ef4da11d46761ab0ce4fbd6b032a7e01baba9.tar.gz |
Refactor CI tests
Diffstat (limited to 'spec')
-rw-r--r-- | spec/ci/six.tar.gz | bin | 61937 -> 0 bytes | |||
-rw-r--r-- | spec/controllers/ci/projects_controller_spec.rb | 18 | ||||
-rw-r--r-- | spec/factories/ci/trigger_requests.rb | 4 | ||||
-rw-r--r-- | spec/factories/ci/triggers.rb | 2 | ||||
-rw-r--r-- | spec/features/ci/admin/builds_spec.rb (renamed from spec/ci/features/admin/builds_spec.rb) | 0 | ||||
-rw-r--r-- | spec/features/ci/admin/events_spec.rb (renamed from spec/ci/features/admin/events_spec.rb) | 0 | ||||
-rw-r--r-- | spec/features/ci/admin/projects_spec.rb (renamed from spec/ci/features/admin/projects_spec.rb) | 0 | ||||
-rw-r--r-- | spec/features/ci/admin/runners_spec.rb (renamed from spec/ci/features/admin/runners_spec.rb) | 0 | ||||
-rw-r--r-- | spec/features/ci/builds_spec.rb (renamed from spec/ci/features/builds_spec.rb) | 0 | ||||
-rw-r--r-- | spec/features/ci/commits_spec.rb (renamed from spec/ci/features/commits_spec.rb) | 0 | ||||
-rw-r--r-- | spec/features/ci/events_spec.rb (renamed from spec/ci/features/events_spec.rb) | 0 | ||||
-rw-r--r-- | spec/features/ci/lint_spec.rb (renamed from spec/ci/features/lint_spec.rb) | 0 | ||||
-rw-r--r-- | spec/features/ci/projects_spec.rb (renamed from spec/ci/features/projects_spec.rb) | 0 | ||||
-rw-r--r-- | spec/features/ci/runners_spec.rb (renamed from spec/ci/features/runners_spec.rb) | 0 | ||||
-rw-r--r-- | spec/features/ci/triggers_spec.rb (renamed from spec/ci/features/triggers_spec.rb) | 0 | ||||
-rw-r--r-- | spec/features/ci/variables_spec.rb (renamed from spec/ci/features/variables_spec.rb) | 0 | ||||
-rw-r--r-- | spec/helpers/ci/application_helper_spec.rb (renamed from spec/ci/helpers/application_helper_spec.rb) | 2 | ||||
-rw-r--r-- | spec/helpers/ci/runners_helper_spec.rb (renamed from spec/ci/helpers/runners_helper_spec.rb) | 2 | ||||
-rw-r--r-- | spec/helpers/ci/user_helper_spec.rb (renamed from spec/ci/helpers/user_helper_spec.rb) | 2 | ||||
-rw-r--r-- | spec/helpers/ci/user_sessions_helper_spec.rb (renamed from spec/ci/helpers/user_sessions_helper_spec.rb) | 2 | ||||
-rw-r--r-- | spec/lib/ci/ansi2html_spec.rb (renamed from spec/ci/lib/ansi2html_spec.rb) | 0 | ||||
-rw-r--r-- | spec/lib/ci/charts_spec.rb (renamed from spec/ci/lib/charts_spec.rb) | 0 | ||||
-rw-r--r-- | spec/lib/ci/gitlab_ci_yaml_processor_spec.rb (renamed from spec/ci/lib/gitlab_ci_yaml_processor_spec.rb) | 0 | ||||
-rw-r--r-- | spec/lib/ci/upgrader_spec.rb (renamed from spec/ci/lib/upgrader_spec.rb) | 0 | ||||
-rw-r--r-- | spec/mailers/ci/notify_spec.rb (renamed from spec/ci/mailers/notify_spec.rb) | 0 | ||||
-rw-r--r-- | spec/models/ci/build_spec.rb (renamed from spec/ci/models/build_spec.rb) | 50 | ||||
-rw-r--r-- | spec/models/ci/commit_spec.rb (renamed from spec/ci/models/commit_spec.rb) | 70 | ||||
-rw-r--r-- | spec/models/ci/mail_service_spec.rb (renamed from spec/ci/models/mail_service_spec.rb) | 40 | ||||
-rw-r--r-- | spec/models/ci/network_spec.rb (renamed from spec/ci/models/network_spec.rb) | 0 | ||||
-rw-r--r-- | spec/models/ci/project_services/hip_chat_message_spec.rb (renamed from spec/ci/models/project_services/hip_chat_message_spec.rb) | 10 | ||||
-rw-r--r-- | spec/models/ci/project_services/hip_chat_service_spec.rb (renamed from spec/ci/models/project_services/hip_chat_service_spec.rb) | 2 | ||||
-rw-r--r-- | spec/models/ci/project_services/slack_message_spec.rb (renamed from spec/ci/models/project_services/slack_message_spec.rb) | 6 | ||||
-rw-r--r-- | spec/models/ci/project_services/slack_service_spec.rb (renamed from spec/ci/models/project_services/slack_service_spec.rb) | 2 | ||||
-rw-r--r-- | spec/models/ci/project_spec.rb (renamed from spec/ci/models/project_spec.rb) | 0 | ||||
-rw-r--r-- | spec/models/ci/runner_project_spec.rb (renamed from spec/ci/models/runner_project_spec.rb) | 2 | ||||
-rw-r--r-- | spec/models/ci/runner_spec.rb (renamed from spec/ci/models/runner_spec.rb) | 2 | ||||
-rw-r--r-- | spec/models/ci/service_spec.rb (renamed from spec/ci/models/service_spec.rb) | 2 | ||||
-rw-r--r-- | spec/models/ci/trigger_spec.rb (renamed from spec/ci/models/trigger_spec.rb) | 2 | ||||
-rw-r--r-- | spec/models/ci/user_spec.rb (renamed from spec/ci/models/user_spec.rb) | 2 | ||||
-rw-r--r-- | spec/models/ci/variable_spec.rb (renamed from spec/ci/models/variable_spec.rb) | 2 | ||||
-rw-r--r-- | spec/models/ci/web_hook_spec.rb (renamed from spec/ci/models/web_hook_spec.rb) | 2 | ||||
-rw-r--r-- | spec/requests/ci/api/builds_spec.rb (renamed from spec/ci/requests/api/builds_spec.rb) | 2 | ||||
-rw-r--r-- | spec/requests/ci/api/commits_spec.rb (renamed from spec/ci/requests/api/commits_spec.rb) | 2 | ||||
-rw-r--r-- | spec/requests/ci/api/forks_spec.rb (renamed from spec/ci/requests/api/forks_spec.rb) | 2 | ||||
-rw-r--r-- | spec/requests/ci/api/projects_spec.rb (renamed from spec/ci/requests/api/projects_spec.rb) | 8 | ||||
-rw-r--r-- | spec/requests/ci/api/runners_spec.rb (renamed from spec/ci/requests/api/runners_spec.rb) | 2 | ||||
-rw-r--r-- | spec/requests/ci/api/triggers_spec.rb (renamed from spec/ci/requests/api/triggers_spec.rb) | 2 | ||||
-rw-r--r-- | spec/requests/ci/builds_spec.rb (renamed from spec/ci/requests/builds_spec.rb) | 0 | ||||
-rw-r--r-- | spec/requests/ci/commits_spec.rb (renamed from spec/ci/requests/commits_spec.rb) | 0 | ||||
-rw-r--r-- | spec/services/ci/create_commit_service_spec.rb (renamed from spec/ci/services/create_commit_service_spec.rb) | 0 | ||||
-rw-r--r-- | spec/services/ci/create_project_service_spec.rb (renamed from spec/ci/services/create_project_service_spec.rb) | 0 | ||||
-rw-r--r-- | spec/services/ci/create_trigger_request_service_spec.rb (renamed from spec/ci/services/create_trigger_request_service_spec.rb) | 0 | ||||
-rw-r--r-- | spec/services/ci/event_service_spec.rb (renamed from spec/ci/services/event_service_spec.rb) | 0 | ||||
-rw-r--r-- | spec/services/ci/image_for_build_service_spec.rb (renamed from spec/ci/services/image_for_build_service_spec.rb) | 0 | ||||
-rw-r--r-- | spec/services/ci/register_build_service_spec.rb (renamed from spec/ci/services/register_build_service_spec.rb) | 0 | ||||
-rw-r--r-- | spec/services/ci/web_hook_service_spec.rb (renamed from spec/ci/services/web_hook_service_spec.rb) | 0 |
56 files changed, 122 insertions, 122 deletions
diff --git a/spec/ci/six.tar.gz b/spec/ci/six.tar.gz Binary files differdeleted file mode 100644 index 80a8c6644e4..00000000000 --- a/spec/ci/six.tar.gz +++ /dev/null diff --git a/spec/controllers/ci/projects_controller_spec.rb b/spec/controllers/ci/projects_controller_spec.rb index 0069a782511..9af766eff33 100644 --- a/spec/controllers/ci/projects_controller_spec.rb +++ b/spec/controllers/ci/projects_controller_spec.rb @@ -1,8 +1,8 @@ require "spec_helper" -describe ProjectsController do +describe Ci::ProjectsController do before do - @project = FactoryGirl.create :project + @project = FactoryGirl.create :ci_project end describe "POST #build" do @@ -55,25 +55,25 @@ describe ProjectsController do end let(:user) do - User.new(user_data) + Ci::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) - Network.any_instance.stub(:project_hooks).and_return(true) + allow_any_instance_of(Ci::Network).to receive(:enable_ci).and_return(true) + allow_any_instance_of(Ci::Network).to receive(:project_hooks).and_return(true) post :create, { project: JSON.dump(project_dump.to_h) }.with_indifferent_access expect(response.code).to eq('302') - expect(assigns(:project)).not_to be_a_new(Project) + expect(assigns(:project)).not_to be_a_new(Ci::Project) end it "shows error" do allow(controller).to receive(:reset_cache) { true } allow(controller).to receive(:current_user) { user } - User.any_instance.stub(:can_manage_project?).and_return(false) + allow_any_instance_of(Ci::User).to receive(:can_manage_project?).and_return(false) post :create, { project: JSON.dump(project_dump.to_h) }.with_indifferent_access @@ -91,13 +91,13 @@ describe ProjectsController do end let(:user) do - User.new(user_data) + Ci::User.new(user_data) end it "searches projects" do allow(controller).to receive(:reset_cache) { true } allow(controller).to receive(:current_user) { user } - Network.any_instance.should_receive(:projects).with(hash_including(search: 'str'), :authorized) + allow_any_instance_of(Ci::Network).to receive(:projects).with(hash_including(search: 'str'), :authorized) xhr :get, :gitlab, { search: "str", format: "js" }.with_indifferent_access diff --git a/spec/factories/ci/trigger_requests.rb b/spec/factories/ci/trigger_requests.rb index c85d1027ce6..da8b7342fcf 100644 --- a/spec/factories/ci/trigger_requests.rb +++ b/spec/factories/ci/trigger_requests.rb @@ -1,8 +1,8 @@ # Read about factories at https://github.com/thoughtbot/factory_girl FactoryGirl.define do - factory :trigger_request do - factory :trigger_request_with_variables do + factory :ci_trigger_request do + factory :ci_trigger_request_with_variables do variables do { TRIGGER_KEY: 'TRIGGER_VALUE' diff --git a/spec/factories/ci/triggers.rb b/spec/factories/ci/triggers.rb index 38cd3cbceb6..fd3afdb1ec2 100644 --- a/spec/factories/ci/triggers.rb +++ b/spec/factories/ci/triggers.rb @@ -2,7 +2,7 @@ FactoryGirl.define do factory :ci_trigger_without_token, class: Ci::Trigger do - factory :trigger do + factory :ci_trigger do token 'token' end end diff --git a/spec/ci/features/admin/builds_spec.rb b/spec/features/ci/admin/builds_spec.rb index e62e83692da..e62e83692da 100644 --- a/spec/ci/features/admin/builds_spec.rb +++ b/spec/features/ci/admin/builds_spec.rb diff --git a/spec/ci/features/admin/events_spec.rb b/spec/features/ci/admin/events_spec.rb index 469c6ed102d..469c6ed102d 100644 --- a/spec/ci/features/admin/events_spec.rb +++ b/spec/features/ci/admin/events_spec.rb diff --git a/spec/ci/features/admin/projects_spec.rb b/spec/features/ci/admin/projects_spec.rb index 6f87e368deb..6f87e368deb 100644 --- a/spec/ci/features/admin/projects_spec.rb +++ b/spec/features/ci/admin/projects_spec.rb diff --git a/spec/ci/features/admin/runners_spec.rb b/spec/features/ci/admin/runners_spec.rb index 2827a7fc6e5..2827a7fc6e5 100644 --- a/spec/ci/features/admin/runners_spec.rb +++ b/spec/features/ci/admin/runners_spec.rb diff --git a/spec/ci/features/builds_spec.rb b/spec/features/ci/builds_spec.rb index fcd7996efd7..fcd7996efd7 100644 --- a/spec/ci/features/builds_spec.rb +++ b/spec/features/ci/builds_spec.rb diff --git a/spec/ci/features/commits_spec.rb b/spec/features/ci/commits_spec.rb index 202f05c516f..202f05c516f 100644 --- a/spec/ci/features/commits_spec.rb +++ b/spec/features/ci/commits_spec.rb diff --git a/spec/ci/features/events_spec.rb b/spec/features/ci/events_spec.rb index 77d1fba5769..77d1fba5769 100644 --- a/spec/ci/features/events_spec.rb +++ b/spec/features/ci/events_spec.rb diff --git a/spec/ci/features/lint_spec.rb b/spec/features/ci/lint_spec.rb index 0b3d4e099fb..0b3d4e099fb 100644 --- a/spec/ci/features/lint_spec.rb +++ b/spec/features/ci/lint_spec.rb diff --git a/spec/ci/features/projects_spec.rb b/spec/features/ci/projects_spec.rb index 3f21af92a2b..3f21af92a2b 100644 --- a/spec/ci/features/projects_spec.rb +++ b/spec/features/ci/projects_spec.rb diff --git a/spec/ci/features/runners_spec.rb b/spec/features/ci/runners_spec.rb index c41dc5b2e2e..c41dc5b2e2e 100644 --- a/spec/ci/features/runners_spec.rb +++ b/spec/features/ci/runners_spec.rb diff --git a/spec/ci/features/triggers_spec.rb b/spec/features/ci/triggers_spec.rb index 2076429383d..2076429383d 100644 --- a/spec/ci/features/triggers_spec.rb +++ b/spec/features/ci/triggers_spec.rb diff --git a/spec/ci/features/variables_spec.rb b/spec/features/ci/variables_spec.rb index 2bb0d9dedde..2bb0d9dedde 100644 --- a/spec/ci/features/variables_spec.rb +++ b/spec/features/ci/variables_spec.rb diff --git a/spec/ci/helpers/application_helper_spec.rb b/spec/helpers/ci/application_helper_spec.rb index c2b1058a8fa..478c0266770 100644 --- a/spec/ci/helpers/application_helper_spec.rb +++ b/spec/helpers/ci/application_helper_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe ApplicationHelper do +describe Ci::ApplicationHelper do describe "#duration_in_words" do it "returns minutes and seconds" do intervals_in_words = { diff --git a/spec/ci/helpers/runners_helper_spec.rb b/spec/helpers/ci/runners_helper_spec.rb index 02d497b40d2..e7681df10bd 100644 --- a/spec/ci/helpers/runners_helper_spec.rb +++ b/spec/helpers/ci/runners_helper_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe RunnersHelper do +describe Ci::RunnersHelper do it "returns - not contacted yet" do runner = FactoryGirl.build :runner runner_status_icon(runner).should include("not connected yet") diff --git a/spec/ci/helpers/user_helper_spec.rb b/spec/helpers/ci/user_helper_spec.rb index 7215dc41a85..f95bfb355ed 100644 --- a/spec/ci/helpers/user_helper_spec.rb +++ b/spec/helpers/ci/user_helper_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe UserHelper do +describe Ci::UserHelper do describe :user_avatar_url do let (:user) { User.new({'avatar_url' => avatar_url}) } diff --git a/spec/ci/helpers/user_sessions_helper_spec.rb b/spec/helpers/ci/user_sessions_helper_spec.rb index a2ab1f1e023..5f654866d99 100644 --- a/spec/ci/helpers/user_sessions_helper_spec.rb +++ b/spec/helpers/ci/user_sessions_helper_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe UserSessionsHelper do +describe Ci::UserSessionsHelper do describe :generate_oauth_hmac do let (:salt) { 'a' } let (:salt2) { 'b' } diff --git a/spec/ci/lib/ansi2html_spec.rb b/spec/lib/ci/ansi2html_spec.rb index aa60011685b..aa60011685b 100644 --- a/spec/ci/lib/ansi2html_spec.rb +++ b/spec/lib/ci/ansi2html_spec.rb diff --git a/spec/ci/lib/charts_spec.rb b/spec/lib/ci/charts_spec.rb index 236cfc2a1f6..236cfc2a1f6 100644 --- a/spec/ci/lib/charts_spec.rb +++ b/spec/lib/ci/charts_spec.rb diff --git a/spec/ci/lib/gitlab_ci_yaml_processor_spec.rb b/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb index ed3d4e84054..ed3d4e84054 100644 --- a/spec/ci/lib/gitlab_ci_yaml_processor_spec.rb +++ b/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb diff --git a/spec/ci/lib/upgrader_spec.rb b/spec/lib/ci/upgrader_spec.rb index 40a98307ad2..40a98307ad2 100644 --- a/spec/ci/lib/upgrader_spec.rb +++ b/spec/lib/ci/upgrader_spec.rb diff --git a/spec/ci/mailers/notify_spec.rb b/spec/mailers/ci/notify_spec.rb index 6a2c845cd0e..6a2c845cd0e 100644 --- a/spec/ci/mailers/notify_spec.rb +++ b/spec/mailers/ci/notify_spec.rb diff --git a/spec/ci/models/build_spec.rb b/spec/models/ci/build_spec.rb index 733398176bf..d1e58438f7b 100644 --- a/spec/ci/models/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -25,10 +25,10 @@ require 'spec_helper' -describe Build do - let(:project) { FactoryGirl.create :project } - let(:commit) { FactoryGirl.create :commit, project: project } - let(:build) { FactoryGirl.create :build, commit: commit } +describe Ci::Build do + let(:project) { FactoryGirl.create :ci_project } + let(:commit) { FactoryGirl.create :ci_commit, project: project } + let(:build) { FactoryGirl.create :ci_build, commit: commit } it { should belong_to(:commit) } it { should validate_presence_of :status } @@ -40,12 +40,12 @@ describe Build do it { should respond_to :trace_html } describe :first_pending do - let(:first) { FactoryGirl.create :build, commit: commit, status: 'pending', created_at: Date.yesterday } - let(:second) { FactoryGirl.create :build, commit: commit, status: 'pending' } + let(:first) { FactoryGirl.create :ci_build, commit: commit, status: 'pending', created_at: Date.yesterday } + let(:second) { FactoryGirl.create :ci_build, commit: commit, status: 'pending' } before { first; second } - subject { Build.first_pending } + subject { Ci::Build.first_pending } - it { should be_a(Build) } + it { should be_a(Ci::Build) } it('returns with the first pending build') { should eq(first) } end @@ -54,12 +54,12 @@ describe Build do build.status = 'success' build.save end - let(:create_from_build) { Build.create_from build } + let(:create_from_build) { Ci::Build.create_from build } it ('there should be a pending task') do - expect(Build.pending.count(:all)).to eq 0 + expect(Ci::Build.pending.count(:all)).to eq 0 create_from_build - expect(Build.pending.count(:all)).to be > 0 + expect(Ci::Build.pending.count(:all)).to be > 0 end end @@ -69,14 +69,14 @@ describe Build do context 'without started_at' do before { build.started_at = nil } - it { should be_false } + it { should be_falsey } end %w(running success failed).each do |status| context "if build status is #{status}" do before { build.status = status } - it { should be_true } + it { should be_truthy } end end @@ -84,7 +84,7 @@ describe Build do context "if build status is #{status}" do before { build.status = status } - it { should be_false } + it { should be_falsey } end end end @@ -96,7 +96,7 @@ describe Build do context "if build.status is #{state}" do before { build.status = state } - it { should be_true } + it { should be_truthy } end end @@ -104,7 +104,7 @@ describe Build do context "if build.status is #{state}" do before { build.status = state } - it { should be_false } + it { should be_falsey } end end end @@ -116,7 +116,7 @@ describe Build do context "if build.status is #{state}" do before { build.status = state } - it { should be_true } + it { should be_truthy } end end @@ -124,7 +124,7 @@ describe Build do context "if build.status is #{state}" do before { build.status = state } - it { should be_false } + it { should be_falsey } end end end @@ -138,13 +138,13 @@ describe Build do context 'and build.status is success' do before { build.status = 'success' } - it { should be_false } + it { should be_falsey } end context 'and build.status is failed' do before { build.status = 'failed' } - it { should be_false } + it { should be_falsey } end end @@ -154,13 +154,13 @@ describe Build do context 'and build.status is success' do before { build.status = 'success' } - it { should be_false } + it { should be_falsey } end context 'and build.status is failed' do before { build.status = 'failed' } - it { should be_true } + it { should be_truthy } end end end @@ -324,14 +324,14 @@ describe Build do } before do - build.project.variables << Variable.new(key: 'SECRET_KEY', value: 'secret_value') + build.project.variables << Ci::Variable.new(key: 'SECRET_KEY', value: 'secret_value') end it { should eq(variables + secure_variables) } context 'and trigger variables' do - let(:trigger) { FactoryGirl.create :trigger, project: project } - let(:trigger_request) { FactoryGirl.create :trigger_request_with_variables, commit: commit, trigger: trigger } + let(:trigger) { FactoryGirl.create :ci_trigger, project: project } + let(:trigger_request) { FactoryGirl.create :ci_trigger_request_with_variables, commit: commit, trigger: trigger } let(:trigger_variables) { [ {key: :TRIGGER_KEY, value: 'TRIGGER_VALUE', public: false} diff --git a/spec/ci/models/commit_spec.rb b/spec/models/ci/commit_spec.rb index 6f644d20aaf..6d5b0597e13 100644 --- a/spec/ci/models/commit_spec.rb +++ b/spec/models/ci/commit_spec.rb @@ -17,10 +17,10 @@ require 'spec_helper' -describe Commit do - let(:project) { FactoryGirl.create :project } - let(:commit) { FactoryGirl.create :commit, project: project } - let(:commit_with_project) { FactoryGirl.create :commit, project: project } +describe Ci::Commit do + let(:project) { FactoryGirl.create :ci_project } + let(:commit) { FactoryGirl.create :ci_commit, project: project } + let(:commit_with_project) { FactoryGirl.create :ci_commit, project: project } let(:config_processor) { GitlabCiYamlProcessor.new(gitlab_ci_yaml) } it { should belong_to(:project) } @@ -37,18 +37,18 @@ describe Commit do describe :last_build do subject { commit.last_build } before do - @first = FactoryGirl.create :build, commit: commit, created_at: Date.yesterday - @second = FactoryGirl.create :build, commit: commit + @first = FactoryGirl.create :ci_build, commit: commit, created_at: Date.yesterday + @second = FactoryGirl.create :ci_build, commit: commit end - it { should be_a(Build) } + it { should be_a(Ci::Build) } it('returns with the most recently created build') { should eq(@second) } end describe :retry do before do - @first = FactoryGirl.create :build, commit: commit, created_at: Date.yesterday - @second = FactoryGirl.create :build, commit: commit + @first = FactoryGirl.create :ci_build, commit: commit, created_at: Date.yesterday + @second = FactoryGirl.create :ci_build, commit: commit end it "creates new build" do @@ -62,38 +62,38 @@ describe Commit do context 'always sending notification' do it 'should return commit_pusher_email as only recipient when no additional recipients are given' do - project = FactoryGirl.create :project, + project = FactoryGirl.create :ci_project, email_add_pusher: true, email_recipients: '' - commit = FactoryGirl.create :commit, project: project + commit = FactoryGirl.create :ci_commit, project: project expected = 'commit_pusher_email' commit.stub(:push_data) { { user_email: expected } } commit.project_recipients.should == [expected] end it 'should return commit_pusher_email and additional recipients' do - project = FactoryGirl.create :project, + project = FactoryGirl.create :ci_project, email_add_pusher: true, email_recipients: 'rec1 rec2' - commit = FactoryGirl.create :commit, project: project + commit = FactoryGirl.create :ci_commit, project: project expected = 'commit_pusher_email' commit.stub(:push_data) { { user_email: expected } } commit.project_recipients.should == ['rec1', 'rec2', expected] end it 'should return recipients' do - project = FactoryGirl.create :project, + project = FactoryGirl.create :ci_project, email_add_pusher: false, email_recipients: 'rec1 rec2' - commit = FactoryGirl.create :commit, project: project + commit = FactoryGirl.create :ci_commit, project: project commit.project_recipients.should == ['rec1', 'rec2'] end it 'should return unique recipients only' do - project = FactoryGirl.create :project, + project = FactoryGirl.create :ci_project, email_add_pusher: true, email_recipients: 'rec1 rec1 rec2' - commit = FactoryGirl.create :commit, project: project + commit = FactoryGirl.create :ci_commit, project: project expected = 'rec2' commit.stub(:push_data) { { user_email: expected } } commit.project_recipients.should == ['rec1', 'rec2'] @@ -168,8 +168,8 @@ describe Commit do end context 'for build triggers' do - let(:trigger) { FactoryGirl.create :trigger, project: project } - let(:trigger_request) { FactoryGirl.create :trigger_request, commit: commit, trigger: trigger } + let(:trigger) { FactoryGirl.create :ci_trigger, project: project } + let(:trigger_request) { FactoryGirl.create :ci_trigger_request, commit: commit, trigger: trigger } it 'creates builds' do commit.create_builds(trigger_request).should be_true @@ -215,49 +215,49 @@ describe Commit do end describe "#finished_at" do - let(:project) { FactoryGirl.create :project } - let(:commit) { FactoryGirl.create :commit, project: project } + let(:project) { FactoryGirl.create :ci_project } + let(:commit) { FactoryGirl.create :ci_commit, project: project } it "returns finished_at of latest build" do - build = FactoryGirl.create :build, commit: commit, finished_at: Time.now - 60 - build1 = FactoryGirl.create :build, commit: commit, finished_at: Time.now - 120 + build = FactoryGirl.create :ci_build, commit: commit, finished_at: Time.now - 60 + build1 = FactoryGirl.create :ci_build, commit: commit, finished_at: Time.now - 120 commit.finished_at.to_i.should == build.finished_at.to_i end it "returns nil if there is no finished build" do - build = FactoryGirl.create :not_started_build, commit: commit + build = FactoryGirl.create :ci_not_started_build, commit: commit commit.finished_at.should be_nil end end describe "coverage" do - let(:project) { FactoryGirl.create :project, coverage_regex: "/.*/" } - let(:commit) { FactoryGirl.create :commit, project: project } + let(:project) { FactoryGirl.create :ci_project, coverage_regex: "/.*/" } + let(:commit) { FactoryGirl.create :ci_commit, project: project } it "calculates average when there are two builds with coverage" do - FactoryGirl.create :build, name: "rspec", coverage: 30, commit: commit - FactoryGirl.create :build, name: "rubocop", coverage: 40, commit: commit + FactoryGirl.create :ci_build, name: "rspec", coverage: 30, commit: commit + FactoryGirl.create :ci_build, name: "rubocop", coverage: 40, commit: commit commit.coverage.should == "35.00" end it "calculates average when there are two builds with coverage and one with nil" do - FactoryGirl.create :build, name: "rspec", coverage: 30, commit: commit - FactoryGirl.create :build, name: "rubocop", coverage: 40, commit: commit - FactoryGirl.create :build, commit: commit + FactoryGirl.create :ci_build, name: "rspec", coverage: 30, commit: commit + FactoryGirl.create :ci_build, name: "rubocop", coverage: 40, commit: commit + FactoryGirl.create :ci_build, commit: commit commit.coverage.should == "35.00" end it "calculates average when there are two builds with coverage and one is retried" do - FactoryGirl.create :build, name: "rspec", coverage: 30, commit: commit - FactoryGirl.create :build, name: "rubocop", coverage: 30, commit: commit - FactoryGirl.create :build, name: "rubocop", coverage: 40, commit: commit + FactoryGirl.create :ci_build, name: "rspec", coverage: 30, commit: commit + FactoryGirl.create :ci_build, name: "rubocop", coverage: 30, commit: commit + FactoryGirl.create :ci_build, name: "rubocop", coverage: 40, commit: commit commit.coverage.should == "35.00" end it "calculates average when there is one build without coverage" do - FactoryGirl.create :build, commit: commit + FactoryGirl.create :ci_build, commit: commit commit.coverage.should be_nil end end diff --git a/spec/ci/models/mail_service_spec.rb b/spec/models/ci/mail_service_spec.rb index d66a6591f8f..4830d98bdf8 100644 --- a/spec/ci/models/mail_service_spec.rb +++ b/spec/models/ci/mail_service_spec.rb @@ -14,7 +14,7 @@ require 'spec_helper' -describe MailService do +describe Ci::MailService do describe "Associations" do it { should belong_to :project } end @@ -28,12 +28,12 @@ describe MailService do end describe 'Sends email for' do - let(:mail) { MailService.new } + let(:mail) { Ci::MailService.new } describe 'failed build' do - let(:project) { FactoryGirl.create(:project, email_add_pusher: true) } - let(:commit) { FactoryGirl.create(:commit, project: project) } - let(:build) { FactoryGirl.create(:build, status: :failed, commit: commit) } + let(:project) { FactoryGirl.create(:ci_project, email_add_pusher: true) } + let(:commit) { FactoryGirl.create(:ci_commit, project: project) } + let(:build) { FactoryGirl.create(:ci_build, status: :failed, commit: commit) } before do mail.stub( @@ -53,9 +53,9 @@ describe MailService do end describe 'successfull build' do - let(:project) { FactoryGirl.create(:project, email_add_pusher: true, email_only_broken_builds: false) } - let(:commit) { FactoryGirl.create(:commit, project: project) } - let(:build) { FactoryGirl.create(:build, status: :success, commit: commit) } + let(:project) { FactoryGirl.create(:ci_project, email_add_pusher: true, email_only_broken_builds: false) } + let(:commit) { FactoryGirl.create(:ci_commit, project: project) } + let(:build) { FactoryGirl.create(:ci_build, status: :success, commit: commit) } before do mail.stub( @@ -76,13 +76,13 @@ describe MailService do describe 'successfull build and project has email_recipients' do let(:project) { - FactoryGirl.create(:project, + FactoryGirl.create(:ci_project, email_add_pusher: true, email_only_broken_builds: false, email_recipients: "jeroen@example.com") } - let(:commit) { FactoryGirl.create(:commit, project: project) } - let(:build) { FactoryGirl.create(:build, status: :success, commit: commit) } + let(:commit) { FactoryGirl.create(:ci_commit, project: project) } + let(:build) { FactoryGirl.create(:ci_build, status: :success, commit: commit) } before do mail.stub( @@ -104,13 +104,13 @@ describe MailService do describe 'successful build and notify only broken builds' do let(:project) { - FactoryGirl.create(:project, + FactoryGirl.create(:ci_project, email_add_pusher: true, email_only_broken_builds: true, email_recipients: "jeroen@example.com") } - let(:commit) { FactoryGirl.create(:commit, project: project) } - let(:build) { FactoryGirl.create(:build, status: :success, commit: commit) } + let(:commit) { FactoryGirl.create(:ci_commit, project: project) } + let(:build) { FactoryGirl.create(:ci_build, status: :success, commit: commit) } before do mail.stub( @@ -132,13 +132,13 @@ describe MailService do describe 'successful build and can test service' do let(:project) { - FactoryGirl.create(:project, + FactoryGirl.create(:ci_project, email_add_pusher: true, email_only_broken_builds: false, email_recipients: "jeroen@example.com") } - let(:commit) { FactoryGirl.create(:commit, project: project) } - let(:build) { FactoryGirl.create(:build, status: :success, commit: commit) } + let(:commit) { FactoryGirl.create(:ci_commit, project: project) } + let(:build) { FactoryGirl.create(:ci_build, status: :success, commit: commit) } before do mail.stub( @@ -154,13 +154,13 @@ describe MailService do describe 'retried build should not receive email' do let(:project) { - FactoryGirl.create(:project, + FactoryGirl.create(:ci_project, email_add_pusher: true, email_only_broken_builds: true, email_recipients: "jeroen@example.com") } - let(:commit) { FactoryGirl.create(:commit, project: project) } - let(:build) { FactoryGirl.create(:build, status: :failed, commit: commit) } + let(:commit) { FactoryGirl.create(:ci_commit, project: project) } + let(:build) { FactoryGirl.create(:ci_build, status: :failed, commit: commit) } before do mail.stub( diff --git a/spec/ci/models/network_spec.rb b/spec/models/ci/network_spec.rb index b80adba5b08..b80adba5b08 100644 --- a/spec/ci/models/network_spec.rb +++ b/spec/models/ci/network_spec.rb diff --git a/spec/ci/models/project_services/hip_chat_message_spec.rb b/spec/models/ci/project_services/hip_chat_message_spec.rb index f1ad875ebcf..3571cb94793 100644 --- a/spec/ci/models/project_services/hip_chat_message_spec.rb +++ b/spec/models/ci/project_services/hip_chat_message_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe HipChatMessage do +describe Ci::HipChatMessage do subject { HipChatMessage.new(build) } let(:project) { FactoryGirl.create(:project) } @@ -8,7 +8,7 @@ describe HipChatMessage do context "One build" do let(:commit) { FactoryGirl.create(:commit_with_one_job, project: project) } - let(:build) do + let(:build) do commit.create_builds commit.builds.first end @@ -16,7 +16,7 @@ describe HipChatMessage do context 'when build succeeds' do it 'returns a successful message' do build.update(status: "success") - + expect( subject.status_color ).to eq 'green' expect( subject.notify? ).to be_false expect( subject.to_s ).to match(/Build '[^']+' #\d+/) @@ -39,7 +39,7 @@ describe HipChatMessage do context "Several builds" do let(:commit) { FactoryGirl.create(:commit_with_two_jobs, project: project) } - let(:build) do + let(:build) do commit.builds.first end @@ -63,7 +63,7 @@ describe HipChatMessage do second_build = commit.builds.last first_build.update(status: "success") second_build.update(status: "failed") - + expect( subject.status_color ).to eq 'red' expect( subject.notify? ).to be_true expect( subject.to_s ).to match(/Commit #\d+/) diff --git a/spec/ci/models/project_services/hip_chat_service_spec.rb b/spec/models/ci/project_services/hip_chat_service_spec.rb index 37ce4905af8..71dba8fc358 100644 --- a/spec/ci/models/project_services/hip_chat_service_spec.rb +++ b/spec/models/ci/project_services/hip_chat_service_spec.rb @@ -15,7 +15,7 @@ require 'spec_helper' -describe HipChatService do +describe Ci::HipChatService do describe "Validations" do diff --git a/spec/ci/models/project_services/slack_message_spec.rb b/spec/models/ci/project_services/slack_message_spec.rb index 88e0f373206..4a7284fe460 100644 --- a/spec/ci/models/project_services/slack_message_spec.rb +++ b/spec/models/ci/project_services/slack_message_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe SlackMessage do +describe Ci::SlackMessage do subject { SlackMessage.new(commit) } let(:project) { FactoryGirl.create :project } @@ -8,7 +8,7 @@ describe SlackMessage do context "One build" do let(:commit) { FactoryGirl.create(:commit_with_one_job, project: project) } - let(:build) do + let(:build) do commit.create_builds commit.builds.first end @@ -70,7 +70,7 @@ describe SlackMessage do second_build = commit.builds.last first_build.update(status: "success") second_build.update(status: "failed") - + subject.color.should == color subject.fallback.should include('Commit') subject.fallback.should include("\##{commit.id}") diff --git a/spec/ci/models/project_services/slack_service_spec.rb b/spec/models/ci/project_services/slack_service_spec.rb index e1c14281274..952349a9def 100644 --- a/spec/ci/models/project_services/slack_service_spec.rb +++ b/spec/models/ci/project_services/slack_service_spec.rb @@ -14,7 +14,7 @@ require 'spec_helper' -describe SlackService do +describe Ci::SlackService do describe "Associations" do it { should belong_to :project } end diff --git a/spec/ci/models/project_spec.rb b/spec/models/ci/project_spec.rb index aa76b99154b..aa76b99154b 100644 --- a/spec/ci/models/project_spec.rb +++ b/spec/models/ci/project_spec.rb diff --git a/spec/ci/models/runner_project_spec.rb b/spec/models/ci/runner_project_spec.rb index cbefb24705a..0218d484130 100644 --- a/spec/ci/models/runner_project_spec.rb +++ b/spec/models/ci/runner_project_spec.rb @@ -11,6 +11,6 @@ require 'spec_helper' -describe RunnerProject do +describe Ci::RunnerProject do pending "add some examples to (or delete) #{__FILE__}" end diff --git a/spec/ci/models/runner_spec.rb b/spec/models/ci/runner_spec.rb index 6902c0a94e6..8677d86aa02 100644 --- a/spec/ci/models/runner_spec.rb +++ b/spec/models/ci/runner_spec.rb @@ -19,7 +19,7 @@ require 'spec_helper' -describe Runner do +describe Ci::Runner do describe '#display_name' do it 'should return the description if it has a value' do runner = FactoryGirl.build(:runner, description: 'Linux/Ruby-1.9.3-p448') diff --git a/spec/ci/models/service_spec.rb b/spec/models/ci/service_spec.rb index 22a49e10a6c..5a90229ec43 100644 --- a/spec/ci/models/service_spec.rb +++ b/spec/models/ci/service_spec.rb @@ -14,7 +14,7 @@ require 'spec_helper' -describe Service do +describe Ci::Service do describe "Associations" do it { should belong_to :project } diff --git a/spec/ci/models/trigger_spec.rb b/spec/models/ci/trigger_spec.rb index bba638e7817..7c928f9d9dc 100644 --- a/spec/ci/models/trigger_spec.rb +++ b/spec/models/ci/trigger_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Trigger do +describe Ci::Trigger do let(:project) { FactoryGirl.create :project } describe 'before_validation' do diff --git a/spec/ci/models/user_spec.rb b/spec/models/ci/user_spec.rb index 73a7a7d5fbc..d1b87988b74 100644 --- a/spec/ci/models/user_spec.rb +++ b/spec/models/ci/user_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe User do +describe Ci::User do describe "has_developer_access?" do before do diff --git a/spec/ci/models/variable_spec.rb b/spec/models/ci/variable_spec.rb index 4575115ccfb..447512bf6df 100644 --- a/spec/ci/models/variable_spec.rb +++ b/spec/models/ci/variable_spec.rb @@ -13,7 +13,7 @@ require 'spec_helper' -describe Variable do +describe Ci::Variable do subject { Variable.new } let(:secret_value) { 'secret' } diff --git a/spec/ci/models/web_hook_spec.rb b/spec/models/ci/web_hook_spec.rb index 0f0f175a7a3..4211576ce5e 100644 --- a/spec/ci/models/web_hook_spec.rb +++ b/spec/models/ci/web_hook_spec.rb @@ -11,7 +11,7 @@ require 'spec_helper' -describe WebHook do +describe Ci::WebHook do describe "Associations" do it { should belong_to :project } end diff --git a/spec/ci/requests/api/builds_spec.rb b/spec/requests/ci/api/builds_spec.rb index be55e9ff479..7da212da83a 100644 --- a/spec/ci/requests/api/builds_spec.rb +++ b/spec/requests/ci/api/builds_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe API::API do +describe Ci::API::API do include ApiHelpers let(:runner) { FactoryGirl.create(:runner, tag_list: ["mysql", "ruby"]) } diff --git a/spec/ci/requests/api/commits_spec.rb b/spec/requests/ci/api/commits_spec.rb index 190df70c1a5..99021dd681d 100644 --- a/spec/ci/requests/api/commits_spec.rb +++ b/spec/requests/ci/api/commits_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe API::API, 'Commits' do +describe Ci::API::API, 'Commits' do include ApiHelpers let(:project) { FactoryGirl.create(:project) } diff --git a/spec/ci/requests/api/forks_spec.rb b/spec/requests/ci/api/forks_spec.rb index af523421c65..74efc0c30be 100644 --- a/spec/ci/requests/api/forks_spec.rb +++ b/spec/requests/ci/api/forks_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe API::API do +describe Ci::API::API do include ApiHelpers let(:project) { FactoryGirl.create(:project) } diff --git a/spec/ci/requests/api/projects_spec.rb b/spec/requests/ci/api/projects_spec.rb index 014a9efc617..65cfc909b48 100644 --- a/spec/ci/requests/api/projects_spec.rb +++ b/spec/requests/ci/api/projects_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe API::API do +describe Ci::API::API do include ApiHelpers let(:gitlab_url) { GitlabCi.config.gitlab_server.url } @@ -12,11 +12,11 @@ describe API::API do url: gitlab_url } } - + before { stub_gitlab_calls } - + context "requests for scoped projects" do # NOTE: These ids are tied to the actual projects on demo.gitlab.com describe "GET /projects" do @@ -45,7 +45,7 @@ describe API::API do end end end - + describe "POST /projects/:project_id/webhooks" do let!(:project) { FactoryGirl.create(:project) } diff --git a/spec/ci/requests/api/runners_spec.rb b/spec/requests/ci/api/runners_spec.rb index 47de3c2a95c..3faebd40bae 100644 --- a/spec/ci/requests/api/runners_spec.rb +++ b/spec/requests/ci/api/runners_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe API::API do +describe Ci::API::API do include ApiHelpers include StubGitlabCalls diff --git a/spec/ci/requests/api/triggers_spec.rb b/spec/requests/ci/api/triggers_spec.rb index 6e56c4b3b22..5da40a69991 100644 --- a/spec/ci/requests/api/triggers_spec.rb +++ b/spec/requests/ci/api/triggers_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe API::API do +describe Ci::API::API do include ApiHelpers describe 'POST /projects/:project_id/refs/:ref/trigger' do diff --git a/spec/ci/requests/builds_spec.rb b/spec/requests/ci/builds_spec.rb index 73d540e372a..73d540e372a 100644 --- a/spec/ci/requests/builds_spec.rb +++ b/spec/requests/ci/builds_spec.rb diff --git a/spec/ci/requests/commits_spec.rb b/spec/requests/ci/commits_spec.rb index e9d8366c41a..e9d8366c41a 100644 --- a/spec/ci/requests/commits_spec.rb +++ b/spec/requests/ci/commits_spec.rb diff --git a/spec/ci/services/create_commit_service_spec.rb b/spec/services/ci/create_commit_service_spec.rb index 34e00d5b3c0..34e00d5b3c0 100644 --- a/spec/ci/services/create_commit_service_spec.rb +++ b/spec/services/ci/create_commit_service_spec.rb diff --git a/spec/ci/services/create_project_service_spec.rb b/spec/services/ci/create_project_service_spec.rb index 31614968d55..31614968d55 100644 --- a/spec/ci/services/create_project_service_spec.rb +++ b/spec/services/ci/create_project_service_spec.rb diff --git a/spec/ci/services/create_trigger_request_service_spec.rb b/spec/services/ci/create_trigger_request_service_spec.rb index 41db01c2235..41db01c2235 100644 --- a/spec/ci/services/create_trigger_request_service_spec.rb +++ b/spec/services/ci/create_trigger_request_service_spec.rb diff --git a/spec/ci/services/event_service_spec.rb b/spec/services/ci/event_service_spec.rb index f7b9bf58127..f7b9bf58127 100644 --- a/spec/ci/services/event_service_spec.rb +++ b/spec/services/ci/event_service_spec.rb diff --git a/spec/ci/services/image_for_build_service_spec.rb b/spec/services/ci/image_for_build_service_spec.rb index 4c7094146bb..4c7094146bb 100644 --- a/spec/ci/services/image_for_build_service_spec.rb +++ b/spec/services/ci/image_for_build_service_spec.rb diff --git a/spec/ci/services/register_build_service_spec.rb b/spec/services/ci/register_build_service_spec.rb index b5af777dd1d..b5af777dd1d 100644 --- a/spec/ci/services/register_build_service_spec.rb +++ b/spec/services/ci/register_build_service_spec.rb diff --git a/spec/ci/services/web_hook_service_spec.rb b/spec/services/ci/web_hook_service_spec.rb index 2bb153942e8..2bb153942e8 100644 --- a/spec/ci/services/web_hook_service_spec.rb +++ b/spec/services/ci/web_hook_service_spec.rb |