Skip to content
Snippets Groups Projects
Commit 74b995d1 authored by Robert Speicher's avatar Robert Speicher
Browse files

Use `described_class` where appropriate

parent 976bffef
No related branches found
No related tags found
No related merge requests found
Showing
with 124 additions and 127 deletions
Loading
Loading
@@ -3,131 +3,131 @@ require 'spec_helper'
describe Ansi2html do
 
it "prints non-ansi as-is" do
Ansi2html::convert("Hello").should eq 'Hello'
described_class::convert("Hello").should eq 'Hello'
end
 
it "strips non-color-changing controll sequences" do
Ansi2html::convert("Hello \e[2Kworld").should eq 'Hello world'
described_class::convert("Hello \e[2Kworld").should eq 'Hello world'
end
 
it "prints simply red" do
Ansi2html::convert("\e[31mHello\e[0m").should eq '<span class="term-fg-red">Hello</span>'
described_class::convert("\e[31mHello\e[0m").should eq '<span class="term-fg-red">Hello</span>'
end
 
it "prints simply red without trailing reset" do
Ansi2html::convert("\e[31mHello").should eq '<span class="term-fg-red">Hello</span>'
described_class::convert("\e[31mHello").should eq '<span class="term-fg-red">Hello</span>'
end
 
it "prints simply yellow" do
Ansi2html::convert("\e[33mHello\e[0m").should eq '<span class="term-fg-yellow">Hello</span>'
described_class::convert("\e[33mHello\e[0m").should eq '<span class="term-fg-yellow">Hello</span>'
end
 
it "prints default on blue" do
Ansi2html::convert("\e[39;44mHello").should eq '<span class="term-bg-blue">Hello</span>'
described_class::convert("\e[39;44mHello").should eq '<span class="term-bg-blue">Hello</span>'
end
 
it "prints red on blue" do
Ansi2html::convert("\e[31;44mHello").should eq '<span class="term-fg-red term-bg-blue">Hello</span>'
described_class::convert("\e[31;44mHello").should eq '<span class="term-fg-red term-bg-blue">Hello</span>'
end
 
it "resets colors after red on blue" do
Ansi2html::convert("\e[31;44mHello\e[0m world").should eq '<span class="term-fg-red term-bg-blue">Hello</span> world'
described_class::convert("\e[31;44mHello\e[0m world").should eq '<span class="term-fg-red term-bg-blue">Hello</span> world'
end
 
it "performs color change from red/blue to yellow/blue" do
Ansi2html::convert("\e[31;44mHello \e[33mworld").should eq '<span class="term-fg-red term-bg-blue">Hello </span><span class="term-fg-yellow term-bg-blue">world</span>'
described_class::convert("\e[31;44mHello \e[33mworld").should eq '<span class="term-fg-red term-bg-blue">Hello </span><span class="term-fg-yellow term-bg-blue">world</span>'
end
 
it "performs color change from red/blue to yellow/green" do
Ansi2html::convert("\e[31;44mHello \e[33;42mworld").should eq '<span class="term-fg-red term-bg-blue">Hello </span><span class="term-fg-yellow term-bg-green">world</span>'
described_class::convert("\e[31;44mHello \e[33;42mworld").should eq '<span class="term-fg-red term-bg-blue">Hello </span><span class="term-fg-yellow term-bg-green">world</span>'
end
 
it "performs color change from red/blue to reset to yellow/green" do
Ansi2html::convert("\e[31;44mHello\e[0m \e[33;42mworld").should eq '<span class="term-fg-red term-bg-blue">Hello</span> <span class="term-fg-yellow term-bg-green">world</span>'
described_class::convert("\e[31;44mHello\e[0m \e[33;42mworld").should eq '<span class="term-fg-red term-bg-blue">Hello</span> <span class="term-fg-yellow term-bg-green">world</span>'
end
 
it "ignores unsupported codes" do
Ansi2html::convert("\e[51mHello\e[0m").should eq 'Hello'
described_class::convert("\e[51mHello\e[0m").should eq 'Hello'
end
 
it "prints light red" do
Ansi2html::convert("\e[91mHello\e[0m").should eq '<span class="term-fg-l-red">Hello</span>'
described_class::convert("\e[91mHello\e[0m").should eq '<span class="term-fg-l-red">Hello</span>'
end
 
it "prints default on light red" do
Ansi2html::convert("\e[101mHello\e[0m").should eq '<span class="term-bg-l-red">Hello</span>'
described_class::convert("\e[101mHello\e[0m").should eq '<span class="term-bg-l-red">Hello</span>'
end
 
it "performs color change from red/blue to default/blue" do
Ansi2html::convert("\e[31;44mHello \e[39mworld").should eq '<span class="term-fg-red term-bg-blue">Hello </span><span class="term-bg-blue">world</span>'
described_class::convert("\e[31;44mHello \e[39mworld").should eq '<span class="term-fg-red term-bg-blue">Hello </span><span class="term-bg-blue">world</span>'
end
 
it "performs color change from light red/blue to default/blue" do
Ansi2html::convert("\e[91;44mHello \e[39mworld").should eq '<span class="term-fg-l-red term-bg-blue">Hello </span><span class="term-bg-blue">world</span>'
described_class::convert("\e[91;44mHello \e[39mworld").should eq '<span class="term-fg-l-red term-bg-blue">Hello </span><span class="term-bg-blue">world</span>'
end
 
it "prints bold text" do
Ansi2html::convert("\e[1mHello").should eq '<span class="term-bold">Hello</span>'
described_class::convert("\e[1mHello").should eq '<span class="term-bold">Hello</span>'
end
 
it "resets bold text" do
Ansi2html::convert("\e[1mHello\e[21m world").should eq '<span class="term-bold">Hello</span> world'
Ansi2html::convert("\e[1mHello\e[22m world").should eq '<span class="term-bold">Hello</span> world'
described_class::convert("\e[1mHello\e[21m world").should eq '<span class="term-bold">Hello</span> world'
described_class::convert("\e[1mHello\e[22m world").should eq '<span class="term-bold">Hello</span> world'
end
 
it "prints italic text" do
Ansi2html::convert("\e[3mHello").should eq '<span class="term-italic">Hello</span>'
described_class::convert("\e[3mHello").should eq '<span class="term-italic">Hello</span>'
end
 
it "resets italic text" do
Ansi2html::convert("\e[3mHello\e[23m world").should eq '<span class="term-italic">Hello</span> world'
described_class::convert("\e[3mHello\e[23m world").should eq '<span class="term-italic">Hello</span> world'
end
 
it "prints underlined text" do
Ansi2html::convert("\e[4mHello").should eq '<span class="term-underline">Hello</span>'
described_class::convert("\e[4mHello").should eq '<span class="term-underline">Hello</span>'
end
 
it "resets underlined text" do
Ansi2html::convert("\e[4mHello\e[24m world").should eq '<span class="term-underline">Hello</span> world'
described_class::convert("\e[4mHello\e[24m world").should eq '<span class="term-underline">Hello</span> world'
end
 
it "prints concealed text" do
Ansi2html::convert("\e[8mHello").should eq '<span class="term-conceal">Hello</span>'
described_class::convert("\e[8mHello").should eq '<span class="term-conceal">Hello</span>'
end
 
it "resets concealed text" do
Ansi2html::convert("\e[8mHello\e[28m world").should eq '<span class="term-conceal">Hello</span> world'
described_class::convert("\e[8mHello\e[28m world").should eq '<span class="term-conceal">Hello</span> world'
end
 
it "prints crossed-out text" do
Ansi2html::convert("\e[9mHello").should eq '<span class="term-cross">Hello</span>'
described_class::convert("\e[9mHello").should eq '<span class="term-cross">Hello</span>'
end
 
it "resets crossed-out text" do
Ansi2html::convert("\e[9mHello\e[29m world").should eq '<span class="term-cross">Hello</span> world'
described_class::convert("\e[9mHello\e[29m world").should eq '<span class="term-cross">Hello</span> world'
end
 
it "can print 256 xterm fg colors" do
Ansi2html::convert("\e[38;5;16mHello").should eq '<span class="xterm-fg-16">Hello</span>'
described_class::convert("\e[38;5;16mHello").should eq '<span class="xterm-fg-16">Hello</span>'
end
 
it "can print 256 xterm fg colors on normal magenta background" do
Ansi2html::convert("\e[38;5;16;45mHello").should eq '<span class="xterm-fg-16 term-bg-magenta">Hello</span>'
described_class::convert("\e[38;5;16;45mHello").should eq '<span class="xterm-fg-16 term-bg-magenta">Hello</span>'
end
 
it "can print 256 xterm bg colors" do
Ansi2html::convert("\e[48;5;240mHello").should eq '<span class="xterm-bg-240">Hello</span>'
described_class::convert("\e[48;5;240mHello").should eq '<span class="xterm-bg-240">Hello</span>'
end
 
it "can print 256 xterm bg colors on normal magenta foreground" do
Ansi2html::convert("\e[48;5;16;35mHello").should eq '<span class="term-fg-magenta xterm-bg-16">Hello</span>'
described_class::convert("\e[48;5;16;35mHello").should eq '<span class="term-fg-magenta xterm-bg-16">Hello</span>'
end
 
it "prints bold colored text vividly" do
Ansi2html::convert("\e[1;31mHello\e[0m").should eq '<span class="term-fg-l-red term-bold">Hello</span>'
described_class::convert("\e[1;31mHello\e[0m").should eq '<span class="term-fg-l-red term-bold">Hello</span>'
end
 
it "prints bold light colored text correctly" do
Ansi2html::convert("\e[1;91mHello\e[0m").should eq '<span class="term-fg-l-red term-bold">Hello</span>'
described_class::convert("\e[1;91mHello\e[0m").should eq '<span class="term-fg-l-red term-bold">Hello</span>'
end
end
require 'spec_helper'
 
describe "Charts" do
context "build_times" do
before do
@project = FactoryGirl.create(:project)
@commit = FactoryGirl.create(:commit, project: @project)
FactoryGirl.create(:build, commit: @commit)
end
describe Charts::BuildTime do
before do
@project = FactoryGirl.create(:project)
@commit = FactoryGirl.create(:commit, project: @project)
FactoryGirl.create(:build, commit: @commit)
end
 
it 'should return build times in minutes' do
chart = Charts::BuildTime.new(@project)
chart.build_times.should eq [2]
end
it 'should return build times in minutes' do
chart = described_class.new(@project)
chart.build_times.should eq [2]
end
end
Loading
Loading
@@ -11,7 +11,7 @@ describe GitlabCiYamlProcessor do
rspec: {script: "rspec"}
})
 
config_processor = GitlabCiYamlProcessor.new(config)
config_processor = described_class.new(config)
 
config_processor.builds_for_stage_and_ref(type, "master").size.should eq 1
config_processor.builds_for_stage_and_ref(type, "master").first.should eq({
Loading
Loading
@@ -32,7 +32,7 @@ describe GitlabCiYamlProcessor do
rspec: {script: "rspec", only: ["deploy"]}
})
 
config_processor = GitlabCiYamlProcessor.new(config)
config_processor = described_class.new(config)
 
config_processor.builds_for_stage_and_ref(type, "master").size.should eq 0
end
Loading
Loading
@@ -43,7 +43,7 @@ describe GitlabCiYamlProcessor do
rspec: {script: "rspec", only: ["/^deploy$/"]}
})
 
config_processor = GitlabCiYamlProcessor.new(config)
config_processor = described_class.new(config)
 
config_processor.builds_for_stage_and_ref(type, "master").size.should eq 0
end
Loading
Loading
@@ -54,7 +54,7 @@ describe GitlabCiYamlProcessor do
rspec: {script: "rspec", only: ["master"]}
})
 
config_processor = GitlabCiYamlProcessor.new(config)
config_processor = described_class.new(config)
 
config_processor.builds_for_stage_and_ref(type, "master").size.should eq 1
end
Loading
Loading
@@ -65,7 +65,7 @@ describe GitlabCiYamlProcessor do
rspec: {script: "rspec", except: ["tags"]}
})
 
config_processor = GitlabCiYamlProcessor.new(config)
config_processor = described_class.new(config)
 
config_processor.builds_for_stage_and_ref(type, "0-1", true).size.should eq 0
end
Loading
Loading
@@ -76,7 +76,7 @@ describe GitlabCiYamlProcessor do
rspec: {script: "rspec", type: type, only: ["master", "deploy"]}
})
 
config_processor = GitlabCiYamlProcessor.new(config)
config_processor = described_class.new(config)
 
config_processor.builds_for_stage_and_ref(type, "deploy").size.should eq 1
end
Loading
Loading
@@ -91,7 +91,7 @@ describe GitlabCiYamlProcessor do
production: {script: "deploy", type: "deploy", only: ["master", "deploy"]},
})
 
config_processor = GitlabCiYamlProcessor.new(config)
config_processor = described_class.new(config)
 
config_processor.builds_for_stage_and_ref("production", "deploy").size.should eq 0
config_processor.builds_for_stage_and_ref(type, "deploy").size.should eq 1
Loading
Loading
@@ -108,7 +108,7 @@ describe GitlabCiYamlProcessor do
rspec: {script: "rspec"}
})
 
config_processor = GitlabCiYamlProcessor.new(config)
config_processor = described_class.new(config)
 
config_processor.builds_for_stage_and_ref("test", "master").size.should eq 1
config_processor.builds_for_stage_and_ref("test", "master").first.should eq({
Loading
Loading
@@ -134,7 +134,7 @@ describe GitlabCiYamlProcessor do
rspec: {image: "ruby:2.5", services: ["postgresql"], script: "rspec"}
})
 
config_processor = GitlabCiYamlProcessor.new(config)
config_processor = described_class.new(config)
 
config_processor.builds_for_stage_and_ref("test", "master").size.should eq 1
config_processor.builds_for_stage_and_ref("test", "master").first.should eq({
Loading
Loading
@@ -165,147 +165,147 @@ describe GitlabCiYamlProcessor do
rspec: {script: "rspec"}
})
 
config_processor = GitlabCiYamlProcessor.new(config)
config_processor = described_class.new(config)
config_processor.variables.should eq variables
end
end
 
describe "Error handling" do
it "indicates that object is invalid" do
expect{GitlabCiYamlProcessor.new("invalid_yaml\n!ccdvlf%612334@@@@")}.to raise_error(GitlabCiYamlProcessor::ValidationError)
expect{described_class.new("invalid_yaml\n!ccdvlf%612334@@@@")}.to raise_error(described_class::ValidationError)
end
 
it "returns errors if tags parameter is invalid" do
config = YAML.dump({rspec: {script: "test", tags: "mysql"}})
expect do
GitlabCiYamlProcessor.new(config)
end.to raise_error(GitlabCiYamlProcessor::ValidationError, "rspec job: tags parameter should be an array of strings")
described_class.new(config)
end.to raise_error(described_class::ValidationError, "rspec job: tags parameter should be an array of strings")
end
 
it "returns errors if before_script parameter is invalid" do
config = YAML.dump({before_script: "bundle update", rspec: {script: "test"}})
expect do
GitlabCiYamlProcessor.new(config)
end.to raise_error(GitlabCiYamlProcessor::ValidationError, "before_script should be an array of strings")
described_class.new(config)
end.to raise_error(described_class::ValidationError, "before_script should be an array of strings")
end
 
it "returns errors if image parameter is invalid" do
config = YAML.dump({image: ["test"], rspec: {script: "test"}})
expect do
GitlabCiYamlProcessor.new(config)
end.to raise_error(GitlabCiYamlProcessor::ValidationError, "image should be a string")
described_class.new(config)
end.to raise_error(described_class::ValidationError, "image should be a string")
end
 
it "returns errors if job image parameter is invalid" do
config = YAML.dump({rspec: {script: "test", image: ["test"]}})
expect do
GitlabCiYamlProcessor.new(config)
end.to raise_error(GitlabCiYamlProcessor::ValidationError, "rspec job: image should be a string")
described_class.new(config)
end.to raise_error(described_class::ValidationError, "rspec job: image should be a string")
end
 
it "returns errors if services parameter is not an array" do
config = YAML.dump({services: "test", rspec: {script: "test"}})
expect do
GitlabCiYamlProcessor.new(config)
end.to raise_error(GitlabCiYamlProcessor::ValidationError, "services should be an array of strings")
described_class.new(config)
end.to raise_error(described_class::ValidationError, "services should be an array of strings")
end
 
it "returns errors if services parameter is not an array of strings" do
config = YAML.dump({services: [10, "test"], rspec: {script: "test"}})
expect do
GitlabCiYamlProcessor.new(config)
end.to raise_error(GitlabCiYamlProcessor::ValidationError, "services should be an array of strings")
described_class.new(config)
end.to raise_error(described_class::ValidationError, "services should be an array of strings")
end
 
it "returns errors if job services parameter is not an array" do
config = YAML.dump({rspec: {script: "test", services: "test"}})
expect do
GitlabCiYamlProcessor.new(config)
end.to raise_error(GitlabCiYamlProcessor::ValidationError, "rspec job: services should be an array of strings")
described_class.new(config)
end.to raise_error(described_class::ValidationError, "rspec job: services should be an array of strings")
end
 
it "returns errors if job services parameter is not an array of strings" do
config = YAML.dump({rspec: {script: "test", services: [10, "test"]}})
expect do
GitlabCiYamlProcessor.new(config)
end.to raise_error(GitlabCiYamlProcessor::ValidationError, "rspec job: services should be an array of strings")
described_class.new(config)
end.to raise_error(described_class::ValidationError, "rspec job: services should be an array of strings")
end
 
it "returns errors if there are unknown parameters" do
config = YAML.dump({extra: "bundle update"})
expect do
GitlabCiYamlProcessor.new(config)
end.to raise_error(GitlabCiYamlProcessor::ValidationError, "Unknown parameter: extra")
described_class.new(config)
end.to raise_error(described_class::ValidationError, "Unknown parameter: extra")
end
 
it "returns errors if there are unknown parameters that are hashes, but doesn't have a script" do
config = YAML.dump({extra: {services: "test"}})
expect do
GitlabCiYamlProcessor.new(config)
end.to raise_error(GitlabCiYamlProcessor::ValidationError, "Unknown parameter: extra")
described_class.new(config)
end.to raise_error(described_class::ValidationError, "Unknown parameter: extra")
end
 
it "returns errors if there is no any jobs defined" do
config = YAML.dump({before_script: ["bundle update"]})
expect do
GitlabCiYamlProcessor.new(config)
end.to raise_error(GitlabCiYamlProcessor::ValidationError, "Please define at least one job")
described_class.new(config)
end.to raise_error(described_class::ValidationError, "Please define at least one job")
end
 
it "returns errors if job allow_failure parameter is not an boolean" do
config = YAML.dump({rspec: {script: "test", allow_failure: "string"}})
expect do
GitlabCiYamlProcessor.new(config)
end.to raise_error(GitlabCiYamlProcessor::ValidationError, "rspec job: allow_failure parameter should be an boolean")
described_class.new(config)
end.to raise_error(described_class::ValidationError, "rspec job: allow_failure parameter should be an boolean")
end
 
it "returns errors if job stage is not a string" do
config = YAML.dump({rspec: {script: "test", type: 1, allow_failure: "string"}})
expect do
GitlabCiYamlProcessor.new(config)
end.to raise_error(GitlabCiYamlProcessor::ValidationError, "rspec job: stage parameter should be build, test, deploy")
described_class.new(config)
end.to raise_error(described_class::ValidationError, "rspec job: stage parameter should be build, test, deploy")
end
 
it "returns errors if job stage is not a pre-defined stage" do
config = YAML.dump({rspec: {script: "test", type: "acceptance", allow_failure: "string"}})
expect do
GitlabCiYamlProcessor.new(config)
end.to raise_error(GitlabCiYamlProcessor::ValidationError, "rspec job: stage parameter should be build, test, deploy")
described_class.new(config)
end.to raise_error(described_class::ValidationError, "rspec job: stage parameter should be build, test, deploy")
end
 
it "returns errors if job stage is not a defined stage" do
config = YAML.dump({types: ["build", "test"], rspec: {script: "test", type: "acceptance", allow_failure: "string"}})
expect do
GitlabCiYamlProcessor.new(config)
end.to raise_error(GitlabCiYamlProcessor::ValidationError, "rspec job: stage parameter should be build, test")
described_class.new(config)
end.to raise_error(described_class::ValidationError, "rspec job: stage parameter should be build, test")
end
 
it "returns errors if stages is not an array" do
config = YAML.dump({types: "test", rspec: {script: "test"}})
expect do
GitlabCiYamlProcessor.new(config)
end.to raise_error(GitlabCiYamlProcessor::ValidationError, "stages should be an array of strings")
described_class.new(config)
end.to raise_error(described_class::ValidationError, "stages should be an array of strings")
end
 
it "returns errors if stages is not an array of strings" do
config = YAML.dump({types: [true, "test"], rspec: {script: "test"}})
expect do
GitlabCiYamlProcessor.new(config)
end.to raise_error(GitlabCiYamlProcessor::ValidationError, "stages should be an array of strings")
described_class.new(config)
end.to raise_error(described_class::ValidationError, "stages should be an array of strings")
end
 
it "returns errors if variables is not a map" do
config = YAML.dump({variables: "test", rspec: {script: "test"}})
expect do
GitlabCiYamlProcessor.new(config)
end.to raise_error(GitlabCiYamlProcessor::ValidationError, "variables should be a map of key-valued strings")
described_class.new(config)
end.to raise_error(described_class::ValidationError, "variables should be a map of key-valued strings")
end
 
it "returns errors if variables is not a map of key-valued strings" do
config = YAML.dump({variables: {test: false}, rspec: {script: "test"}})
expect do
GitlabCiYamlProcessor.new(config)
end.to raise_error(GitlabCiYamlProcessor::ValidationError, "variables should be a map of key-valued strings")
described_class.new(config)
end.to raise_error(described_class::ValidationError, "variables should be a map of key-valued strings")
end
end
end
require 'spec_helper'
 
describe Upgrader do
let(:upgrader) { Upgrader.new }
let(:upgrader) { described_class.new }
let(:current_version) { GitlabCi::VERSION }
 
describe 'current_version_raw' do
Loading
Loading
Loading
Loading
@@ -11,7 +11,7 @@ describe Notify do
end
 
describe 'build success' do
subject { Notify.build_success_email(@build.id, 'wow@example.com') }
subject { described_class.build_success_email(@build.id, 'wow@example.com') }
 
it 'has the correct subject' do
should have_subject /Build success for/
Loading
Loading
@@ -23,7 +23,7 @@ describe Notify do
end
 
describe 'build fail' do
subject { Notify.build_fail_email(@build.id, 'wow@example.com') }
subject { described_class.build_fail_email(@build.id, 'wow@example.com') }
 
it 'has the correct subject' do
should have_subject /Build failed for/
Loading
Loading
Loading
Loading
@@ -28,7 +28,7 @@ describe MailService do
end
 
describe 'Sends email for' do
let(:mail) { MailService.new }
let(:mail) { described_class.new }
 
describe 'failed build' do
let(:project) { FactoryGirl.create(:project, email_add_pusher: true) }
Loading
Loading
require 'spec_helper'
 
describe Network do
let(:network) { Network.new }
let(:network) { described_class.new }
 
describe '#enable_ci' do
subject { network.enable_ci '', '', '' }
Loading
Loading
require 'spec_helper'
 
describe HipChatMessage do
subject { HipChatMessage.new(build) }
subject { described_class.new(build) }
 
let(:project) { FactoryGirl.create(:project) }
 
Loading
Loading
Loading
Loading
@@ -32,7 +32,7 @@ describe HipChatService do
 
describe "Execute" do
 
let(:service) { HipChatService.new }
let(:service) { described_class.new }
let(:project) { FactoryGirl.create :project }
let(:commit) { FactoryGirl.create :commit, project: project }
let(:build) { FactoryGirl.create :build, commit: commit, status: 'failed' }
Loading
Loading
require 'spec_helper'
 
describe SlackMessage do
subject { SlackMessage.new(commit) }
subject { described_class.new(commit) }
 
let(:project) { FactoryGirl.create :project }
 
Loading
Loading
Loading
Loading
@@ -30,7 +30,7 @@ describe SlackService do
end
 
describe "Execute" do
let(:slack) { SlackService.new }
let(:slack) { described_class.new }
let(:project) { FactoryGirl.create :project }
let(:commit) { FactoryGirl.create :commit, project: project }
let(:build) { FactoryGirl.create :build, commit: commit, status: 'failed' }
Loading
Loading
Loading
Loading
@@ -57,7 +57,7 @@ describe Project do
FactoryGirl.create :commit, committed_at: 1.hour.ago, project: newest_project
FactoryGirl.create :commit, committed_at: 2.hour.ago, project: oldest_project
 
Project.ordered_by_last_commit_date.should eq [newest_project, oldest_project, project_without_commits]
described_class.ordered_by_last_commit_date.should eq [newest_project, oldest_project, project_without_commits]
end
end
 
Loading
Loading
@@ -123,19 +123,19 @@ describe Project do
}
end
 
describe 'Project.parse' do
describe '.parse' do
let(:project_dump) { YAML.load File.read(Rails.root.join('spec/support/gitlab_stubs/raw_project.yml')) }
let(:parsed_project) { Project.parse(project_dump) }
let(:parsed_project) { described_class.parse(project_dump) }
 
it { parsed_project.should be_valid }
it { parsed_project.should be_kind_of(Project) }
it { parsed_project.should be_kind_of(described_class) }
it { parsed_project.name.should eq("GitLab / api.gitlab.org") }
it { parsed_project.gitlab_id.should eq(189) }
it { parsed_project.gitlab_url.should eq("http://demo.gitlab.com/gitlab/api-gitlab-org") }
 
it "parses plain hash" do
Project.parse(project_dump).name.should eq("GitLab / api.gitlab.org")
described_class.parse(project_dump).name.should eq("GitLab / api.gitlab.org")
end
end
 
Loading
Loading
@@ -154,8 +154,8 @@ describe Project do
describe '.search' do
let!(:project) { FactoryGirl.create(:project, name: "foo") }
 
it { Project.search('fo').should include(project) }
it { Project.search('bar').should be_empty }
it { described_class.search('fo').should include(project) }
it { described_class.search('bar').should be_empty }
end
 
describe '#any_runners' do
Loading
Loading
Loading
Loading
@@ -25,7 +25,7 @@ describe Service do
 
describe "Test Button" do
before do
@service = Service.new
@service = described_class.new
end
 
describe "Testable" do
Loading
Loading
Loading
Loading
@@ -4,7 +4,7 @@ describe User do
 
describe "has_developer_access?" do
before do
@user = User.new({})
@user = described_class.new({})
end
 
let(:project_with_owner_access) do
Loading
Loading
@@ -53,24 +53,24 @@ describe User do
end
 
describe "authorized_projects" do
let (:user) { User.new({}) }
let (:user) { described_class.new({}) }
 
before do
FactoryGirl.create :project, gitlab_id: 1
FactoryGirl.create :project, gitlab_id: 2
gitlab_project = OpenStruct.new({id: 1})
gitlab_project1 = OpenStruct.new({id: 2})
allow_any_instance_of(User).to receive(:gitlab_projects).and_return([gitlab_project, gitlab_project1])
allow_any_instance_of(described_class).to receive(:gitlab_projects).and_return([gitlab_project, gitlab_project1])
end
 
it "returns projects" do
allow_any_instance_of(User).to receive(:can_manage_project?).and_return(true)
allow_any_instance_of(described_class).to receive(:can_manage_project?).and_return(true)
 
user.authorized_projects.count.should eq 2
end
 
it "empty list if user miss manage permission" do
allow_any_instance_of(User).to receive(:can_manage_project?).and_return(false)
allow_any_instance_of(described_class).to receive(:can_manage_project?).and_return(false)
 
user.authorized_projects.count.should eq 0
end
Loading
Loading
@@ -82,9 +82,9 @@ describe User do
project1 = FactoryGirl.create :project, gitlab_id: 2
gitlab_project = OpenStruct.new({id: 1})
gitlab_project1 = OpenStruct.new({id: 2})
allow_any_instance_of(User).to receive(:gitlab_projects).and_return([gitlab_project, gitlab_project1])
allow_any_instance_of(User).to receive(:can_manage_project?).and_return(true)
user = User.new({})
allow_any_instance_of(described_class).to receive(:gitlab_projects).and_return([gitlab_project, gitlab_project1])
allow_any_instance_of(described_class).to receive(:can_manage_project?).and_return(true)
user = described_class.new({})
 
runner = FactoryGirl.create :specific_runner
runner1 = FactoryGirl.create :specific_runner
Loading
Loading
Loading
Loading
@@ -14,7 +14,7 @@
require 'spec_helper'
 
describe Variable do
subject { Variable.new }
subject { described_class.new }
 
let(:secret_value) { 'secret' }
 
Loading
Loading
Loading
Loading
@@ -54,7 +54,7 @@ describe WebHook do
end
 
it "catches exceptions" do
WebHook.should_receive(:post).and_raise("Some HTTP Post error")
described_class.should_receive(:post).and_raise("Some HTTP Post error")
 
expect { @web_hook.execute(@data) }.
to raise_error(RuntimeError, 'Some HTTP Post error')
Loading
Loading
require 'spec_helper'
 
describe CreateCommitService do
let(:service) { CreateCommitService.new }
let(:service) { described_class.new }
let(:project) { FactoryGirl.create(:project) }
describe '#execute' do
Loading
Loading
require 'spec_helper'
 
describe CreateProjectService do
let(:service) { CreateProjectService.new }
let(:service) { described_class.new }
let(:current_user) { double.as_null_object }
let(:project_dump) { YAML.load File.read(Rails.root.join('spec/support/gitlab_stubs/raw_project.yml')) }
 
Loading
Loading
require 'spec_helper'
 
describe CreateTriggerRequestService do
let(:service) { CreateTriggerRequestService.new }
let(:service) { described_class.new }
let(:project) { FactoryGirl.create :project }
let(:trigger) { FactoryGirl.create :trigger, project: project }
 
Loading
Loading
Loading
Loading
@@ -10,7 +10,7 @@ describe EventService do
describe '#remove_project' do
it "creates event" do
EventService.new.remove_project(user, project)
described_class.new.remove_project(user, project)
 
Event.admin.last.description.should eq "Project \"GitLab / gitlab-shell\" has been removed by root"
end
Loading
Loading
@@ -18,7 +18,7 @@ describe EventService do
 
describe '#create_project' do
it "creates event" do
EventService.new.create_project(user, project)
described_class.new.create_project(user, project)
 
Event.admin.last.description.should eq "Project \"GitLab / gitlab-shell\" has been created by root"
end
Loading
Loading
@@ -26,7 +26,7 @@ describe EventService do
 
describe '#change_project_settings' do
it "creates event" do
EventService.new.change_project_settings(user, project)
described_class.new.change_project_settings(user, project)
 
Event.last.description.should eq "User \"root\" updated projects settings"
end
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment