summaryrefslogtreecommitdiff
path: root/spec/models/concerns
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models/concerns')
-rw-r--r--spec/models/concerns/access_requestable_spec.rb14
-rw-r--r--spec/models/concerns/avatarable_spec.rb36
-rw-r--r--spec/models/concerns/awardable_spec.rb12
-rw-r--r--spec/models/concerns/batch_destroy_dependent_associations_spec.rb16
-rw-r--r--spec/models/concerns/blob_language_from_git_attributes_spec.rb14
-rw-r--r--spec/models/concerns/blocks_json_serialization_spec.rb10
-rw-r--r--spec/models/concerns/cache_markdown_field_spec.rb106
-rw-r--r--spec/models/concerns/cacheable_attributes_spec.rb108
-rw-r--r--spec/models/concerns/case_sensitivity_spec.rb38
-rw-r--r--spec/models/concerns/chronic_duration_attribute_spec.rb66
-rw-r--r--spec/models/concerns/deployable_spec.rb43
-rw-r--r--spec/models/concerns/deployment_platform_spec.rb58
-rw-r--r--spec/models/concerns/discussion_on_diff_spec.rb30
-rw-r--r--spec/models/concerns/each_batch_spec.rb26
-rw-r--r--spec/models/concerns/editable_spec.rb4
-rw-r--r--spec/models/concerns/expirable_spec.rb12
-rw-r--r--spec/models/concerns/faster_cache_keys_spec.rb8
-rw-r--r--spec/models/concerns/feature_gate_spec.rb10
-rw-r--r--spec/models/concerns/from_union_spec.rb14
-rw-r--r--spec/models/concerns/group_descendant_spec.rb80
-rw-r--r--spec/models/concerns/has_ref_spec.rb26
-rw-r--r--spec/models/concerns/has_status_spec.rb184
-rw-r--r--spec/models/concerns/has_variable_spec.rb44
-rw-r--r--spec/models/concerns/ignorable_column_spec.rb22
-rw-r--r--spec/models/concerns/issuable_spec.rb254
-rw-r--r--spec/models/concerns/loaded_in_group_list_spec.rb20
-rw-r--r--spec/models/concerns/manual_inverse_association_spec.rb22
-rw-r--r--spec/models/concerns/maskable_spec.rb50
-rw-r--r--spec/models/concerns/mentionable_spec.rb80
-rw-r--r--spec/models/concerns/milestoneish_spec.rb96
-rw-r--r--spec/models/concerns/noteable_spec.rb22
-rw-r--r--spec/models/concerns/optionally_search_spec.rb30
-rw-r--r--spec/models/concerns/participable_spec.rb20
-rw-r--r--spec/models/concerns/presentable_spec.rb10
-rw-r--r--spec/models/concerns/project_features_compatibility_spec.rb4
-rw-r--r--spec/models/concerns/prometheus_adapter_spec.rb32
-rw-r--r--spec/models/concerns/protected_ref_access_spec.rb10
-rw-r--r--spec/models/concerns/reactive_caching_spec.rb52
-rw-r--r--spec/models/concerns/redactable_spec.rb40
-rw-r--r--spec/models/concerns/redis_cacheable_spec.rb38
-rw-r--r--spec/models/concerns/relative_positioning_spec.rb74
-rw-r--r--spec/models/concerns/resolvable_discussion_spec.rb2
-rw-r--r--spec/models/concerns/resolvable_note_spec.rb42
-rw-r--r--spec/models/concerns/routable_spec.rb88
-rw-r--r--spec/models/concerns/sha_attribute_spec.rb34
-rw-r--r--spec/models/concerns/sortable_spec.rb88
-rw-r--r--spec/models/concerns/spammable_spec.rb24
-rw-r--r--spec/models/concerns/strip_attribute_spec.rb6
-rw-r--r--spec/models/concerns/subscribable_spec.rb62
-rw-r--r--spec/models/concerns/token_authenticatable_spec.rb164
-rw-r--r--spec/models/concerns/token_authenticatable_strategies/base_spec.rb36
-rw-r--r--spec/models/concerns/token_authenticatable_strategies/encrypted_spec.rb132
-rw-r--r--spec/models/concerns/triggerable_hooks_spec.rb36
-rw-r--r--spec/models/concerns/uniquify_spec.rb36
54 files changed, 1295 insertions, 1290 deletions
diff --git a/spec/models/concerns/access_requestable_spec.rb b/spec/models/concerns/access_requestable_spec.rb
index 04d6cfa2c02..461d7a17de9 100644
--- a/spec/models/concerns/access_requestable_spec.rb
+++ b/spec/models/concerns/access_requestable_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
+require "spec_helper"
describe AccessRequestable do
- describe 'Group' do
- describe '#request_access' do
+ describe "Group" do
+ describe "#request_access" do
let(:group) { create(:group, :public, :access_requestable) }
let(:user) { create(:user) }
@@ -10,7 +10,7 @@ describe AccessRequestable do
it { expect(group.request_access(user).user).to eq(user) }
end
- describe '#access_requested?' do
+ describe "#access_requested?" do
let(:group) { create(:group, :public, :access_requestable) }
let(:user) { create(:user) }
@@ -22,15 +22,15 @@ describe AccessRequestable do
end
end
- describe 'Project' do
- describe '#request_access' do
+ describe "Project" do
+ describe "#request_access" do
let(:project) { create(:project, :public, :access_requestable) }
let(:user) { create(:user) }
it { expect(project.request_access(user)).to be_a(ProjectMember) }
end
- describe '#access_requested?' do
+ describe "#access_requested?" do
let(:project) { create(:project, :public, :access_requestable) }
let(:user) { create(:user) }
diff --git a/spec/models/concerns/avatarable_spec.rb b/spec/models/concerns/avatarable_spec.rb
index 1ea7f2b9985..245625b80bd 100644
--- a/spec/models/concerns/avatarable_spec.rb
+++ b/spec/models/concerns/avatarable_spec.rb
@@ -1,43 +1,43 @@
-require 'spec_helper'
+require "spec_helper"
describe Avatarable do
let(:project) { create(:project, :with_avatar) }
let(:gitlab_host) { "https://gitlab.example.com" }
let(:relative_url_root) { "/gitlab" }
- let(:asset_host) { 'https://gitlab-assets.example.com' }
+ let(:asset_host) { "https://gitlab-assets.example.com" }
before do
stub_config_setting(base_url: gitlab_host)
stub_config_setting(relative_url_root: relative_url_root)
end
- describe '#update' do
+ describe "#update" do
let(:validator) { project._validators[:avatar].detect { |v| v.is_a?(FileSizeValidator) } }
- context 'when avatar changed' do
- it 'validates the file size' do
+ context "when avatar changed" do
+ it "validates the file size" do
expect(validator).to receive(:validate_each).and_call_original
- project.update(avatar: 'uploads/avatar.png')
+ project.update(avatar: "uploads/avatar.png")
end
end
- context 'when avatar was not changed' do
- it 'skips validation of file size' do
+ context "when avatar was not changed" do
+ it "skips validation of file size" do
expect(validator).not_to receive(:validate_each)
- project.update(name: 'Hello world')
+ project.update(name: "Hello world")
end
end
end
- describe '#avatar_path' do
- context 'with caching enabled', :request_store do
+ describe "#avatar_path" do
+ context "with caching enabled", :request_store do
let!(:avatar_path) { [relative_url_root, project.avatar.local_url].join }
let!(:avatar_url) { [gitlab_host, relative_url_root, project.avatar.local_url].join }
- it 'only calls local_url once' do
+ it "only calls local_url once" do
expect(project.avatar).to receive(:local_url).once.and_call_original
2.times do
@@ -45,21 +45,21 @@ describe Avatarable do
end
end
- it 'calls local_url twice for path and URLs' do
+ it "calls local_url twice for path and URLs" do
expect(project.avatar).to receive(:local_url).exactly(2).times.and_call_original
expect(project.avatar_path(only_path: true)).to eq(avatar_path)
expect(project.avatar_path(only_path: false)).to eq(avatar_url)
end
- it 'calls local_url twice for different sizes' do
+ it "calls local_url twice for different sizes" do
expect(project.avatar).to receive(:local_url).exactly(2).times.and_call_original
expect(project.avatar_path).to eq(avatar_path)
expect(project.avatar_path(size: 40)).to eq(avatar_path + "?width=40")
end
- it 'handles unpersisted objects' do
+ it "handles unpersisted objects" do
new_project = build(:project, :with_avatar)
path = [relative_url_root, new_project.avatar.local_url].join
expect(new_project.avatar).to receive(:local_url).exactly(2).times.and_call_original
@@ -96,11 +96,11 @@ describe Avatarable do
let(:avatar_path) { (avatar_path_prefix + [project.avatar.local_url]).join }
- it 'returns the expected avatar path' do
+ it "returns the expected avatar path" do
expect(project.avatar_path(only_path: only_path)).to eq(avatar_path)
end
- it 'returns the expected avatar path with width parameter' do
+ it "returns the expected avatar path with width parameter" do
expect(project.avatar_path(only_path: only_path, size: 128)).to eq(avatar_path + "?width=128")
end
@@ -111,7 +111,7 @@ describe Avatarable do
project.avatar.migrate!(ObjectStorage::Store::REMOTE)
end
- it 'returns the expected avatar path' do
+ it "returns the expected avatar path" do
expect(project.avatar_url(only_path: only_path)).to eq(avatar_path)
end
end
diff --git a/spec/models/concerns/awardable_spec.rb b/spec/models/concerns/awardable_spec.rb
index 5713106418d..54623244b7d 100644
--- a/spec/models/concerns/awardable_spec.rb
+++ b/spec/models/concerns/awardable_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Awardable do
let!(:issue) { create(:issue) }
@@ -62,18 +62,18 @@ describe Awardable do
end
end
- describe '#user_can_award?' do
+ describe "#user_can_award?" do
let(:user) { create(:user) }
before do
issue.project.add_guest(user)
end
- it 'is truthy when the user is allowed to award emoji' do
+ it "is truthy when the user is allowed to award emoji" do
expect(issue.user_can_award?(user)).to be_truthy
end
- it 'is falsy when the project is archived' do
+ it "is falsy when the project is archived" do
issue.project.update!(archived: true)
expect(issue.user_can_award?(user)).to be_falsy
@@ -90,10 +90,10 @@ describe Awardable do
end
end
- describe 'querying award_emoji on an Awardable' do
+ describe "querying award_emoji on an Awardable" do
let(:issue) { create(:issue) }
- it 'sorts in ascending fashion' do
+ it "sorts in ascending fashion" do
create_list(:award_emoji, 3, awardable: issue)
expect(issue.award_emoji).to eq issue.award_emoji.sort_by(&:id)
diff --git a/spec/models/concerns/batch_destroy_dependent_associations_spec.rb b/spec/models/concerns/batch_destroy_dependent_associations_spec.rb
index e5392fe0462..14dced7846e 100644
--- a/spec/models/concerns/batch_destroy_dependent_associations_spec.rb
+++ b/spec/models/concerns/batch_destroy_dependent_associations_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
+require "spec_helper"
describe BatchDestroyDependentAssociations do
class TestProject < ActiveRecord::Base
- self.table_name = 'projects'
+ self.table_name = "projects"
has_many :builds, dependent: :destroy
has_many :notification_settings, as: :source, dependent: :delete_all
@@ -12,21 +12,21 @@ describe BatchDestroyDependentAssociations do
include BatchDestroyDependentAssociations
end
- describe '#dependent_associations_to_destroy' do
+ describe "#dependent_associations_to_destroy" do
set(:project) { TestProject.new }
- it 'returns the right associations' do
+ it "returns the right associations" do
expect(project.dependent_associations_to_destroy.map(&:name)).to match_array([:builds])
end
end
- describe '#destroy_dependent_associations_in_batches' do
+ describe "#destroy_dependent_associations_in_batches" do
set(:project) { create(:project) }
set(:build) { create(:ci_build, project: project) }
set(:notification_setting) { create(:notification_setting, project: project) }
let!(:todos) { create(:todo, project: project) }
- it 'destroys multiple builds' do
+ it "destroys multiple builds" do
create(:ci_build, project: project)
expect(Ci::Build.count).to eq(2)
@@ -36,7 +36,7 @@ describe BatchDestroyDependentAssociations do
expect(Ci::Build.count).to eq(0)
end
- it 'destroys builds in batches' do
+ it "destroys builds in batches" do
expect(project).to receive_message_chain(:builds, :find_each).and_yield(build)
expect(build).to receive(:destroy).and_call_original
@@ -48,7 +48,7 @@ describe BatchDestroyDependentAssociations do
expect(NotificationSetting.count).to eq(User.count)
end
- it 'excludes associations' do
+ it "excludes associations" do
project.destroy_dependent_associations_in_batches(exclude: [:builds])
expect(Ci::Build.count).to eq(1)
diff --git a/spec/models/concerns/blob_language_from_git_attributes_spec.rb b/spec/models/concerns/blob_language_from_git_attributes_spec.rb
index 7f05073b08e..619e3e17498 100644
--- a/spec/models/concerns/blob_language_from_git_attributes_spec.rb
+++ b/spec/models/concerns/blob_language_from_git_attributes_spec.rb
@@ -1,22 +1,22 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe BlobLanguageFromGitAttributes do
include FakeBlobHelpers
let(:project) { build(:project, :repository) }
- describe '#language_from_gitattributes' do
- subject(:blob) { fake_blob(path: 'file.md') }
+ describe "#language_from_gitattributes" do
+ subject(:blob) { fake_blob(path: "file.md") }
- it 'returns return value from gitattribute' do
- expect(blob.project.repository).to receive(:gitattribute).with(blob.path, 'gitlab-language').and_return('erb?parent=json')
+ it "returns return value from gitattribute" do
+ expect(blob.project.repository).to receive(:gitattribute).with(blob.path, "gitlab-language").and_return("erb?parent=json")
- expect(blob.language_from_gitattributes).to eq('erb?parent=json')
+ expect(blob.language_from_gitattributes).to eq("erb?parent=json")
end
- it 'returns nil if project is absent' do
+ it "returns nil if project is absent" do
allow(blob).to receive(:project).and_return(nil)
expect(blob.language_from_gitattributes).to eq(nil)
diff --git a/spec/models/concerns/blocks_json_serialization_spec.rb b/spec/models/concerns/blocks_json_serialization_spec.rb
index 5906b588d0e..a95d2379696 100644
--- a/spec/models/concerns/blocks_json_serialization_spec.rb
+++ b/spec/models/concerns/blocks_json_serialization_spec.rb
@@ -1,16 +1,16 @@
-require 'rails_helper'
+require "rails_helper"
describe BlocksJsonSerialization do
- DummyModel = Class.new do
+ DummyModel = Class.new {
include BlocksJsonSerialization
- end
+ }
- it 'blocks as_json' do
+ it "blocks as_json" do
expect { DummyModel.new.as_json }
.to raise_error(described_class::JsonSerializationError, /DummyModel/)
end
- it 'blocks to_json' do
+ it "blocks to_json" do
expect { DummyModel.new.to_json }
.to raise_error(described_class::JsonSerializationError, /DummyModel/)
end
diff --git a/spec/models/concerns/cache_markdown_field_spec.rb b/spec/models/concerns/cache_markdown_field_spec.rb
index 447279f19a8..e89dd5d3fc4 100644
--- a/spec/models/concerns/cache_markdown_field_spec.rb
+++ b/spec/models/concerns/cache_markdown_field_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe CacheMarkdownField do
# The minimum necessary ActiveModel to test this concern
@@ -70,10 +70,10 @@ describe CacheMarkdownField do
Class.new(ThingWithMarkdownFields) { add_attr(new_attr) }
end
- let(:markdown) { '`Foo`' }
+ let(:markdown) { "`Foo`" }
let(:html) { '<p dir="auto"><code>Foo</code></p>' }
- let(:updated_markdown) { '`Bar`' }
+ let(:updated_markdown) { "`Bar`" }
let(:updated_html) { '<p dir="auto"><code>Bar</code></p>' }
let(:thing) { ThingWithMarkdownFields.new(foo: markdown, foo_html: html, cached_markdown_version: cache_version) }
@@ -83,13 +83,13 @@ describe CacheMarkdownField do
stub_commonmark_sourcepos_disabled
end
- describe '.attributes' do
- it 'excludes cache attributes' do
+ describe ".attributes" do
+ it "excludes cache attributes" do
expect(thing.attributes.keys.sort).to eq(%w[bar baz foo])
end
end
- context 'an unchanged markdown field' do
+ context "an unchanged markdown field" do
before do
thing.foo = thing.foo
thing.save
@@ -101,7 +101,7 @@ describe CacheMarkdownField do
it { expect(thing.cached_markdown_version).to eq(cache_version) }
end
- context 'a changed markdown field' do
+ context "a changed markdown field" do
let(:thing) { ThingWithMarkdownFields.new(foo: markdown, foo_html: html, cached_markdown_version: cache_version - 1) }
before do
@@ -113,50 +113,50 @@ describe CacheMarkdownField do
it { expect(thing.cached_markdown_version).to eq(cache_version) }
end
- context 'when a markdown field is set repeatedly to an empty string' do
+ context "when a markdown field is set repeatedly to an empty string" do
it do
expect(thing).to receive(:refresh_markdown_cache).once
- thing.foo = ''
+ thing.foo = ""
thing.save
- thing.foo = ''
+ thing.foo = ""
thing.save
end
end
- context 'when a markdown field is set repeatedly to a string which renders as empty html' do
+ context "when a markdown field is set repeatedly to a string which renders as empty html" do
it do
expect(thing).to receive(:refresh_markdown_cache).once
- thing.foo = '[//]: # (This is also a comment.)'
+ thing.foo = "[//]: # (This is also a comment.)"
thing.save
- thing.foo = '[//]: # (This is also a comment.)'
+ thing.foo = "[//]: # (This is also a comment.)"
thing.save
end
end
- context 'when a markdown field and html field are both changed' do
+ context "when a markdown field and html field are both changed" do
it do
expect(thing).not_to receive(:refresh_markdown_cache)
- thing.foo = '_look over there!_'
- thing.foo_html = '<em>look over there!</em>'
+ thing.foo = "_look over there!_"
+ thing.foo_html = "<em>look over there!</em>"
thing.save
end
end
- context 'a non-markdown field changed' do
+ context "a non-markdown field changed" do
let(:thing) { ThingWithMarkdownFields.new(foo: markdown, foo_html: html, cached_markdown_version: cache_version - 1) }
before do
- thing.bar = 'OK'
+ thing.bar = "OK"
thing.save
end
- it { expect(thing.bar).to eq('OK') }
+ it { expect(thing.bar).to eq("OK") }
it { expect(thing.foo).to eq(markdown) }
it { expect(thing.foo_html).to eq(html) }
it { expect(thing.cached_markdown_version).to eq(cache_version) }
end
- context 'version is out of date' do
+ context "version is out of date" do
let(:thing) { ThingWithMarkdownFields.new(foo: updated_markdown, foo_html: html, cached_markdown_version: nil) }
before do
@@ -167,90 +167,90 @@ describe CacheMarkdownField do
it { expect(thing.cached_markdown_version).to eq(cache_version) }
end
- describe '#cached_html_up_to_date?' do
+ describe "#cached_html_up_to_date?" do
let(:thing) { ThingWithMarkdownFields.new(foo: markdown, foo_html: html, cached_markdown_version: cache_version) }
subject { thing.cached_html_up_to_date?(:foo) }
- it 'returns false when the version is absent' do
+ it "returns false when the version is absent" do
thing.cached_markdown_version = nil
is_expected.to be_falsy
end
- it 'returns false when the cached version is too old' do
+ it "returns false when the cached version is too old" do
thing.cached_markdown_version = cache_version - 1
is_expected.to be_falsy
end
- it 'returns false when the cached version is in future' do
+ it "returns false when the cached version is in future" do
thing.cached_markdown_version = cache_version + 1
is_expected.to be_falsy
end
- it 'returns false when the local version was bumped' do
+ it "returns false when the local version was bumped" do
allow(Gitlab::CurrentSettings.current_application_settings).to receive(:local_markdown_version).and_return(2)
thing.cached_markdown_version = cache_version
is_expected.to be_falsy
end
- it 'returns true when the local version is default' do
+ it "returns true when the local version is default" do
thing.cached_markdown_version = cache_version
is_expected.to be_truthy
end
- it 'returns true when the cached version is just right' do
+ it "returns true when the cached version is just right" do
allow(Gitlab::CurrentSettings.current_application_settings).to receive(:local_markdown_version).and_return(2)
thing.cached_markdown_version = cache_version + 2
is_expected.to be_truthy
end
- it 'returns false if markdown has been changed but html has not' do
+ it "returns false if markdown has been changed but html has not" do
thing.foo = updated_html
is_expected.to be_falsy
end
- it 'returns true if markdown has not been changed but html has' do
+ it "returns true if markdown has not been changed but html has" do
thing.foo_html = updated_html
is_expected.to be_truthy
end
- it 'returns true if markdown and html have both been changed' do
+ it "returns true if markdown and html have both been changed" do
thing.foo = updated_markdown
thing.foo_html = updated_html
is_expected.to be_truthy
end
- it 'returns false if the markdown field is set but the html is not' do
+ it "returns false if the markdown field is set but the html is not" do
thing.foo_html = nil
is_expected.to be_falsy
end
end
- describe '#latest_cached_markdown_version' do
+ describe "#latest_cached_markdown_version" do
subject { thing.latest_cached_markdown_version }
- it 'returns default version' do
+ it "returns default version" do
thing.cached_markdown_version = nil
is_expected.to eq(cache_version)
end
end
- describe '#refresh_markdown_cache' do
+ describe "#refresh_markdown_cache" do
before do
thing.foo = updated_markdown
end
- it 'fills all html fields' do
+ it "fills all html fields" do
thing.refresh_markdown_cache
expect(thing.foo_html).to eq(updated_html)
@@ -258,13 +258,13 @@ describe CacheMarkdownField do
expect(thing.baz_html_changed?).to be_truthy
end
- it 'does not save the result' do
+ it "does not save the result" do
expect(thing).not_to receive(:update_columns)
thing.refresh_markdown_cache
end
- it 'updates the markdown cache version' do
+ it "updates the markdown cache version" do
thing.cached_markdown_version = nil
thing.refresh_markdown_cache
@@ -272,14 +272,14 @@ describe CacheMarkdownField do
end
end
- describe '#refresh_markdown_cache!' do
+ describe "#refresh_markdown_cache!" do
let(:thing) { ThingWithMarkdownFields.new(foo: markdown, foo_html: html, cached_markdown_version: cache_version) }
before do
thing.foo = updated_markdown
end
- it 'fills all html fields' do
+ it "fills all html fields" do
thing.refresh_markdown_cache!
expect(thing.foo_html).to eq(updated_html)
@@ -287,14 +287,14 @@ describe CacheMarkdownField do
expect(thing.baz_html_changed?).to be_truthy
end
- it 'skips saving if not persisted' do
+ it "skips saving if not persisted" do
expect(thing).to receive(:persisted?).and_return(false)
expect(thing).not_to receive(:update_columns)
thing.refresh_markdown_cache!
end
- it 'saves the changes using #update_columns' do
+ it "saves the changes using #update_columns" do
expect(thing).to receive(:persisted?).and_return(true)
expect(thing).to receive(:update_columns)
.with("foo_html" => updated_html, "baz_html" => "", "cached_markdown_version" => cache_version)
@@ -303,45 +303,45 @@ describe CacheMarkdownField do
end
end
- describe '#banzai_render_context' do
+ describe "#banzai_render_context" do
subject(:context) { thing.banzai_render_context(:foo) }
- it 'sets project to nil if the object lacks a project' do
+ it "sets project to nil if the object lacks a project" do
is_expected.to have_key(:project)
expect(context[:project]).to be_nil
end
- it 'excludes author if the object lacks an author' do
+ it "excludes author if the object lacks an author" do
is_expected.not_to have_key(:author)
end
- it 'raises if the context for an unrecognised field is requested' do
+ it "raises if the context for an unrecognised field is requested" do
expect { thing.banzai_render_context(:not_found) }.to raise_error(ArgumentError)
end
- it 'includes the pipeline' do
+ it "includes the pipeline" do
baz = thing.banzai_render_context(:baz)
expect(baz[:pipeline]).to eq(:single_line)
end
- it 'returns copies of the context template' do
+ it "returns copies of the context template" do
template = thing.cached_markdown_fields[:baz]
copy = thing.banzai_render_context(:baz)
expect(copy).not_to be(template)
end
- context 'with a project' do
+ context "with a project" do
let(:project) { create(:project, group: create(:group)) }
let(:thing) { thing_subclass(:project).new(foo: markdown, foo_html: html, project: project) }
- it 'sets the project in the context' do
+ it "sets the project in the context" do
is_expected.to have_key(:project)
expect(context[:project]).to eq(project)
end
- it 'invalidates the cache when project changes' do
+ it "invalidates the cache when project changes" do
thing.project = :new_project
allow(Banzai::Renderer).to receive(:cacheless_render_field).and_return(updated_html)
@@ -353,15 +353,15 @@ describe CacheMarkdownField do
end
end
- context 'with an author' do
+ context "with an author" do
let(:thing) { thing_subclass(:author).new(foo: markdown, foo_html: html, author: :author_value) }
- it 'sets the author in the context' do
+ it "sets the author in the context" do
is_expected.to have_key(:author)
expect(context[:author]).to eq(:author_value)
end
- it 'invalidates the cache when author changes' do
+ it "invalidates the cache when author changes" do
thing.author = :new_author
allow(Banzai::Renderer).to receive(:cacheless_render_field).and_return(updated_html)
diff --git a/spec/models/concerns/cacheable_attributes_spec.rb b/spec/models/concerns/cacheable_attributes_spec.rb
index 43a544cfe26..e8ef745e83d 100644
--- a/spec/models/concerns/cacheable_attributes_spec.rb
+++ b/spec/models/concerns/cacheable_attributes_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe CacheableAttributes do
let(:minimal_test_class) do
@@ -9,15 +9,15 @@ describe CacheableAttributes do
include CacheableAttributes
def self.name
- 'TestClass'
+ "TestClass"
end
def self.first
- @_first ||= new('foo' => 'a')
+ @_first ||= new("foo" => "a")
end
def self.last
- @_last ||= new('foo' => 'a', 'bar' => 'b')
+ @_last ||= new("foo" => "a", "bar" => "b")
end
def self.column_names
@@ -32,20 +32,20 @@ describe CacheableAttributes do
end
end
- shared_context 'with defaults' do
+ shared_context "with defaults" do
before do
minimal_test_class.define_singleton_method(:defaults) do
- { foo: 'a', bar: 'b', baz: 'c' }
+ {foo: "a", bar: "b", baz: "c"}
end
end
end
- describe '.current_without_cache' do
- it 'defaults to last' do
+ describe ".current_without_cache" do
+ it "defaults to last" do
expect(minimal_test_class.current_without_cache).to eq(minimal_test_class.last)
end
- it 'can be overridden' do
+ it "can be overridden" do
minimal_test_class.define_singleton_method(:current_without_cache) do
first
end
@@ -54,45 +54,45 @@ describe CacheableAttributes do
end
end
- describe '.cache_key' do
- it 'excludes cache attributes' do
+ describe ".cache_key" do
+ it "excludes cache attributes" do
expect(minimal_test_class.cache_key).to eq("TestClass:#{Gitlab::VERSION}:#{Rails.version}")
end
end
- describe '.defaults' do
- it 'defaults to {}' do
+ describe ".defaults" do
+ it "defaults to {}" do
expect(minimal_test_class.defaults).to eq({})
end
- context 'with defaults defined' do
- include_context 'with defaults'
+ context "with defaults defined" do
+ include_context "with defaults"
- it 'can be overridden' do
- expect(minimal_test_class.defaults).to eq({ foo: 'a', bar: 'b', baz: 'c' })
+ it "can be overridden" do
+ expect(minimal_test_class.defaults).to eq({foo: "a", bar: "b", baz: "c"})
end
end
end
- describe '.build_from_defaults' do
- include_context 'with defaults'
+ describe ".build_from_defaults" do
+ include_context "with defaults"
- context 'without any attributes given' do
- it 'intializes a new object with the defaults' do
+ context "without any attributes given" do
+ it "intializes a new object with the defaults" do
expect(minimal_test_class.build_from_defaults.attributes).to eq(minimal_test_class.defaults.stringify_keys)
end
end
- context 'with attributes given' do
- it 'intializes a new object with the given attributes merged into the defaults' do
- expect(minimal_test_class.build_from_defaults(foo: 'd').attributes['foo']).to eq('d')
+ context "with attributes given" do
+ it "intializes a new object with the given attributes merged into the defaults" do
+ expect(minimal_test_class.build_from_defaults(foo: "d").attributes["foo"]).to eq("d")
end
end
- describe 'edge cases on concrete implementations' do
- describe '.build_from_defaults' do
- context 'without any attributes given' do
- it 'intializes all attributes even if they are nil' do
+ describe "edge cases on concrete implementations" do
+ describe ".build_from_defaults" do
+ context "without any attributes given" do
+ it "intializes all attributes even if they are nil" do
record = ApplicationSetting.build_from_defaults
expect(record).not_to be_persisted
@@ -103,31 +103,31 @@ describe CacheableAttributes do
end
end
- describe '.current', :use_clean_rails_memory_store_caching do
- context 'redis unavailable' do
+ describe ".current", :use_clean_rails_memory_store_caching do
+ context "redis unavailable" do
before do
allow(minimal_test_class).to receive(:last).and_return(:last)
expect(Rails.cache).to receive(:read).with(minimal_test_class.cache_key).and_raise(Redis::BaseError)
end
- context 'in production environment' do
+ context "in production environment" do
before do
expect(Rails.env).to receive(:production?).and_return(true)
end
- it 'returns an uncached record and logs a warning' do
+ it "returns an uncached record and logs a warning" do
expect(Rails.logger).to receive(:warn).with("Cached record for TestClass couldn't be loaded, falling back to uncached record: Redis::BaseError")
expect(minimal_test_class.current).to eq(:last)
end
end
- context 'in other environments' do
+ context "in other environments" do
before do
expect(Rails.env).to receive(:production?).and_return(false)
end
- it 'returns an uncached record and logs a warning' do
+ it "returns an uncached record and logs a warning" do
expect(Rails.logger).not_to receive(:warn)
expect { minimal_test_class.current }.to raise_error(Redis::BaseError)
@@ -135,8 +135,8 @@ describe CacheableAttributes do
end
end
- context 'when a record is not yet present' do
- it 'does not cache nil object' do
+ context "when a record is not yet present" do
+ it "does not cache nil object" do
# when missing settings a nil object is returned, but not cached
allow(ApplicationSetting).to receive(:current_without_cache).twice.and_return(nil)
@@ -144,7 +144,7 @@ describe CacheableAttributes do
expect(Rails.cache.exist?(ApplicationSetting.cache_key)).to be(false)
end
- it 'caches non-nil object' do
+ it "caches non-nil object" do
create(:application_setting)
expect(ApplicationSetting.current).to eq(ApplicationSetting.last)
@@ -157,13 +157,13 @@ describe CacheableAttributes do
end
end
- describe 'edge cases' do
- describe 'caching behavior', :use_clean_rails_memory_store_caching do
+ describe "edge cases" do
+ describe "caching behavior", :use_clean_rails_memory_store_caching do
before do
stub_commonmark_sourcepos_disabled
end
- it 'retrieves upload fields properly' do
+ it "retrieves upload fields properly" do
ar_record = create(:appearance, :with_logo)
ar_record.cache!
@@ -171,22 +171,22 @@ describe CacheableAttributes do
expect(cache_record).to be_persisted
expect(cache_record.logo).to be_an(AttachmentUploader)
- expect(cache_record.logo.url).to end_with('/dk.png')
+ expect(cache_record.logo.url).to end_with("/dk.png")
end
- it 'retrieves markdown fields properly' do
- ar_record = create(:appearance, description: '**Hello**')
+ it "retrieves markdown fields properly" do
+ ar_record = create(:appearance, description: "**Hello**")
ar_record.cache!
cache_record = Appearance.current
- expect(cache_record.description).to eq('**Hello**')
+ expect(cache_record.description).to eq("**Hello**")
expect(cache_record.description_html).to eq('<p dir="auto"><strong>Hello</strong></p>')
end
end
end
- it 'uses RequestStore in addition to Rails.cache', :request_store do
+ it "uses RequestStore in addition to Rails.cache", :request_store do
# Warm up the cache
create(:application_setting).cache!
@@ -196,39 +196,39 @@ describe CacheableAttributes do
end
end
- describe '.cached', :use_clean_rails_memory_store_caching do
- context 'when cache is cold' do
- it 'returns nil' do
+ describe ".cached", :use_clean_rails_memory_store_caching do
+ context "when cache is cold" do
+ it "returns nil" do
expect(minimal_test_class.cached).to be_nil
end
end
- context 'when cached is warm' do
+ context "when cached is warm" do
before do
# Warm up the cache
create(:appearance).cache!
end
- it 'retrieves the record from cache' do
+ it "retrieves the record from cache" do
expect(ActiveRecord::QueryRecorder.new { Appearance.cached }.count).to eq(0)
expect(Appearance.cached).to eq(Appearance.current_without_cache)
end
end
end
- describe '#cache!', :use_clean_rails_memory_store_caching do
+ describe "#cache!", :use_clean_rails_memory_store_caching do
let(:record) { create(:appearance) }
- it 'caches the attributes' do
+ it "caches the attributes" do
record.cache!
expect(Rails.cache.read(Appearance.cache_key)).to eq(record)
end
- describe 'edge cases' do
+ describe "edge cases" do
let(:record) { create(:appearance) }
- it 'caches the attributes' do
+ it "caches the attributes" do
record.cache!
expect(Rails.cache.read(Appearance.cache_key)).to eq(record)
diff --git a/spec/models/concerns/case_sensitivity_spec.rb b/spec/models/concerns/case_sensitivity_spec.rb
index 1bf6c9b3404..98d9593f7a2 100644
--- a/spec/models/concerns/case_sensitivity_spec.rb
+++ b/spec/models/concerns/case_sensitivity_spec.rb
@@ -1,49 +1,49 @@
-require 'spec_helper'
+require "spec_helper"
describe CaseSensitivity do
- describe '.iwhere' do
+ describe ".iwhere" do
let(:connection) { ActiveRecord::Base.connection }
let(:model) do
Class.new(ActiveRecord::Base) do
include CaseSensitivity
- self.table_name = 'namespaces'
+ self.table_name = "namespaces"
end
end
- let!(:model_1) { model.create(path: 'mOdEl-1', name: 'mOdEl 1') }
- let!(:model_2) { model.create(path: 'mOdEl-2', name: 'mOdEl 2') }
+ let!(:model_1) { model.create(path: "mOdEl-1", name: "mOdEl 1") }
+ let!(:model_2) { model.create(path: "mOdEl-2", name: "mOdEl 2") }
- it 'finds a single instance by a single attribute regardless of case' do
- expect(model.iwhere(path: 'MODEL-1')).to contain_exactly(model_1)
+ it "finds a single instance by a single attribute regardless of case" do
+ expect(model.iwhere(path: "MODEL-1")).to contain_exactly(model_1)
end
- it 'finds multiple instances by a single attribute regardless of case' do
- expect(model.iwhere(path: %w(MODEL-1 model-2))).to contain_exactly(model_1, model_2)
+ it "finds multiple instances by a single attribute regardless of case" do
+ expect(model.iwhere(path: %w[MODEL-1 model-2])).to contain_exactly(model_1, model_2)
end
- it 'finds instances by multiple attributes' do
- expect(model.iwhere(path: %w(MODEL-1 model-2), name: 'model 1'))
+ it "finds instances by multiple attributes" do
+ expect(model.iwhere(path: %w[MODEL-1 model-2], name: "model 1"))
.to contain_exactly(model_1)
end
# Using `mysql` & `postgresql` metadata-tags here because both adapters build
# the query slightly differently
- context 'for MySQL', :mysql do
- it 'builds a simple query' do
- query = model.iwhere(path: %w(MODEL-1 model-2), name: 'model 1').to_sql
+ context "for MySQL", :mysql do
+ it "builds a simple query" do
+ query = model.iwhere(path: %w[MODEL-1 model-2], name: "model 1").to_sql
expected_query = <<~QRY.strip
- SELECT `namespaces`.* FROM `namespaces` WHERE (`namespaces`.`path` IN ('MODEL-1', 'model-2')) AND (`namespaces`.`name` = 'model 1')
+ SELECT `namespaces`.* FROM `namespaces` WHERE (`namespaces`.`path` IN ('MODEL-1', 'model-2')) AND (`namespaces`.`name` = 'model 1')
QRY
expect(query).to eq(expected_query)
end
end
- context 'for PostgreSQL', :postgresql do
- it 'builds a query using LOWER' do
- query = model.iwhere(path: %w(MODEL-1 model-2), name: 'model 1').to_sql
+ context "for PostgreSQL", :postgresql do
+ it "builds a query using LOWER" do
+ query = model.iwhere(path: %w[MODEL-1 model-2], name: "model 1").to_sql
expected_query = <<~QRY.strip
- SELECT \"namespaces\".* FROM \"namespaces\" WHERE (LOWER(\"namespaces\".\"path\") IN (LOWER('MODEL-1'), LOWER('model-2'))) AND (LOWER(\"namespaces\".\"name\") = LOWER('model 1'))
+ SELECT \"namespaces\".* FROM \"namespaces\" WHERE (LOWER(\"namespaces\".\"path\") IN (LOWER('MODEL-1'), LOWER('model-2'))) AND (LOWER(\"namespaces\".\"name\") = LOWER('model 1'))
QRY
expect(query).to eq(expected_query)
diff --git a/spec/models/concerns/chronic_duration_attribute_spec.rb b/spec/models/concerns/chronic_duration_attribute_spec.rb
index 51221e07ca3..5f90bfa09d0 100644
--- a/spec/models/concerns/chronic_duration_attribute_spec.rb
+++ b/spec/models/concerns/chronic_duration_attribute_spec.rb
@@ -1,18 +1,18 @@
-require 'spec_helper'
+require "spec_helper"
-shared_examples 'ChronicDurationAttribute reader' do
- it 'contains dynamically created reader method' do
+shared_examples "ChronicDurationAttribute reader" do
+ it "contains dynamically created reader method" do
expect(subject.class).to be_public_method_defined(virtual_field)
end
- it 'outputs chronic duration formatted value' do
+ it "outputs chronic duration formatted value" do
subject.send("#{source_field}=", 120)
- expect(subject.send(virtual_field)).to eq('2m')
+ expect(subject.send(virtual_field)).to eq("2m")
end
- context 'when value is set to nil' do
- it 'outputs nil' do
+ context "when value is set to nil" do
+ it "outputs nil" do
subject.send("#{source_field}=", nil)
expect(subject.send(virtual_field)).to be_nil
@@ -20,69 +20,69 @@ shared_examples 'ChronicDurationAttribute reader' do
end
end
-shared_examples 'ChronicDurationAttribute writer' do
- it 'contains dynamically created writer method' do
+shared_examples "ChronicDurationAttribute writer" do
+ it "contains dynamically created writer method" do
expect(subject.class).to be_public_method_defined("#{virtual_field}=")
end
before do
- subject.send("#{virtual_field}=", '10m')
+ subject.send("#{virtual_field}=", "10m")
end
- it 'parses chronic duration input' do
+ it "parses chronic duration input" do
expect(subject.send(source_field)).to eq(600)
end
- it 'passes validation' do
+ it "passes validation" do
expect(subject.valid?).to be_truthy
end
- context 'when negative input is used' do
+ context "when negative input is used" do
before do
subject.send("#{source_field}=", 3600)
end
it "doesn't raise exception" do
- expect { subject.send("#{virtual_field}=", '-10m') }.not_to raise_error
+ expect { subject.send("#{virtual_field}=", "-10m") }.not_to raise_error
end
it "doesn't change value" do
- expect { subject.send("#{virtual_field}=", '-10m') }.not_to change { subject.send(source_field) }
+ expect { subject.send("#{virtual_field}=", "-10m") }.not_to change { subject.send(source_field) }
end
it "doesn't pass validation" do
- subject.send("#{virtual_field}=", '-10m')
+ subject.send("#{virtual_field}=", "-10m")
expect(subject.valid?).to be_falsey
expect(subject.errors&.messages)
- .to include(base: ['Maximum job timeout has a value which could not be accepted'])
+ .to include(base: ["Maximum job timeout has a value which could not be accepted"])
end
end
- context 'when empty input is used' do
+ context "when empty input is used" do
before do
- subject.send("#{virtual_field}=", '')
+ subject.send("#{virtual_field}=", "")
end
- it 'writes default value' do
+ it "writes default value" do
expect(subject.send(source_field)).to eq(default_value)
end
- it 'passes validation' do
+ it "passes validation" do
expect(subject.valid?).to be_truthy
end
end
- context 'when nil input is used' do
+ context "when nil input is used" do
before do
subject.send("#{virtual_field}=", nil)
end
- it 'writes default value' do
+ it "writes default value" do
expect(subject.send(source_field)).to eq(default_value)
end
- it 'passes validation' do
+ it "passes validation" do
expect(subject.valid?).to be_truthy
end
@@ -92,31 +92,31 @@ shared_examples 'ChronicDurationAttribute writer' do
end
end
-describe 'ChronicDurationAttribute' do
- context 'when default value is not set' do
+describe "ChronicDurationAttribute" do
+ context "when default value is not set" do
let(:source_field) {:maximum_timeout}
let(:virtual_field) {:maximum_timeout_human_readable}
let(:default_value) { nil }
subject { create(:ci_runner) }
- it_behaves_like 'ChronicDurationAttribute reader'
- it_behaves_like 'ChronicDurationAttribute writer'
+ it_behaves_like "ChronicDurationAttribute reader"
+ it_behaves_like "ChronicDurationAttribute writer"
end
- context 'when default value is set' do
+ context "when default value is set" do
let(:source_field) {:build_timeout}
let(:virtual_field) {:build_timeout_human_readable}
let(:default_value) { 3600 }
subject { create(:project) }
- it_behaves_like 'ChronicDurationAttribute reader'
- it_behaves_like 'ChronicDurationAttribute writer'
+ it_behaves_like "ChronicDurationAttribute reader"
+ it_behaves_like "ChronicDurationAttribute writer"
end
end
-describe 'ChronicDurationAttribute - reader' do
+describe "ChronicDurationAttribute - reader" do
let(:source_field) {:timeout}
let(:virtual_field) {:timeout_human_readable}
@@ -126,5 +126,5 @@ describe 'ChronicDurationAttribute - reader' do
expect(subject.class).not_to be_public_method_defined("#{virtual_field}=")
end
- it_behaves_like 'ChronicDurationAttribute reader'
+ it_behaves_like "ChronicDurationAttribute reader"
end
diff --git a/spec/models/concerns/deployable_spec.rb b/spec/models/concerns/deployable_spec.rb
index 6951be903fe..af029db6763 100644
--- a/spec/models/concerns/deployable_spec.rb
+++ b/spec/models/concerns/deployable_spec.rb
@@ -1,7 +1,7 @@
-require 'rails_helper'
+require "rails_helper"
describe Deployable do
- describe '#create_deployment' do
+ describe "#create_deployment" do
let(:deployment) { job.deployment }
let(:environment) { deployment&.environment }
@@ -9,63 +9,64 @@ describe Deployable do
job.reload
end
- context 'when the deployable object will deploy to production' do
+ context "when the deployable object will deploy to production" do
let!(:job) { create(:ci_build, :start_review_app) }
- it 'creates a deployment and environment record' do
+ it "creates a deployment and environment record" do
expect(deployment.project).to eq(job.project)
expect(deployment.ref).to eq(job.ref)
expect(deployment.tag).to eq(job.tag)
expect(deployment.sha).to eq(job.sha)
expect(deployment.user).to eq(job.user)
expect(deployment.deployable).to eq(job)
- expect(deployment.on_stop).to eq('stop_review_app')
- expect(environment.name).to eq('review/master')
+ expect(deployment.on_stop).to eq("stop_review_app")
+ expect(environment.name).to eq("review/master")
end
end
- context 'when the deployable object will stop an environment' do
+ context "when the deployable object will stop an environment" do
let!(:job) { create(:ci_build, :stop_review_app) }
- it 'does not create a deployment record' do
+ it "does not create a deployment record" do
expect(deployment).to be_nil
end
end
- context 'when the deployable object has already had a deployment' do
+ context "when the deployable object has already had a deployment" do
let!(:job) { create(:ci_build, :start_review_app, deployment: race_deployment) }
let!(:race_deployment) { create(:deployment, :success) }
- it 'does not create a new deployment' do
+ it "does not create a new deployment" do
expect(deployment).to eq(race_deployment)
end
end
- context 'when the deployable object will not deploy' do
+ context "when the deployable object will not deploy" do
let!(:job) { create(:ci_build) }
- it 'does not create a deployment and environment record' do
+ it "does not create a deployment and environment record" do
expect(deployment).to be_nil
expect(environment).to be_nil
end
end
- context 'when environment scope contains invalid character' do
+ context "when environment scope contains invalid character" do
let(:job) do
create(
:ci_build,
- name: 'job:deploy-to-test-site',
- environment: '$CI_JOB_NAME',
+ name: "job:deploy-to-test-site",
+ environment: "$CI_JOB_NAME",
options: {
environment: {
- name: '$CI_JOB_NAME',
- url: 'http://staging.example.com/$CI_JOB_NAME',
- on_stop: 'stop_review_app'
- }
- })
+ name: "$CI_JOB_NAME",
+ url: "http://staging.example.com/$CI_JOB_NAME",
+ on_stop: "stop_review_app",
+ },
+ }
+ )
end
- it 'does not create a deployment and environment record' do
+ it "does not create a deployment and environment record" do
expect(deployment).to be_nil
expect(environment).to be_nil
end
diff --git a/spec/models/concerns/deployment_platform_spec.rb b/spec/models/concerns/deployment_platform_spec.rb
index 19ab4382b53..d8fc7ce1e79 100644
--- a/spec/models/concerns/deployment_platform_spec.rb
+++ b/spec/models/concerns/deployment_platform_spec.rb
@@ -1,37 +1,37 @@
-require 'rails_helper'
+require "rails_helper"
describe DeploymentPlatform do
let(:project) { create(:project) }
- describe '#deployment_platform' do
+ describe "#deployment_platform" do
subject { project.deployment_platform }
- context 'with no Kubernetes configuration on CI/CD, no Kubernetes Service and a Kubernetes template configured' do
+ context "with no Kubernetes configuration on CI/CD, no Kubernetes Service and a Kubernetes template configured" do
let!(:kubernetes_service) { create(:kubernetes_service, template: true) }
- it 'returns a platform kubernetes' do
+ it "returns a platform kubernetes" do
expect(subject).to be_a_kind_of(Clusters::Platforms::Kubernetes)
end
- it 'creates a cluster and a platform kubernetes' do
+ it "creates a cluster and a platform kubernetes" do
expect { subject }
.to change { Clusters::Cluster.count }.by(1)
.and change { Clusters::Platforms::Kubernetes.count }.by(1)
end
- it 'includes appropriate attributes for Cluster' do
+ it "includes appropriate attributes for Cluster" do
cluster = subject.cluster
- expect(cluster.name).to eq('kubernetes-template')
+ expect(cluster.name).to eq("kubernetes-template")
expect(cluster.project).to eq(project)
- expect(cluster.provider_type).to eq('user')
- expect(cluster.platform_type).to eq('kubernetes')
+ expect(cluster.provider_type).to eq("user")
+ expect(cluster.platform_type).to eq("kubernetes")
end
- it 'creates a platform kubernetes' do
+ it "creates a platform kubernetes" do
expect { subject }.to change { Clusters::Platforms::Kubernetes.count }.by(1)
end
- it 'copies attributes from Clusters::Platform::Kubernetes template into the new Cluster::Platforms::Kubernetes' do
+ it "copies attributes from Clusters::Platform::Kubernetes template into the new Cluster::Platforms::Kubernetes" do
expect(subject.api_url).to eq(kubernetes_service.api_url)
expect(subject.ca_pem).to eq(kubernetes_service.ca_pem)
expect(subject.token).to eq(kubernetes_service.token)
@@ -39,32 +39,32 @@ describe DeploymentPlatform do
end
end
- context 'with no Kubernetes configuration on CI/CD, no Kubernetes Service and no Kubernetes template configured' do
+ context "with no Kubernetes configuration on CI/CD, no Kubernetes Service and no Kubernetes template configured" do
it { is_expected.to be_nil }
end
- context 'when project has configured kubernetes from CI/CD > Clusters' do
+ context "when project has configured kubernetes from CI/CD > Clusters" do
let!(:cluster) { create(:cluster, :provided_by_gcp, projects: [project]) }
let(:platform_kubernetes) { cluster.platform_kubernetes }
- it 'returns the Kubernetes platform' do
+ it "returns the Kubernetes platform" do
expect(subject).to eq(platform_kubernetes)
end
- context 'with a group level kubernetes cluster' do
+ context "with a group level kubernetes cluster" do
let(:group_cluster) { create(:cluster, :provided_by_gcp, :group) }
before do
project.update!(group: group_cluster.group)
end
- it 'returns the Kubernetes platform from the project cluster' do
+ it "returns the Kubernetes platform from the project cluster" do
expect(subject).to eq(platform_kubernetes)
end
end
end
- context 'when group has configured kubernetes cluster' do
+ context "when group has configured kubernetes cluster" do
let!(:group_cluster) { create(:cluster, :provided_by_gcp, :group) }
let(:group) { group_cluster.group }
@@ -72,11 +72,11 @@ describe DeploymentPlatform do
project.update!(group: group)
end
- it 'returns the Kubernetes platform' do
+ it "returns the Kubernetes platform" do
is_expected.to eq(group_cluster.platform_kubernetes)
end
- context 'when child group has configured kubernetes cluster', :nested_groups do
+ context "when child group has configured kubernetes cluster", :nested_groups do
let!(:child_group1_cluster) { create(:cluster, :provided_by_gcp, :group) }
let(:child_group1) { child_group1_cluster.group }
@@ -85,11 +85,11 @@ describe DeploymentPlatform do
child_group1.update!(parent: group)
end
- it 'returns the Kubernetes platform for the child group' do
+ it "returns the Kubernetes platform for the child group" do
is_expected.to eq(child_group1_cluster.platform_kubernetes)
end
- context 'deeply nested group' do
+ context "deeply nested group" do
let!(:child_group2_cluster) { create(:cluster, :provided_by_gcp, :group) }
let(:child_group2) { child_group2_cluster.group }
@@ -98,42 +98,42 @@ describe DeploymentPlatform do
project.update!(group: child_group2)
end
- it 'returns most nested group cluster Kubernetes platform' do
+ it "returns most nested group cluster Kubernetes platform" do
is_expected.to eq(child_group2_cluster.platform_kubernetes)
end
- context 'cluster in the middle of hierarchy is disabled' do
+ context "cluster in the middle of hierarchy is disabled" do
before do
child_group2_cluster.update!(enabled: false)
end
- it 'returns closest enabled Kubenetes platform' do
+ it "returns closest enabled Kubenetes platform" do
is_expected.to eq(child_group1_cluster.platform_kubernetes)
end
end
end
end
- context 'feature flag disabled' do
+ context "feature flag disabled" do
before do
stub_feature_flags(group_clusters: false)
end
- it 'returns nil' do
+ it "returns nil" do
is_expected.to be_nil
end
end
end
- context 'when user configured kubernetes integration from project services' do
+ context "when user configured kubernetes integration from project services" do
let!(:kubernetes_service) { create(:kubernetes_service, project: project) }
- it 'returns the Kubernetes service' do
+ it "returns the Kubernetes service" do
expect(subject).to eq(kubernetes_service)
end
end
- context 'when the cluster creation fails' do
+ context "when the cluster creation fails" do
let!(:kubernetes_service) { create(:kubernetes_service, template: true) }
before do
diff --git a/spec/models/concerns/discussion_on_diff_spec.rb b/spec/models/concerns/discussion_on_diff_spec.rb
index 64bf04071e8..53fea1ed801 100644
--- a/spec/models/concerns/discussion_on_diff_spec.rb
+++ b/spec/models/concerns/discussion_on_diff_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe DiscussionOnDiff do
subject { create(:diff_note_on_merge_request, line_number: 18).to_discussion }
@@ -13,27 +13,27 @@ describe DiscussionOnDiff do
expect(truncated_lines.count).to be <= DiffDiscussion::NUMBER_OF_TRUNCATED_DIFF_LINES
end
- context 'with truncated diff lines diff limit set' do
+ context "with truncated diff lines diff limit set" do
let(:truncated_lines) do
subject.truncated_diff_lines(
diff_limit: diff_limit
)
end
- context 'when diff limit is higher than default' do
+ context "when diff limit is higher than default" do
let(:diff_limit) { DiffDiscussion::NUMBER_OF_TRUNCATED_DIFF_LINES + 1 }
- it 'returns fewer lines than the default' do
+ it "returns fewer lines than the default" do
expect(subject.diff_lines.count).to be > diff_limit
expect(truncated_lines.count).to be <= DiffDiscussion::NUMBER_OF_TRUNCATED_DIFF_LINES
end
end
- context 'when diff_limit is lower than default' do
+ context "when diff_limit is lower than default" do
let(:diff_limit) { 3 }
- it 'returns fewer lines than the default' do
+ it "returns fewer lines than the default" do
expect(subject.diff_lines.count).to be > DiffDiscussion::NUMBER_OF_TRUNCATED_DIFF_LINES
expect(truncated_lines.count).to be <= diff_limit
@@ -57,36 +57,36 @@ describe DiscussionOnDiff do
end
end
- context 'when the discussion is on an image' do
+ context "when the discussion is on an image" do
subject { create(:image_diff_note_on_merge_request).to_discussion }
- it 'returns an empty array' do
+ it "returns an empty array" do
expect(truncated_lines).to eq([])
end
end
end
- describe '#line_code_in_diffs' do
- context 'when the discussion is active in the diff' do
+ describe "#line_code_in_diffs" do
+ context "when the discussion is active in the diff" do
let(:diff_refs) { subject.position.diff_refs }
- it 'returns the current line code' do
+ it "returns the current line code" do
expect(subject.line_code_in_diffs(diff_refs)).to eq(subject.line_code)
end
end
- context 'when the discussion was created in the diff' do
+ context "when the discussion was created in the diff" do
let(:diff_refs) { subject.original_position.diff_refs }
- it 'returns the original line code' do
+ it "returns the original line code" do
expect(subject.line_code_in_diffs(diff_refs)).to eq(subject.original_line_code)
end
end
- context 'when the discussion is unrelated to the diff' do
+ context "when the discussion is unrelated to the diff" do
let(:diff_refs) { subject.project.commit(RepoHelpers.sample_commit.id).diff_refs }
- it 'returns nil' do
+ it "returns nil" do
expect(subject.line_code_in_diffs(diff_refs)).to be_nil
end
end
diff --git a/spec/models/concerns/each_batch_spec.rb b/spec/models/concerns/each_batch_spec.rb
index 17224c09693..848f046d09a 100644
--- a/spec/models/concerns/each_batch_spec.rb
+++ b/spec/models/concerns/each_batch_spec.rb
@@ -1,12 +1,12 @@
-require 'spec_helper'
+require "spec_helper"
describe EachBatch do
- describe '.each_batch' do
+ describe ".each_batch" do
let(:model) do
Class.new(ActiveRecord::Base) do
include EachBatch
- self.table_name = 'users'
+ self.table_name = "users"
end
end
@@ -14,34 +14,34 @@ describe EachBatch do
5.times { create(:user, updated_at: 1.day.ago) }
end
- shared_examples 'each_batch handling' do |kwargs|
- it 'yields an ActiveRecord::Relation when a block is given' do
+ shared_examples "each_batch handling" do |kwargs|
+ it "yields an ActiveRecord::Relation when a block is given" do
model.each_batch(kwargs) do |relation|
expect(relation).to be_a_kind_of(ActiveRecord::Relation)
end
end
- it 'yields a batch index as the second argument' do
+ it "yields a batch index as the second argument" do
model.each_batch(kwargs) do |_, index|
expect(index).to eq(1)
end
end
- it 'accepts a custom batch size' do
+ it "accepts a custom batch size" do
amount = 0
- model.each_batch(kwargs.merge({ of: 1 })) { amount += 1 }
+ model.each_batch(kwargs.merge({of: 1})) { amount += 1 }
expect(amount).to eq(5)
end
- it 'does not include ORDER BYs in the yielded relations' do
+ it "does not include ORDER BYs in the yielded relations" do
model.each_batch do |relation|
- expect(relation.to_sql).not_to include('ORDER BY')
+ expect(relation.to_sql).not_to include("ORDER BY")
end
end
- it 'allows updating of the yielded relations' do
+ it "allows updating of the yielded relations" do
time = Time.now
model.each_batch do |relation|
@@ -52,7 +52,7 @@ describe EachBatch do
end
end
- it_behaves_like 'each_batch handling', {}
- it_behaves_like 'each_batch handling', { order_hint: :updated_at }
+ it_behaves_like "each_batch handling", {}
+ it_behaves_like "each_batch handling", {order_hint: :updated_at}
end
end
diff --git a/spec/models/concerns/editable_spec.rb b/spec/models/concerns/editable_spec.rb
index 49a9a8ebcbc..49350966c96 100644
--- a/spec/models/concerns/editable_spec.rb
+++ b/spec/models/concerns/editable_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
describe Editable do
- describe '#edited?' do
+ describe "#edited?" do
let(:issue) { create(:issue, last_edited_at: nil) }
let(:edited_issue) { create(:issue, created_at: 3.days.ago, last_edited_at: 2.days.ago) }
diff --git a/spec/models/concerns/expirable_spec.rb b/spec/models/concerns/expirable_spec.rb
index f7b436f32e6..34052832986 100644
--- a/spec/models/concerns/expirable_spec.rb
+++ b/spec/models/concerns/expirable_spec.rb
@@ -1,28 +1,28 @@
-require 'spec_helper'
+require "spec_helper"
describe Expirable do
- describe 'ProjectMember' do
+ describe "ProjectMember" do
let(:no_expire) { create(:project_member) }
let(:expire_later) { create(:project_member, expires_at: Time.current + 6.days) }
let(:expired) { create(:project_member, expires_at: Time.current - 6.days) }
- describe '.expired' do
+ describe ".expired" do
it { expect(ProjectMember.expired).to match_array([expired]) }
end
- describe '#expired?' do
+ describe "#expired?" do
it { expect(no_expire.expired?).to eq(false) }
it { expect(expire_later.expired?).to eq(false) }
it { expect(expired.expired?).to eq(true) }
end
- describe '#expires?' do
+ describe "#expires?" do
it { expect(no_expire.expires?).to eq(false) }
it { expect(expire_later.expires?).to eq(true) }
it { expect(expired.expires?).to eq(true) }
end
- describe '#expires_soon?' do
+ describe "#expires_soon?" do
it { expect(no_expire.expires_soon?).to eq(false) }
it { expect(expire_later.expires_soon?).to eq(true) }
it { expect(expired.expires_soon?).to eq(true) }
diff --git a/spec/models/concerns/faster_cache_keys_spec.rb b/spec/models/concerns/faster_cache_keys_spec.rb
index 8d3f94267fa..0d96edeb0e3 100644
--- a/spec/models/concerns/faster_cache_keys_spec.rb
+++ b/spec/models/concerns/faster_cache_keys_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe FasterCacheKeys do
- describe '#cache_key' do
- it 'returns a String' do
+ describe "#cache_key" do
+ it "returns a String" do
# We're using a fixed string here so it's easier to set an expectation for
# the resulting cache key.
- time = '2016-08-08 16:39:00+02'
+ time = "2016-08-08 16:39:00+02"
issue = build(:issue, updated_at: time)
issue.extend(described_class)
diff --git a/spec/models/concerns/feature_gate_spec.rb b/spec/models/concerns/feature_gate_spec.rb
index 3f601243245..6bd7e023f9a 100644
--- a/spec/models/concerns/feature_gate_spec.rb
+++ b/spec/models/concerns/feature_gate_spec.rb
@@ -1,15 +1,15 @@
-require 'spec_helper'
+require "spec_helper"
describe FeatureGate do
- describe 'User' do
- describe '#flipper_id' do
- context 'when user is not persisted' do
+ describe "User" do
+ describe "#flipper_id" do
+ context "when user is not persisted" do
let(:user) { build(:user) }
it { expect(user.flipper_id).to be_nil }
end
- context 'when user is persisted' do
+ context "when user is persisted" do
let(:user) { create(:user) }
it { expect(user.flipper_id).to eq "User:#{user.id}" }
diff --git a/spec/models/concerns/from_union_spec.rb b/spec/models/concerns/from_union_spec.rb
index ee427a667c6..ec76d8ef9f0 100644
--- a/spec/models/concerns/from_union_spec.rb
+++ b/spec/models/concerns/from_union_spec.rb
@@ -1,33 +1,33 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe FromUnion do
- describe '.from_union' do
+ describe ".from_union" do
let(:model) do
Class.new(ActiveRecord::Base) do
- self.table_name = 'users'
+ self.table_name = "users"
include FromUnion
end
end
- it 'selects from the results of the UNION' do
+ it "selects from the results of the UNION" do
query = model.from_union([model.where(id: 1), model.where(id: 2)])
expect(query.to_sql).to match(/FROM \(SELECT.+UNION.+SELECT.+\) users/m)
end
- it 'supports the use of a custom alias for the sub query' do
+ it "supports the use of a custom alias for the sub query" do
query = model.from_union(
[model.where(id: 1), model.where(id: 2)],
- alias_as: 'kittens'
+ alias_as: "kittens"
)
expect(query.to_sql).to match(/FROM \(SELECT.+UNION.+SELECT.+\) kittens/m)
end
- it 'supports keeping duplicate rows' do
+ it "supports keeping duplicate rows" do
query = model.from_union(
[model.where(id: 1), model.where(id: 2)],
remove_duplicates: false
diff --git a/spec/models/concerns/group_descendant_spec.rb b/spec/models/concerns/group_descendant_spec.rb
index 28352d8c961..625dfa7de1f 100644
--- a/spec/models/concerns/group_descendant_spec.rb
+++ b/spec/models/concerns/group_descendant_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe GroupDescendant, :nested_groups do
let(:parent) { create(:group) }
@@ -9,9 +9,9 @@ describe GroupDescendant, :nested_groups do
groups + [parent, subgroup, subsub_group]
end
- context 'for a group' do
- describe '#hierarchy' do
- it 'only queries once for the ancestors' do
+ context "for a group" do
+ describe "#hierarchy" do
+ it "only queries once for the ancestors" do
# make sure the subsub_group does not have anything cached
test_group = create(:group, parent: subsub_group).reload
@@ -20,73 +20,73 @@ describe GroupDescendant, :nested_groups do
expect(query_count).to eq(1)
end
- it 'only queries once for the ancestors when a top is given' do
+ it "only queries once for the ancestors when a top is given" do
test_group = create(:group, parent: subsub_group).reload
recorder = ActiveRecord::QueryRecorder.new { test_group.hierarchy(subgroup) }
expect(recorder.count).to eq(1)
end
- it 'builds a hierarchy for a group' do
- expected_hierarchy = { parent => { subgroup => subsub_group } }
+ it "builds a hierarchy for a group" do
+ expected_hierarchy = {parent => {subgroup => subsub_group}}
expect(subsub_group.hierarchy).to eq(expected_hierarchy)
end
- it 'builds a hierarchy upto a specified parent' do
- expected_hierarchy = { subgroup => subsub_group }
+ it "builds a hierarchy upto a specified parent" do
+ expected_hierarchy = {subgroup => subsub_group}
expect(subsub_group.hierarchy(parent)).to eq(expected_hierarchy)
end
- it 'raises an error if specifying a base that is not part of the tree' do
+ it "raises an error if specifying a base that is not part of the tree" do
expect { subsub_group.hierarchy(build_stubbed(:group)) }
- .to raise_error('specified top is not part of the tree')
+ .to raise_error("specified top is not part of the tree")
end
end
- describe '.build_hierarchy' do
- it 'combines hierarchies until the top' do
+ describe ".build_hierarchy" do
+ it "combines hierarchies until the top" do
other_subgroup = create(:group, parent: parent)
other_subsub_group = create(:group, parent: subgroup)
groups = all_preloaded_groups(other_subgroup, subsub_group, other_subsub_group)
- expected_hierarchy = { parent => [other_subgroup, { subgroup => [subsub_group, other_subsub_group] }] }
+ expected_hierarchy = {parent => [other_subgroup, {subgroup => [subsub_group, other_subsub_group]}]}
expect(described_class.build_hierarchy(groups)).to eq(expected_hierarchy)
end
- it 'combines upto a given parent' do
+ it "combines upto a given parent" do
other_subgroup = create(:group, parent: parent)
other_subsub_group = create(:group, parent: subgroup)
groups = [other_subgroup, subsub_group, other_subsub_group]
groups << subgroup # Add the parent as if it was preloaded
- expected_hierarchy = [other_subgroup, { subgroup => [subsub_group, other_subsub_group] }]
+ expected_hierarchy = [other_subgroup, {subgroup => [subsub_group, other_subsub_group]}]
expect(described_class.build_hierarchy(groups, parent)).to eq(expected_hierarchy)
end
- it 'handles building a tree out of order' do
+ it "handles building a tree out of order" do
other_subgroup = create(:group, parent: parent)
other_subgroup2 = create(:group, parent: parent)
other_subsub_group = create(:group, parent: other_subgroup)
groups = all_preloaded_groups(subsub_group, other_subgroup2, other_subsub_group, other_subgroup)
- expected_hierarchy = { parent => [{ subgroup => subsub_group }, other_subgroup2, { other_subgroup => other_subsub_group }] }
+ expected_hierarchy = {parent => [{subgroup => subsub_group}, other_subgroup2, {other_subgroup => other_subsub_group}]}
expect(described_class.build_hierarchy(groups)).to eq(expected_hierarchy)
end
- it 'tracks the exception when a parent was not preloaded' do
+ it "tracks the exception when a parent was not preloaded" do
expect(Gitlab::Sentry).to receive(:track_exception).and_call_original
expect { GroupDescendant.build_hierarchy([subsub_group]) }.to raise_error(ArgumentError)
end
- it 'recovers if a parent was not reloaded by querying for the parent' do
- expected_hierarchy = { parent => { subgroup => subsub_group } }
+ it "recovers if a parent was not reloaded by querying for the parent" do
+ expected_hierarchy = {parent => {subgroup => subsub_group}}
# this does not raise in production, so stubbing it here.
allow(Gitlab::Sentry).to receive(:track_exception)
@@ -94,61 +94,61 @@ describe GroupDescendant, :nested_groups do
expect(GroupDescendant.build_hierarchy([subsub_group])).to eq(expected_hierarchy)
end
- it 'raises an error if not all elements were preloaded' do
+ it "raises an error if not all elements were preloaded" do
expect { described_class.build_hierarchy([subsub_group]) }
.to raise_error(/was not preloaded/)
end
end
end
- context 'for a project' do
+ context "for a project" do
let(:project) { create(:project, namespace: subsub_group) }
- describe '#hierarchy' do
- it 'builds a hierarchy for a project' do
- expected_hierarchy = { parent => { subgroup => { subsub_group => project } } }
+ describe "#hierarchy" do
+ it "builds a hierarchy for a project" do
+ expected_hierarchy = {parent => {subgroup => {subsub_group => project}}}
expect(project.hierarchy).to eq(expected_hierarchy)
end
- it 'builds a hierarchy upto a specified parent' do
- expected_hierarchy = { subsub_group => project }
+ it "builds a hierarchy upto a specified parent" do
+ expected_hierarchy = {subsub_group => project}
expect(project.hierarchy(subgroup)).to eq(expected_hierarchy)
end
end
- describe '.build_hierarchy' do
- it 'combines hierarchies until the top' do
+ describe ".build_hierarchy" do
+ it "combines hierarchies until the top" do
other_project = create(:project, namespace: parent)
other_subgroup_project = create(:project, namespace: subgroup)
elements = all_preloaded_groups(other_project, subsub_group, other_subgroup_project)
- expected_hierarchy = { parent => [other_project, { subgroup => [subsub_group, other_subgroup_project] }] }
+ expected_hierarchy = {parent => [other_project, {subgroup => [subsub_group, other_subgroup_project]}]}
expect(described_class.build_hierarchy(elements)).to eq(expected_hierarchy)
end
- it 'combines upto a given parent' do
+ it "combines upto a given parent" do
other_project = create(:project, namespace: parent)
other_subgroup_project = create(:project, namespace: subgroup)
elements = [other_project, subsub_group, other_subgroup_project]
elements << subgroup # Added as if it was preloaded
- expected_hierarchy = [other_project, { subgroup => [subsub_group, other_subgroup_project] }]
+ expected_hierarchy = [other_project, {subgroup => [subsub_group, other_subgroup_project]}]
expect(described_class.build_hierarchy(elements, parent)).to eq(expected_hierarchy)
end
- it 'merges to elements in the same hierarchy' do
- expected_hierarchy = { parent => subgroup }
+ it "merges to elements in the same hierarchy" do
+ expected_hierarchy = {parent => subgroup}
expect(described_class.build_hierarchy([parent, subgroup])).to eq(expected_hierarchy)
end
- it 'merges complex hierarchies' do
+ it "merges complex hierarchies" do
project = create(:project, namespace: parent)
sub_project = create(:project, namespace: subgroup)
subsubsub_group = create(:group, parent: subsub_group)
@@ -165,11 +165,11 @@ describe GroupDescendant, :nested_groups do
project,
{
subgroup => [
- { subsub_group => [{ subsubsub_group => subsubsub_project }, subsub_project] },
- sub_project
- ]
+ {subsub_group => [{subsubsub_group => subsubsub_project}, subsub_project]},
+ sub_project,
+ ],
},
- { other_subgroup => other_subproject }
+ {other_subgroup => other_subproject},
]
actual_hierarchy = described_class.build_hierarchy(elements, parent)
diff --git a/spec/models/concerns/has_ref_spec.rb b/spec/models/concerns/has_ref_spec.rb
index 8aed72d77a4..21840d08830 100644
--- a/spec/models/concerns/has_ref_spec.rb
+++ b/spec/models/concerns/has_ref_spec.rb
@@ -1,57 +1,57 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe HasRef do
- describe '#branch?' do
+ describe "#branch?" do
let(:build) { create(:ci_build) }
subject { build.branch? }
- context 'is not a tag' do
+ context "is not a tag" do
before do
build.tag = false
end
- it 'return true when tag is set to false' do
+ it "return true when tag is set to false" do
is_expected.to be_truthy
end
end
- context 'is not a tag' do
+ context "is not a tag" do
before do
build.tag = true
end
- it 'return false when tag is set to true' do
+ it "return false when tag is set to true" do
is_expected.to be_falsey
end
end
end
- describe '#git_ref' do
+ describe "#git_ref" do
subject { build.git_ref }
- context 'when tag is true' do
+ context "when tag is true" do
let(:build) { create(:ci_build, tag: true) }
- it 'returns a tag ref' do
+ it "returns a tag ref" do
is_expected.to start_with(Gitlab::Git::TAG_REF_PREFIX)
end
end
- context 'when tag is false' do
+ context "when tag is false" do
let(:build) { create(:ci_build, tag: false) }
- it 'returns a branch ref' do
+ it "returns a branch ref" do
is_expected.to start_with(Gitlab::Git::BRANCH_REF_PREFIX)
end
end
- context 'when tag is nil' do
+ context "when tag is nil" do
let(:build) { create(:ci_build, tag: nil) }
- it 'returns a branch ref' do
+ it "returns a branch ref" do
is_expected.to start_with(Gitlab::Git::BRANCH_REF_PREFIX)
end
end
diff --git a/spec/models/concerns/has_status_spec.rb b/spec/models/concerns/has_status_spec.rb
index 6b1038cb8fd..7e06f3f074c 100644
--- a/spec/models/concerns/has_status_spec.rb
+++ b/spec/models/concerns/has_status_spec.rb
@@ -1,185 +1,185 @@
-require 'spec_helper'
+require "spec_helper"
describe HasStatus do
- describe '.status' do
+ describe ".status" do
subject { CommitStatus.status }
- shared_examples 'build status summary' do
- context 'all successful' do
+ shared_examples "build status summary" do
+ context "all successful" do
let!(:statuses) { Array.new(2) { create(type, status: :success) } }
- it { is_expected.to eq 'success' }
+ it { is_expected.to eq "success" }
end
- context 'at least one failed' do
+ context "at least one failed" do
let!(:statuses) do
[create(type, status: :success), create(type, status: :failed)]
end
- it { is_expected.to eq 'failed' }
+ it { is_expected.to eq "failed" }
end
- context 'at least one running' do
+ context "at least one running" do
let!(:statuses) do
[create(type, status: :success), create(type, status: :running)]
end
- it { is_expected.to eq 'running' }
+ it { is_expected.to eq "running" }
end
- context 'at least one pending' do
+ context "at least one pending" do
let!(:statuses) do
[create(type, status: :success), create(type, status: :pending)]
end
- it { is_expected.to eq 'running' }
+ it { is_expected.to eq "running" }
end
- context 'success and failed but allowed to fail' do
+ context "success and failed but allowed to fail" do
let!(:statuses) do
[create(type, status: :success),
- create(type, status: :failed, allow_failure: true)]
+ create(type, status: :failed, allow_failure: true),]
end
- it { is_expected.to eq 'success' }
+ it { is_expected.to eq "success" }
end
- context 'one failed but allowed to fail' do
+ context "one failed but allowed to fail" do
let!(:statuses) do
[create(type, status: :failed, allow_failure: true)]
end
- it { is_expected.to eq 'success' }
+ it { is_expected.to eq "success" }
end
- context 'success and canceled' do
+ context "success and canceled" do
let!(:statuses) do
[create(type, status: :success), create(type, status: :canceled)]
end
- it { is_expected.to eq 'canceled' }
+ it { is_expected.to eq "canceled" }
end
- context 'one failed and one canceled' do
+ context "one failed and one canceled" do
let!(:statuses) do
[create(type, status: :failed), create(type, status: :canceled)]
end
- it { is_expected.to eq 'failed' }
+ it { is_expected.to eq "failed" }
end
- context 'one failed but allowed to fail and one canceled' do
+ context "one failed but allowed to fail and one canceled" do
let!(:statuses) do
[create(type, status: :failed, allow_failure: true),
- create(type, status: :canceled)]
+ create(type, status: :canceled),]
end
- it { is_expected.to eq 'canceled' }
+ it { is_expected.to eq "canceled" }
end
- context 'one running one canceled' do
+ context "one running one canceled" do
let!(:statuses) do
[create(type, status: :running), create(type, status: :canceled)]
end
- it { is_expected.to eq 'running' }
+ it { is_expected.to eq "running" }
end
- context 'all canceled' do
+ context "all canceled" do
let!(:statuses) do
[create(type, status: :canceled), create(type, status: :canceled)]
end
- it { is_expected.to eq 'canceled' }
+ it { is_expected.to eq "canceled" }
end
- context 'success and canceled but allowed to fail' do
+ context "success and canceled but allowed to fail" do
let!(:statuses) do
[create(type, status: :success),
- create(type, status: :canceled, allow_failure: true)]
+ create(type, status: :canceled, allow_failure: true),]
end
- it { is_expected.to eq 'success' }
+ it { is_expected.to eq "success" }
end
- context 'one finished and second running but allowed to fail' do
+ context "one finished and second running but allowed to fail" do
let!(:statuses) do
[create(type, status: :success),
- create(type, status: :running, allow_failure: true)]
+ create(type, status: :running, allow_failure: true),]
end
- it { is_expected.to eq 'running' }
+ it { is_expected.to eq "running" }
end
- context 'when one status finished and second is still created' do
+ context "when one status finished and second is still created" do
let!(:statuses) do
[create(type, status: :success), create(type, status: :created)]
end
- it { is_expected.to eq 'running' }
+ it { is_expected.to eq "running" }
end
- context 'when there is a manual status before created status' do
+ context "when there is a manual status before created status" do
let!(:statuses) do
[create(type, status: :success),
create(type, status: :manual, allow_failure: false),
- create(type, status: :created)]
+ create(type, status: :created),]
end
- it { is_expected.to eq 'manual' }
+ it { is_expected.to eq "manual" }
end
- context 'when one status is a blocking manual action' do
+ context "when one status is a blocking manual action" do
let!(:statuses) do
[create(type, status: :failed),
- create(type, status: :manual, allow_failure: false)]
+ create(type, status: :manual, allow_failure: false),]
end
- it { is_expected.to eq 'manual' }
+ it { is_expected.to eq "manual" }
end
- context 'when one status is a non-blocking manual action' do
+ context "when one status is a non-blocking manual action" do
let!(:statuses) do
[create(type, status: :failed),
- create(type, status: :manual, allow_failure: true)]
+ create(type, status: :manual, allow_failure: true),]
end
- it { is_expected.to eq 'failed' }
+ it { is_expected.to eq "failed" }
end
end
- context 'ci build statuses' do
+ context "ci build statuses" do
let(:type) { :ci_build }
- it_behaves_like 'build status summary'
+ it_behaves_like "build status summary"
end
- context 'generic commit statuses' do
+ context "generic commit statuses" do
let(:type) { :generic_commit_status }
- it_behaves_like 'build status summary'
+ it_behaves_like "build status summary"
end
end
- context 'for scope with one status' do
- shared_examples 'having a job' do |status|
+ context "for scope with one status" do
+ shared_examples "having a job" do |status|
%i[ci_build generic_commit_status].each do |type|
context "when it's #{status} #{type} job" do
let!(:job) { create(type, status) }
describe ".#{status}" do
- it 'contains the job' do
+ it "contains the job" do
expect(CommitStatus.public_send(status).all)
.to contain_exactly(job)
end
end
- describe '.relevant' do
+ describe ".relevant" do
if status == :created
- it 'contains nothing' do
+ it "contains nothing" do
expect(CommitStatus.relevant.all).to be_empty
end
else
- it 'contains the job' do
+ it "contains the job" do
expect(CommitStatus.relevant.all).to contain_exactly(job)
end
end
@@ -190,151 +190,151 @@ describe HasStatus do
%i[created running pending success
failed canceled skipped].each do |status|
- it_behaves_like 'having a job', status
+ it_behaves_like "having a job", status
end
end
- context 'for scope with more statuses' do
- shared_examples 'containing the job' do |status|
+ context "for scope with more statuses" do
+ shared_examples "containing the job" do |status|
%i[ci_build generic_commit_status].each do |type|
context "when it's #{status} #{type} job" do
let!(:job) { create(type, status) }
- it 'contains the job' do
+ it "contains the job" do
is_expected.to contain_exactly(job)
end
end
end
end
- shared_examples 'not containing the job' do |status|
+ shared_examples "not containing the job" do |status|
%i[ci_build generic_commit_status].each do |type|
context "when it's #{status} #{type} job" do
let!(:job) { create(type, status) }
- it 'contains nothing' do
+ it "contains nothing" do
is_expected.to be_empty
end
end
end
end
- describe '.running_or_pending' do
+ describe ".running_or_pending" do
subject { CommitStatus.running_or_pending }
%i[running pending].each do |status|
- it_behaves_like 'containing the job', status
+ it_behaves_like "containing the job", status
end
%i[created failed success].each do |status|
- it_behaves_like 'not containing the job', status
+ it_behaves_like "not containing the job", status
end
end
- describe '.alive' do
+ describe ".alive" do
subject { CommitStatus.alive }
%i[running pending created].each do |status|
- it_behaves_like 'containing the job', status
+ it_behaves_like "containing the job", status
end
%i[failed success].each do |status|
- it_behaves_like 'not containing the job', status
+ it_behaves_like "not containing the job", status
end
end
- describe '.created_or_pending' do
+ describe ".created_or_pending" do
subject { CommitStatus.created_or_pending }
%i[created pending].each do |status|
- it_behaves_like 'containing the job', status
+ it_behaves_like "containing the job", status
end
%i[running failed success].each do |status|
- it_behaves_like 'not containing the job', status
+ it_behaves_like "not containing the job", status
end
end
- describe '.finished' do
+ describe ".finished" do
subject { CommitStatus.finished }
%i[success failed canceled].each do |status|
- it_behaves_like 'containing the job', status
+ it_behaves_like "containing the job", status
end
%i[created running pending].each do |status|
- it_behaves_like 'not containing the job', status
+ it_behaves_like "not containing the job", status
end
end
- describe '.cancelable' do
+ describe ".cancelable" do
subject { CommitStatus.cancelable }
%i[running pending created scheduled].each do |status|
- it_behaves_like 'containing the job', status
+ it_behaves_like "containing the job", status
end
%i[failed success skipped canceled manual].each do |status|
- it_behaves_like 'not containing the job', status
+ it_behaves_like "not containing the job", status
end
end
- describe '.manual' do
+ describe ".manual" do
subject { CommitStatus.manual }
%i[manual].each do |status|
- it_behaves_like 'containing the job', status
+ it_behaves_like "containing the job", status
end
%i[failed success skipped canceled].each do |status|
- it_behaves_like 'not containing the job', status
+ it_behaves_like "not containing the job", status
end
end
- describe '.scheduled' do
+ describe ".scheduled" do
subject { CommitStatus.scheduled }
%i[scheduled].each do |status|
- it_behaves_like 'containing the job', status
+ it_behaves_like "containing the job", status
end
%i[failed success skipped canceled].each do |status|
- it_behaves_like 'not containing the job', status
+ it_behaves_like "not containing the job", status
end
end
end
- describe '::DEFAULT_STATUS' do
- it 'is a status created' do
- expect(described_class::DEFAULT_STATUS).to eq 'created'
+ describe "::DEFAULT_STATUS" do
+ it "is a status created" do
+ expect(described_class::DEFAULT_STATUS).to eq "created"
end
end
- describe '::BLOCKED_STATUS' do
- it 'is a status manual' do
+ describe "::BLOCKED_STATUS" do
+ it "is a status manual" do
expect(described_class::BLOCKED_STATUS).to eq %w[manual scheduled]
end
end
- describe 'blocked?' do
+ describe "blocked?" do
subject { object.blocked? }
%w[ci_pipeline ci_stage ci_build generic_commit_status].each do |type|
let(:object) { build(type, status: status) }
- context 'when status is scheduled' do
+ context "when status is scheduled" do
let(:status) { :scheduled }
it { is_expected.to be_truthy }
end
- context 'when status is manual' do
+ context "when status is manual" do
let(:status) { :manual }
it { is_expected.to be_truthy }
end
- context 'when status is created' do
+ context "when status is created" do
let(:status) { :created }
it { is_expected.to be_falsy }
@@ -342,10 +342,10 @@ describe HasStatus do
end
end
- describe '.status_sql' do
+ describe ".status_sql" do
subject { Ci::Build.status_sql }
- it 'returns SQL' do
+ it "returns SQL" do
puts subject
end
end
diff --git a/spec/models/concerns/has_variable_spec.rb b/spec/models/concerns/has_variable_spec.rb
index bff96e12ffa..5b9d825c168 100644
--- a/spec/models/concerns/has_variable_spec.rb
+++ b/spec/models/concerns/has_variable_spec.rb
@@ -1,61 +1,61 @@
-require 'spec_helper'
+require "spec_helper"
describe HasVariable do
subject { build(:ci_variable) }
it { is_expected.to validate_presence_of(:key) }
it { is_expected.to validate_length_of(:key).is_at_most(255) }
- it { is_expected.to allow_value('foo').for(:key) }
- it { is_expected.not_to allow_value('foo bar').for(:key) }
- it { is_expected.not_to allow_value('foo/bar').for(:key) }
+ it { is_expected.to allow_value("foo").for(:key) }
+ it { is_expected.not_to allow_value("foo bar").for(:key) }
+ it { is_expected.not_to allow_value("foo/bar").for(:key) }
- describe '#key=' do
- context 'when the new key is nil' do
- it 'strips leading and trailing whitespaces' do
+ describe "#key=" do
+ context "when the new key is nil" do
+ it "strips leading and trailing whitespaces" do
subject.key = nil
- expect(subject.key).to eq('')
+ expect(subject.key).to eq("")
end
end
- context 'when the new key has leadind and trailing whitespaces' do
- it 'strips leading and trailing whitespaces' do
- subject.key = ' my key '
+ context "when the new key has leadind and trailing whitespaces" do
+ it "strips leading and trailing whitespaces" do
+ subject.key = " my key "
- expect(subject.key).to eq('my key')
+ expect(subject.key).to eq("my key")
end
end
end
- describe '#value' do
+ describe "#value" do
before do
- subject.value = 'secret'
+ subject.value = "secret"
end
- it 'stores the encrypted value' do
+ it "stores the encrypted value" do
expect(subject.encrypted_value).not_to be_nil
end
- it 'stores an iv for value' do
+ it "stores an iv for value" do
expect(subject.encrypted_value_iv).not_to be_nil
end
- it 'stores a salt for value' do
+ it "stores a salt for value" do
expect(subject.encrypted_value_salt).not_to be_nil
end
- it 'fails to decrypt if iv is incorrect' do
+ it "fails to decrypt if iv is incorrect" do
# attr_encrypted expects the IV to be 16 bytes and base64-encoded
- subject.encrypted_value_iv = [SecureRandom.hex(8)].pack('m')
+ subject.encrypted_value_iv = [SecureRandom.hex(8)].pack("m")
subject.instance_variable_set(:@value, nil)
expect { subject.value }
- .to raise_error(OpenSSL::Cipher::CipherError, 'bad decrypt')
+ .to raise_error(OpenSSL::Cipher::CipherError, "bad decrypt")
end
end
- describe '#to_runner_variable' do
- it 'returns a hash for the runner' do
+ describe "#to_runner_variable" do
+ it "returns a hash for the runner" do
expect(subject.to_runner_variable)
.to include(key: subject.key, value: subject.value, public: false)
end
diff --git a/spec/models/concerns/ignorable_column_spec.rb b/spec/models/concerns/ignorable_column_spec.rb
index b70f2331a0e..9b7adb44c8f 100644
--- a/spec/models/concerns/ignorable_column_spec.rb
+++ b/spec/models/concerns/ignorable_column_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe IgnorableColumn do
let :base_class do
@@ -6,9 +6,9 @@ describe IgnorableColumn do
def self.columns
# This method does not have access to "double"
[
- Struct.new(:name).new('id'),
- Struct.new(:name).new('title'),
- Struct.new(:name).new('date')
+ Struct.new(:name).new("id"),
+ Struct.new(:name).new("title"),
+ Struct.new(:name).new("date"),
]
end
end
@@ -20,23 +20,23 @@ describe IgnorableColumn do
end
end
- describe '.columns' do
- it 'returns the columns, excluding the ignored ones' do
+ describe ".columns" do
+ it "returns the columns, excluding the ignored ones" do
model.ignore_column(:title, :date)
- expect(model.columns.map(&:name)).to eq(%w(id))
+ expect(model.columns.map(&:name)).to eq(%w[id])
end
end
- describe '.ignored_columns' do
- it 'returns a Set' do
+ describe ".ignored_columns" do
+ it "returns a Set" do
expect(model.ignored_columns).to be_an_instance_of(Set)
end
- it 'returns the names of the ignored columns' do
+ it "returns the names of the ignored columns" do
model.ignore_column(:title, :date)
- expect(model.ignored_columns).to eq(Set.new(%w(title date)))
+ expect(model.ignored_columns).to eq(Set.new(%w[title date]))
end
end
end
diff --git a/spec/models/concerns/issuable_spec.rb b/spec/models/concerns/issuable_spec.rb
index 41159348e04..b6c0bdb75a2 100644
--- a/spec/models/concerns/issuable_spec.rb
+++ b/spec/models/concerns/issuable_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
+require "spec_helper"
describe Issuable do
let(:issuable_class) { Issue }
- let(:issue) { create(:issue, title: 'An issue', description: 'A description') }
+ let(:issue) { create(:issue, title: "An issue", description: "A description") }
let(:user) { create(:user) }
describe "Associations" do
@@ -14,18 +14,18 @@ describe Issuable do
it { is_expected.to have_many(:todos).dependent(:destroy) }
it { is_expected.to have_many(:labels) }
- context 'Notes' do
+ context "Notes" do
let!(:note) { create(:note, noteable: issue, project: issue.project) }
let(:scoped_issue) { Issue.includes(notes: :author).find(issue.id) }
- it 'indicates if the notes have their authors loaded' do
+ it "indicates if the notes have their authors loaded" do
expect(issue.notes).not_to be_authors_loaded
expect(scoped_issue.notes).to be_authors_loaded
end
end
end
- describe 'Included modules' do
+ describe "Included modules" do
let(:described_class) { issuable_class }
it { is_expected.to include_module(Awardable) }
@@ -53,12 +53,12 @@ describe Issuable do
it { expect(issuable_class).to respond_to(:assigned) }
end
- describe 'author_name' do
- it 'is delegated to author' do
+ describe "author_name" do
+ it "is delegated to author" do
expect(issue.author_name).to eq issue.author.name
end
- it 'returns nil when author is nil' do
+ it "returns nil when author is nil" do
issue.author_id = nil
issue.save(validate: false)
@@ -68,152 +68,152 @@ describe Issuable do
describe ".search" do
let!(:searchable_issue) { create(:issue, title: "Searchable awesome issue") }
- let!(:searchable_issue2) { create(:issue, title: 'Aw') }
+ let!(:searchable_issue2) { create(:issue, title: "Aw") }
- it 'returns issues with a matching title' do
+ it "returns issues with a matching title" do
expect(issuable_class.search(searchable_issue.title))
.to eq([searchable_issue])
end
- it 'returns issues with a partially matching title' do
- expect(issuable_class.search('able')).to eq([searchable_issue])
+ it "returns issues with a partially matching title" do
+ expect(issuable_class.search("able")).to eq([searchable_issue])
end
- it 'returns issues with a matching title regardless of the casing' do
+ it "returns issues with a matching title regardless of the casing" do
expect(issuable_class.search(searchable_issue.title.upcase))
.to eq([searchable_issue])
end
- it 'returns issues with a fuzzy matching title' do
- expect(issuable_class.search('searchable issue')).to eq([searchable_issue])
+ it "returns issues with a fuzzy matching title" do
+ expect(issuable_class.search("searchable issue")).to eq([searchable_issue])
end
- it 'returns issues with a matching title for a query shorter than 3 chars' do
+ it "returns issues with a matching title for a query shorter than 3 chars" do
expect(issuable_class.search(searchable_issue2.title.downcase)).to eq([searchable_issue2])
end
end
describe ".full_search" do
let!(:searchable_issue) do
- create(:issue, title: "Searchable awesome issue", description: 'Many cute kittens')
+ create(:issue, title: "Searchable awesome issue", description: "Many cute kittens")
end
let!(:searchable_issue2) { create(:issue, title: "Aw", description: "Cu") }
- it 'returns issues with a matching title' do
+ it "returns issues with a matching title" do
expect(issuable_class.full_search(searchable_issue.title))
.to eq([searchable_issue])
end
- it 'returns issues with a partially matching title' do
- expect(issuable_class.full_search('able')).to eq([searchable_issue])
+ it "returns issues with a partially matching title" do
+ expect(issuable_class.full_search("able")).to eq([searchable_issue])
end
- it 'returns issues with a matching title regardless of the casing' do
+ it "returns issues with a matching title regardless of the casing" do
expect(issuable_class.full_search(searchable_issue.title.upcase))
.to eq([searchable_issue])
end
- it 'returns issues with a fuzzy matching title' do
- expect(issuable_class.full_search('searchable issue')).to eq([searchable_issue])
+ it "returns issues with a fuzzy matching title" do
+ expect(issuable_class.full_search("searchable issue")).to eq([searchable_issue])
end
- it 'returns issues with a matching description' do
+ it "returns issues with a matching description" do
expect(issuable_class.full_search(searchable_issue.description))
.to eq([searchable_issue])
end
- it 'returns issues with a partially matching description' do
+ it "returns issues with a partially matching description" do
expect(issuable_class.full_search(searchable_issue.description))
.to eq([searchable_issue])
end
- it 'returns issues with a matching description regardless of the casing' do
+ it "returns issues with a matching description regardless of the casing" do
expect(issuable_class.full_search(searchable_issue.description.upcase))
.to eq([searchable_issue])
end
- it 'returns issues with a fuzzy matching description' do
- expect(issuable_class.full_search('many kittens')).to eq([searchable_issue])
+ it "returns issues with a fuzzy matching description" do
+ expect(issuable_class.full_search("many kittens")).to eq([searchable_issue])
end
- it 'returns issues with a matching description for a query shorter than 3 chars' do
+ it "returns issues with a matching description for a query shorter than 3 chars" do
expect(issuable_class.full_search(searchable_issue2.description.downcase)).to eq([searchable_issue2])
end
context 'when matching columns is "title"' do
- it 'returns issues with a matching title' do
- expect(issuable_class.full_search(searchable_issue.title, matched_columns: 'title'))
+ it "returns issues with a matching title" do
+ expect(issuable_class.full_search(searchable_issue.title, matched_columns: "title"))
.to eq([searchable_issue])
end
- it 'returns no issues with a matching description' do
- expect(issuable_class.full_search(searchable_issue.description, matched_columns: 'title'))
+ it "returns no issues with a matching description" do
+ expect(issuable_class.full_search(searchable_issue.description, matched_columns: "title"))
.to be_empty
end
end
context 'when matching columns is "description"' do
- it 'returns no issues with a matching title' do
- expect(issuable_class.full_search(searchable_issue.title, matched_columns: 'description'))
+ it "returns no issues with a matching title" do
+ expect(issuable_class.full_search(searchable_issue.title, matched_columns: "description"))
.to be_empty
end
- it 'returns issues with a matching description' do
- expect(issuable_class.full_search(searchable_issue.description, matched_columns: 'description'))
+ it "returns issues with a matching description" do
+ expect(issuable_class.full_search(searchable_issue.description, matched_columns: "description"))
.to eq([searchable_issue])
end
end
context 'when matching columns is "title,description"' do
- it 'returns issues with a matching title' do
- expect(issuable_class.full_search(searchable_issue.title, matched_columns: 'title,description'))
+ it "returns issues with a matching title" do
+ expect(issuable_class.full_search(searchable_issue.title, matched_columns: "title,description"))
.to eq([searchable_issue])
end
- it 'returns issues with a matching description' do
- expect(issuable_class.full_search(searchable_issue.description, matched_columns: 'title,description'))
+ it "returns issues with a matching description" do
+ expect(issuable_class.full_search(searchable_issue.description, matched_columns: "title,description"))
.to eq([searchable_issue])
end
end
context 'when matching columns is nil"' do
- it 'returns issues with a matching title' do
+ it "returns issues with a matching title" do
expect(issuable_class.full_search(searchable_issue.title, matched_columns: nil))
.to eq([searchable_issue])
end
- it 'returns issues with a matching description' do
+ it "returns issues with a matching description" do
expect(issuable_class.full_search(searchable_issue.description, matched_columns: nil))
.to eq([searchable_issue])
end
end
context 'when matching columns is "invalid"' do
- it 'returns issues with a matching title' do
- expect(issuable_class.full_search(searchable_issue.title, matched_columns: 'invalid'))
+ it "returns issues with a matching title" do
+ expect(issuable_class.full_search(searchable_issue.title, matched_columns: "invalid"))
.to eq([searchable_issue])
end
- it 'returns issues with a matching description' do
- expect(issuable_class.full_search(searchable_issue.description, matched_columns: 'invalid'))
+ it "returns issues with a matching description" do
+ expect(issuable_class.full_search(searchable_issue.description, matched_columns: "invalid"))
.to eq([searchable_issue])
end
end
context 'when matching columns is "title,invalid"' do
- it 'returns issues with a matching title' do
- expect(issuable_class.full_search(searchable_issue.title, matched_columns: 'title,invalid'))
+ it "returns issues with a matching title" do
+ expect(issuable_class.full_search(searchable_issue.title, matched_columns: "title,invalid"))
.to eq([searchable_issue])
end
- it 'returns no issues with a matching description' do
- expect(issuable_class.full_search(searchable_issue.description, matched_columns: 'title,invalid'))
+ it "returns no issues with a matching description" do
+ expect(issuable_class.full_search(searchable_issue.description, matched_columns: "title,invalid"))
.to be_empty
end
end
end
- describe '.to_ability_name' do
+ describe ".to_ability_name" do
it { expect(Issue.to_ability_name).to eq("issue") }
it { expect(MergeRequest.to_ability_name).to eq("merge_request") }
end
@@ -266,72 +266,72 @@ describe Issuable do
let!(:issue3) { create(:issue, project: project) }
it "sorts desc" do
- issues = project.issues.sort_by_attribute('milestone_due_desc')
+ issues = project.issues.sort_by_attribute("milestone_due_desc")
expect(issues).to match_array([issue2, issue1, issue, issue3])
end
it "sorts asc" do
- issues = project.issues.sort_by_attribute('milestone_due_asc')
+ issues = project.issues.sort_by_attribute("milestone_due_asc")
expect(issues).to match_array([issue1, issue2, issue, issue3])
end
end
- context 'when all of the results are level on the sort key' do
+ context "when all of the results are level on the sort key" do
let!(:issues) do
10.times { create(:issue, project: project) }
end
- it 'has no duplicates across pages' do
- sorted_issue_ids = 1.upto(10).map do |i|
- project.issues.sort_by_attribute('milestone_due_desc').page(i).per(1).first.id
- end
+ it "has no duplicates across pages" do
+ sorted_issue_ids = 1.upto(10).map { |i|
+ project.issues.sort_by_attribute("milestone_due_desc").page(i).per(1).first.id
+ }
expect(sorted_issue_ids).to eq(sorted_issue_ids.uniq)
end
end
end
- describe '#subscribed?' do
+ describe "#subscribed?" do
let(:project) { issue.project }
- context 'user is not a participant in the issue' do
+ context "user is not a participant in the issue" do
before do
allow(issue).to receive(:participants).with(user).and_return([])
end
- it 'returns false when no subcription exists' do
+ it "returns false when no subcription exists" do
expect(issue.subscribed?(user, project)).to be_falsey
end
- it 'returns true when a subcription exists and subscribed is true' do
+ it "returns true when a subcription exists and subscribed is true" do
issue.subscriptions.create(user: user, project: project, subscribed: true)
expect(issue.subscribed?(user, project)).to be_truthy
end
- it 'returns false when a subcription exists and subscribed is false' do
+ it "returns false when a subcription exists and subscribed is false" do
issue.subscriptions.create(user: user, project: project, subscribed: false)
expect(issue.subscribed?(user, project)).to be_falsey
end
end
- context 'user is a participant in the issue' do
+ context "user is a participant in the issue" do
before do
allow(issue).to receive(:participants).with(user).and_return([user])
end
- it 'returns false when no subcription exists' do
+ it "returns false when no subcription exists" do
expect(issue.subscribed?(user, project)).to be_truthy
end
- it 'returns true when a subcription exists and subscribed is true' do
+ it "returns true when a subcription exists and subscribed is true" do
issue.subscriptions.create(user: user, project: project, subscribed: true)
expect(issue.subscribed?(user, project)).to be_truthy
end
- it 'returns false when a subcription exists and subscribed is false' do
+ it "returns false when a subcription exists and subscribed is false" do
issue.subscriptions.create(user: user, project: project, subscribed: false)
expect(issue.subscribed?(user, project)).to be_falsey
@@ -339,23 +339,23 @@ describe Issuable do
end
end
- describe '#time_estimate=' do
- it 'coerces the value below Gitlab::Database::MAX_INT_VALUE' do
+ describe "#time_estimate=" do
+ it "coerces the value below Gitlab::Database::MAX_INT_VALUE" do
expect { issue.time_estimate = 100 }.to change { issue.time_estimate }.to(100)
expect { issue.time_estimate = Gitlab::Database::MAX_INT_VALUE + 100 }.to change { issue.time_estimate }.to(Gitlab::Database::MAX_INT_VALUE)
end
- it 'skips coercion for not Integer values' do
+ it "skips coercion for not Integer values" do
expect { issue.time_estimate = nil }.to change { issue.time_estimate }.to(nil)
- expect { issue.time_estimate = 'invalid time' }.not_to raise_error
+ expect { issue.time_estimate = "invalid time" }.not_to raise_error
expect { issue.time_estimate = 22.33 }.not_to raise_error
end
end
- describe '#to_hook_data' do
+ describe "#to_hook_data" do
let(:builder) { double }
- context 'labels are updated' do
+ context "labels are updated" do
let(:labels) { create_list(:label, 2) }
before do
@@ -364,18 +364,19 @@ describe Issuable do
.to receive(:new).with(issue).and_return(builder)
end
- it 'delegates to Gitlab::HookData::IssuableBuilder#build' do
+ it "delegates to Gitlab::HookData::IssuableBuilder#build" do
expect(builder).to receive(:build).with(
user: user,
changes: hash_including(
- 'labels' => [[labels[0].hook_attrs], [labels[1].hook_attrs]]
- ))
+ "labels" => [[labels[0].hook_attrs], [labels[1].hook_attrs]]
+ )
+ )
- issue.to_hook_data(user, old_associations: { labels: [labels[0]] })
+ issue.to_hook_data(user, old_associations: {labels: [labels[0]]})
end
end
- context 'total_time_spent is updated' do
+ context "total_time_spent is updated" do
before do
issue.spend_time(duration: 2, user_id: user.id, spent_at: Time.now)
issue.save
@@ -383,18 +384,19 @@ describe Issuable do
.to receive(:new).with(issue).and_return(builder)
end
- it 'delegates to Gitlab::HookData::IssuableBuilder#build' do
+ it "delegates to Gitlab::HookData::IssuableBuilder#build" do
expect(builder).to receive(:build).with(
user: user,
changes: hash_including(
- 'total_time_spent' => [1, 2]
- ))
+ "total_time_spent" => [1, 2]
+ )
+ )
- issue.to_hook_data(user, old_associations: { total_time_spent: 1 })
+ issue.to_hook_data(user, old_associations: {total_time_spent: 1})
end
end
- context 'issue is assigned' do
+ context "issue is assigned" do
let(:user2) { create(:user) }
before do
@@ -403,18 +405,19 @@ describe Issuable do
.to receive(:new).with(issue).and_return(builder)
end
- it 'delegates to Gitlab::HookData::IssuableBuilder#build' do
+ it "delegates to Gitlab::HookData::IssuableBuilder#build" do
expect(builder).to receive(:build).with(
user: user,
changes: hash_including(
- 'assignees' => [[user.hook_attrs], [user.hook_attrs, user2.hook_attrs]]
- ))
+ "assignees" => [[user.hook_attrs], [user.hook_attrs, user2.hook_attrs]]
+ )
+ )
- issue.to_hook_data(user, old_associations: { assignees: [user] })
+ issue.to_hook_data(user, old_associations: {assignees: [user]})
end
end
- context 'merge_request is assigned' do
+ context "merge_request is assigned" do
let(:merge_request) { create(:merge_request) }
let(:user2) { create(:user) }
@@ -425,34 +428,35 @@ describe Issuable do
.to receive(:new).with(merge_request).and_return(builder)
end
- it 'delegates to Gitlab::HookData::IssuableBuilder#build' do
+ it "delegates to Gitlab::HookData::IssuableBuilder#build" do
expect(builder).to receive(:build).with(
user: user,
changes: hash_including(
- 'assignee_id' => [user.id, user2.id],
- 'assignee' => [user.hook_attrs, user2.hook_attrs]
- ))
+ "assignee_id" => [user.id, user2.id],
+ "assignee" => [user.hook_attrs, user2.hook_attrs]
+ )
+ )
- merge_request.to_hook_data(user, old_associations: { assignees: [user] })
+ merge_request.to_hook_data(user, old_associations: {assignees: [user]})
end
end
end
- describe '#labels_array' do
+ describe "#labels_array" do
let(:project) { create(:project) }
- let(:bug) { create(:label, project: project, title: 'bug') }
+ let(:bug) { create(:label, project: project, title: "bug") }
let(:issue) { create(:issue, project: project) }
before do
issue.labels << bug
end
- it 'loads the association and returns it as an array' do
+ it "loads the association and returns it as an array" do
expect(issue.reload.labels_array).to eq([bug])
end
end
- describe '#user_notes_count' do
+ describe "#user_notes_count" do
let(:project) { create(:project) }
let(:issue1) { create(:issue, project: project) }
let(:issue2) { create(:issue, project: project) }
@@ -462,7 +466,7 @@ describe Issuable do
create_list(:note, 6, noteable: issue2, project: project)
end
- it 'counts the user notes' do
+ it "counts the user notes" do
expect(issue1.user_notes_count).to be(3)
expect(issue2.user_notes_count).to be(6)
end
@@ -482,14 +486,14 @@ describe Issuable do
end
end
- describe '.order_due_date_and_labels_priority' do
+ describe ".order_due_date_and_labels_priority" do
let(:project) { create(:project) }
def create_issue(milestone, labels)
create(:labeled_issue, milestone: milestone, labels: labels, project: project)
end
- it 'sorts issues in order of milestone due date, then label priority' do
+ it "sorts issues in order of milestone due date, then label priority" do
first_priority = create(:label, project: project, priority: 1)
second_priority = create(:label, project: project, priority: 2)
no_priority = create(:label, project: project)
@@ -518,15 +522,15 @@ describe Issuable do
second_milestone_no_labels,
third_milestone_first_priority,
no_milestone_second_priority,
- third_milestone_no_priority])
+ third_milestone_no_priority,])
end
end
- describe '.order_labels_priority' do
- let(:label_1) { create(:label, title: 'label_1', project: issue.project, priority: 1) }
- let(:label_2) { create(:label, title: 'label_2', project: issue.project, priority: 2) }
+ describe ".order_labels_priority" do
+ let(:label_1) { create(:label, title: "label_1", project: issue.project, priority: 1) }
+ let(:label_2) { create(:label, title: "label_2", project: issue.project, priority: 2) }
- subject { Issue.order_labels_priority(excluded_labels: ['label_1']).first.highest_priority }
+ subject { Issue.order_labels_priority(excluded_labels: ["label_1"]).first.highest_priority }
before do
issue.labels << label_1
@@ -538,9 +542,9 @@ describe Issuable do
describe ".with_label" do
let(:project) { create(:project, :public) }
- let(:bug) { create(:label, project: project, title: 'bug') }
- let(:feature) { create(:label, project: project, title: 'feature') }
- let(:enhancement) { create(:label, project: project, title: 'enhancement') }
+ let(:bug) { create(:label, project: project, title: "bug") }
+ let(:feature) { create(:label, project: project, title: "feature") }
+ let(:enhancement) { create(:label, project: project, title: "enhancement") }
let(:issue1) { create(:issue, title: "Bugfix1", project: project) }
let(:issue2) { create(:issue, title: "Bugfix2", project: project) }
let(:issue3) { create(:issue, title: "Feature1", project: project) }
@@ -553,20 +557,20 @@ describe Issuable do
issue3.labels << feature
end
- it 'finds the correct issue containing just enhancement label' do
+ it "finds the correct issue containing just enhancement label" do
expect(Issue.with_label(enhancement.title)).to match_array([issue2])
end
- it 'finds the correct issues containing the same label' do
+ it "finds the correct issues containing the same label" do
expect(Issue.with_label(bug.title)).to match_array([issue1, issue2])
end
- it 'finds the correct issues containing only both labels' do
+ it "finds the correct issues containing only both labels" do
expect(Issue.with_label([bug.title, enhancement.title])).to match_array([issue2])
end
end
- describe '#spend_time' do
+ describe "#spend_time" do
let(:user) { create(:user) }
let(:issue) { create(:issue) }
@@ -575,14 +579,14 @@ describe Issuable do
issue.save!
end
- context 'adding time' do
- it 'should update the total time spent' do
+ context "adding time" do
+ it "should update the total time spent" do
spend_time(1800)
expect(issue.total_time_spent).to eq(1800)
end
- it 'updates issues updated_at' do
+ it "updates issues updated_at" do
issue
Timecop.travel(1.minute.from_now) do
@@ -591,32 +595,32 @@ describe Issuable do
end
end
- context 'subtracting time' do
+ context "subtracting time" do
before do
spend_time(1800)
end
- it 'should update the total time spent' do
+ it "should update the total time spent" do
spend_time(-900)
expect(issue.total_time_spent).to eq(900)
end
- context 'when time to subtract exceeds the total time spent' do
- it 'raise a validation error' do
+ context "when time to subtract exceeds the total time spent" do
+ it "raise a validation error" do
Timecop.travel(1.minute.from_now) do
- expect do
- expect do
+ expect {
+ expect {
spend_time(-3600)
- end.to raise_error(ActiveRecord::RecordInvalid)
- end.not_to change { issue.updated_at }
+ }.to raise_error(ActiveRecord::RecordInvalid)
+ }.not_to change { issue.updated_at }
end
end
end
end
end
- describe '#first_contribution?' do
+ describe "#first_contribution?" do
let(:group) { create(:group) }
let(:project) { create(:project, namespace: group) }
let(:other_project) { create(:project) }
diff --git a/spec/models/concerns/loaded_in_group_list_spec.rb b/spec/models/concerns/loaded_in_group_list_spec.rb
index 7a279547a3a..435d863b2da 100644
--- a/spec/models/concerns/loaded_in_group_list_spec.rb
+++ b/spec/models/concerns/loaded_in_group_list_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe LoadedInGroupList do
let(:parent) { create(:group) }
subject(:found_group) { Group.with_selects_for_list.find_by(id: parent.id) }
- describe '.with_selects_for_list' do
- it 'includes the preloaded counts for groups' do
+ describe ".with_selects_for_list" do
+ it "includes the preloaded counts for groups" do
create(:group, parent: parent)
create(:project, namespace: parent)
parent.add_developer(create(:user))
@@ -17,29 +17,29 @@ describe LoadedInGroupList do
expect(found_group.preloaded_member_count).to eq(1)
end
- context 'with archived projects' do
- it 'counts including archived projects when `true` is passed' do
+ context "with archived projects" do
+ it "counts including archived projects when `true` is passed" do
create(:project, namespace: parent, archived: true)
create(:project, namespace: parent)
- found_group = Group.with_selects_for_list(archived: 'true').find_by(id: parent.id)
+ found_group = Group.with_selects_for_list(archived: "true").find_by(id: parent.id)
expect(found_group.preloaded_project_count).to eq(2)
end
- it 'counts only archived projects when `only` is passed' do
+ it "counts only archived projects when `only` is passed" do
create_list(:project, 2, namespace: parent, archived: true)
create(:project, namespace: parent)
- found_group = Group.with_selects_for_list(archived: 'only').find_by(id: parent.id)
+ found_group = Group.with_selects_for_list(archived: "only").find_by(id: parent.id)
expect(found_group.preloaded_project_count).to eq(2)
end
end
end
- describe '#children_count' do
- it 'counts groups and projects' do
+ describe "#children_count" do
+ it "counts groups and projects" do
create(:group, parent: parent)
create(:project, namespace: parent)
diff --git a/spec/models/concerns/manual_inverse_association_spec.rb b/spec/models/concerns/manual_inverse_association_spec.rb
index ff4a04ea573..025e94e06c3 100644
--- a/spec/models/concerns/manual_inverse_association_spec.rb
+++ b/spec/models/concerns/manual_inverse_association_spec.rb
@@ -1,9 +1,9 @@
-require 'spec_helper'
+require "spec_helper"
describe ManualInverseAssociation do
let(:model) do
Class.new(MergeRequest) do
- belongs_to :manual_association, class_name: 'MergeRequestDiff', foreign_key: :latest_merge_request_diff_id
+ belongs_to :manual_association, class_name: "MergeRequestDiff", foreign_key: :latest_merge_request_diff_id
manual_inverse_association :manual_association, :merge_request
end
end
@@ -14,36 +14,36 @@ describe ManualInverseAssociation do
let(:instance) { create(:merge_request).becomes(model) }
- describe '.manual_inverse_association' do
- context 'when the relation exists' do
+ describe ".manual_inverse_association" do
+ context "when the relation exists" do
before do
instance.create_merge_request_diff
instance.reload
end
- it 'loads the relation' do
+ it "loads the relation" do
expect(instance.manual_association).to be_an_instance_of(MergeRequestDiff)
end
- it 'does not perform extra queries after loading' do
+ it "does not perform extra queries after loading" do
instance.manual_association
expect { instance.manual_association.merge_request }
.not_to exceed_query_limit(0)
end
- it 'allows reloading the relation' do
- query_count = ActiveRecord::QueryRecorder.new do
+ it "allows reloading the relation" do
+ query_count = ActiveRecord::QueryRecorder.new {
instance.manual_association
instance.reload_manual_association
- end.count
+ }.count
expect(query_count).to eq(2)
end
end
- context 'when the relation does not return a value' do
- it 'does not try to set an inverse' do
+ context "when the relation does not return a value" do
+ it "does not try to set an inverse" do
expect(instance.manual_association).to be_nil
end
end
diff --git a/spec/models/concerns/maskable_spec.rb b/spec/models/concerns/maskable_spec.rb
index aeba7ad862f..c5473cec3cd 100644
--- a/spec/models/concerns/maskable_spec.rb
+++ b/spec/models/concerns/maskable_spec.rb
@@ -1,58 +1,58 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Maskable do
let(:variable) { build(:ci_variable) }
- describe 'masked value validations' do
+ describe "masked value validations" do
subject { variable }
- context 'when variable is masked' do
+ context "when variable is masked" do
before do
subject.masked = true
end
- it { is_expected.not_to allow_value('hello').for(:value) }
- it { is_expected.not_to allow_value('hello world').for(:value) }
- it { is_expected.not_to allow_value('hello$VARIABLEworld').for(:value) }
+ it { is_expected.not_to allow_value("hello").for(:value) }
+ it { is_expected.not_to allow_value("hello world").for(:value) }
+ it { is_expected.not_to allow_value("hello$VARIABLEworld").for(:value) }
it { is_expected.not_to allow_value('hello\rworld').for(:value) }
- it { is_expected.to allow_value('helloworld').for(:value) }
+ it { is_expected.to allow_value("helloworld").for(:value) }
end
- context 'when variable is not masked' do
+ context "when variable is not masked" do
before do
subject.masked = false
end
- it { is_expected.to allow_value('hello').for(:value) }
- it { is_expected.to allow_value('hello world').for(:value) }
- it { is_expected.to allow_value('hello$VARIABLEworld').for(:value) }
+ it { is_expected.to allow_value("hello").for(:value) }
+ it { is_expected.to allow_value("hello world").for(:value) }
+ it { is_expected.to allow_value("hello$VARIABLEworld").for(:value) }
it { is_expected.to allow_value('hello\rworld').for(:value) }
- it { is_expected.to allow_value('helloworld').for(:value) }
+ it { is_expected.to allow_value("helloworld").for(:value) }
end
end
- describe 'REGEX' do
+ describe "REGEX" do
subject { Maskable::REGEX }
- it 'does not match strings shorter than 8 letters' do
- expect(subject.match?('hello')).to eq(false)
+ it "does not match strings shorter than 8 letters" do
+ expect(subject.match?("hello")).to eq(false)
end
- it 'does not match strings with spaces' do
- expect(subject.match?('hello world')).to eq(false)
+ it "does not match strings with spaces" do
+ expect(subject.match?("hello world")).to eq(false)
end
- it 'does not match strings with shell variables' do
- expect(subject.match?('hello$VARIABLEworld')).to eq(false)
+ it "does not match strings with shell variables" do
+ expect(subject.match?("hello$VARIABLEworld")).to eq(false)
end
- it 'does not match strings with escape characters' do
+ it "does not match strings with escape characters" do
expect(subject.match?('hello\rworld')).to eq(false)
end
- it 'does not match strings that span more than one line' do
+ it "does not match strings that span more than one line" do
string = <<~EOS
hello
world
@@ -61,15 +61,15 @@ describe Maskable do
expect(subject.match?(string)).to eq(false)
end
- it 'matches valid strings' do
- expect(subject.match?('helloworld')).to eq(true)
+ it "matches valid strings" do
+ expect(subject.match?("helloworld")).to eq(true)
end
end
- describe '#to_runner_variable' do
+ describe "#to_runner_variable" do
subject { variable.to_runner_variable }
- it 'exposes the masked attribute' do
+ it "exposes the masked attribute" do
expect(subject).to include(:masked)
end
end
diff --git a/spec/models/concerns/mentionable_spec.rb b/spec/models/concerns/mentionable_spec.rb
index a9b237fa9ea..e747492be14 100644
--- a/spec/models/concerns/mentionable_spec.rb
+++ b/spec/models/concerns/mentionable_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Mentionable do
class Example
@@ -12,32 +12,32 @@ describe Mentionable do
end
end
- describe 'references' do
+ describe "references" do
let(:project) { create(:project) }
let(:mentionable) { Example.new }
- it 'excludes JIRA references' do
+ it "excludes JIRA references" do
allow(project).to receive_messages(jira_tracker?: true)
mentionable.project = project
- mentionable.message = 'JIRA-123'
+ mentionable.message = "JIRA-123"
expect(mentionable.referenced_mentionables).to be_empty
end
end
end
describe Issue, "Mentionable" do
- describe '#mentioned_users' do
- let!(:user) { create(:user, username: 'stranger') }
- let!(:user2) { create(:user, username: 'john') }
- let!(:user3) { create(:user, username: 'jim') }
+ describe "#mentioned_users" do
+ let!(:user) { create(:user, username: "stranger") }
+ let!(:user2) { create(:user, username: "john") }
+ let!(:user3) { create(:user, username: "jim") }
let(:issue) { create(:issue, description: "#{user.to_reference} mentioned") }
subject { issue.mentioned_users }
it { expect(subject).to contain_exactly(user) }
- context 'when a note on personal snippet' do
+ context "when a note on personal snippet" do
let!(:note) { create(:note_on_personal_snippet, note: "#{user.to_reference} mentioned #{user3.to_reference}") }
subject { note.mentioned_users }
@@ -46,8 +46,8 @@ describe Issue, "Mentionable" do
end
end
- describe '#referenced_mentionables' do
- context 'with an issue on a private project' do
+ describe "#referenced_mentionables" do
+ context "with an issue on a private project" do
let(:project) { create(:project, :public) }
let(:issue) { create(:issue, project: project) }
let(:public_issue) { create(:issue, project: project) }
@@ -60,31 +60,31 @@ describe Issue, "Mentionable" do
issue.referenced_mentionables(current_user)
end
- context 'when the current user can see the issue' do
+ context "when the current user can see the issue" do
before do
private_project.add_developer(user)
end
- it 'includes the reference' do
+ it "includes the reference" do
expect(referenced_issues(user)).to contain_exactly(private_issue, public_issue)
end
end
- context 'when the current user cannot see the issue' do
- it 'does not include the reference' do
+ context "when the current user cannot see the issue" do
+ it "does not include the reference" do
expect(referenced_issues(user)).to contain_exactly(public_issue)
end
end
- context 'when there is no current user' do
- it 'does not include the reference' do
+ context "when there is no current user" do
+ it "does not include the reference" do
expect(referenced_issues(nil)).to contain_exactly(public_issue)
end
end
end
end
- describe '#create_cross_references!' do
+ describe "#create_cross_references!" do
let(:project) { create(:project, :repository) }
let(:author) { build(:user) }
let(:commit) { project.commit }
@@ -94,14 +94,14 @@ describe Issue, "Mentionable" do
create(:issue, project: project, description: "See #{commit.to_reference}")
end
- it 'correctly removes already-mentioned Commits' do
+ it "correctly removes already-mentioned Commits" do
expect(SystemNoteService).not_to receive(:cross_reference)
issue.create_cross_references!(author, [commit2])
end
end
- describe '#create_new_cross_references!' do
+ describe "#create_new_cross_references!" do
let(:project) { create(:project) }
let(:author) { create(:author) }
let(:issues) { create_list(:issue, 2, project: project, author: author) }
@@ -110,17 +110,17 @@ describe Issue, "Mentionable" do
project.add_developer(author)
end
- context 'before changes are persisted' do
- it 'ignores pre-existing references' do
+ context "before changes are persisted" do
+ it "ignores pre-existing references" do
issue = create_issue(description: issues[0].to_reference)
expect(SystemNoteService).not_to receive(:cross_reference)
- issue.description = 'New description'
+ issue.description = "New description"
issue.create_new_cross_references!
end
- it 'notifies new references' do
+ it "notifies new references" do
issue = create_issue(description: issues[0].to_reference)
expect(SystemNoteService).to receive(:cross_reference).with(issues[1], any_args)
@@ -130,17 +130,17 @@ describe Issue, "Mentionable" do
end
end
- context 'after changes are persisted' do
- it 'ignores pre-existing references' do
+ context "after changes are persisted" do
+ it "ignores pre-existing references" do
issue = create_issue(description: issues[0].to_reference)
expect(SystemNoteService).not_to receive(:cross_reference)
- issue.update(description: 'New description')
+ issue.update(description: "New description")
issue.create_new_cross_references!
end
- it 'notifies new references' do
+ it "notifies new references" do
issue = create_issue(description: issues[0].to_reference)
expect(SystemNoteService).to receive(:cross_reference).with(issues[1], any_args)
@@ -149,7 +149,7 @@ describe Issue, "Mentionable" do
issue.create_new_cross_references!
end
- it 'notifies new references from project snippet note' do
+ it "notifies new references from project snippet note" do
snippet = create(:snippet, project: project)
note = create(:note, note: issues[0].to_reference, noteable: snippet, project: project, author: author)
@@ -166,36 +166,36 @@ describe Issue, "Mentionable" do
end
end
-describe Commit, 'Mentionable' do
+describe Commit, "Mentionable" do
let(:project) { create(:project, :public, :repository) }
let(:commit) { project.commit }
- describe '#matches_cross_reference_regex?' do
+ describe "#matches_cross_reference_regex?" do
it "is false when message doesn't reference anything" do
allow(commit.raw).to receive(:message).and_return "WIP: Do something"
expect(commit.matches_cross_reference_regex?).to be_falsey
end
- it 'is true if issue #number mentioned in title' do
+ it "is true if issue #number mentioned in title" do
allow(commit.raw).to receive(:message).and_return "#1"
expect(commit.matches_cross_reference_regex?).to be_truthy
end
- it 'is true if references an MR' do
+ it "is true if references an MR" do
allow(commit.raw).to receive(:message).and_return "See merge request !12"
expect(commit.matches_cross_reference_regex?).to be_truthy
end
- it 'is true if references a commit' do
+ it "is true if references a commit" do
allow(commit.raw).to receive(:message).and_return "a1b2c3d4"
expect(commit.matches_cross_reference_regex?).to be_truthy
end
- it 'is true if issue referenced by url' do
+ it "is true if issue referenced by url" do
issue = create(:issue, project: project)
allow(commit.raw).to receive(:message).and_return Gitlab::UrlBuilder.build(issue)
@@ -203,17 +203,17 @@ describe Commit, 'Mentionable' do
expect(commit.matches_cross_reference_regex?).to be_truthy
end
- context 'with external issue tracker' do
+ context "with external issue tracker" do
let(:project) { create(:jira_project, :repository) }
- it 'is true if external issues referenced' do
- allow(commit.raw).to receive(:message).and_return 'JIRA-123'
+ it "is true if external issues referenced" do
+ allow(commit.raw).to receive(:message).and_return "JIRA-123"
expect(commit.matches_cross_reference_regex?).to be_truthy
end
- it 'is true if internal issues referenced' do
- allow(commit.raw).to receive(:message).and_return '#123'
+ it "is true if internal issues referenced" do
+ allow(commit.raw).to receive(:message).and_return "#123"
expect(commit.matches_cross_reference_regex?).to be_truthy
end
diff --git a/spec/models/concerns/milestoneish_spec.rb b/spec/models/concerns/milestoneish_spec.rb
index 87bf731340f..24bd9ec8881 100644
--- a/spec/models/concerns/milestoneish_spec.rb
+++ b/spec/models/concerns/milestoneish_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe Milestone, 'Milestoneish' do
+describe Milestone, "Milestoneish" do
let(:author) { create(:user) }
let(:assignee) { create(:user) }
let(:non_member) { create(:user) }
@@ -19,17 +19,17 @@ describe Milestone, 'Milestoneish' do
let!(:closed_security_issue_3) { create(:issue, :confidential, :closed, project: project, author: author, milestone: milestone) }
let!(:closed_security_issue_4) { create(:issue, :confidential, :closed, project: project, assignees: [assignee], milestone: milestone) }
let!(:merge_request) { create(:merge_request, source_project: project, target_project: project, milestone: milestone) }
- let(:label_1) { create(:label, title: 'label_1', project: project, priority: 1) }
- let(:label_2) { create(:label, title: 'label_2', project: project, priority: 2) }
- let(:label_3) { create(:label, title: 'label_3', project: project) }
+ let(:label_1) { create(:label, title: "label_1", project: project, priority: 1) }
+ let(:label_2) { create(:label, title: "label_2", project: project, priority: 2) }
+ let(:label_3) { create(:label, title: "label_3", project: project) }
before do
project.add_developer(member)
project.add_guest(guest)
end
- describe '#sorted_issues' do
- it 'sorts issues by label priority' do
+ describe "#sorted_issues" do
+ it "sorts issues by label priority" do
issue.labels << label_1
security_issue_1.labels << label_2
closed_issue_1.labels << label_3
@@ -42,11 +42,11 @@ describe Milestone, 'Milestoneish' do
end
end
- describe '#sorted_merge_requests' do
- it 'sorts merge requests by label priority' do
- merge_request_1 = create(:labeled_merge_request, labels: [label_2], source_project: project, source_branch: 'branch_1', milestone: milestone)
- merge_request_2 = create(:labeled_merge_request, labels: [label_1], source_project: project, source_branch: 'branch_2', milestone: milestone)
- merge_request_3 = create(:labeled_merge_request, labels: [label_3], source_project: project, source_branch: 'branch_3', milestone: milestone)
+ describe "#sorted_merge_requests" do
+ it "sorts merge requests by label priority" do
+ merge_request_1 = create(:labeled_merge_request, labels: [label_2], source_project: project, source_branch: "branch_1", milestone: milestone)
+ merge_request_2 = create(:labeled_merge_request, labels: [label_1], source_project: project, source_branch: "branch_2", milestone: milestone)
+ merge_request_3 = create(:labeled_merge_request, labels: [label_3], source_project: project, source_branch: "branch_3", milestone: milestone)
merge_requests = milestone.sorted_merge_requests
@@ -56,64 +56,64 @@ describe Milestone, 'Milestoneish' do
end
end
- describe '#closed_items_count' do
- it 'does not count confidential issues for non project members' do
+ describe "#closed_items_count" do
+ it "does not count confidential issues for non project members" do
expect(milestone.closed_items_count(non_member)).to eq 2
end
- it 'does not count confidential issues for project members with guest role' do
+ it "does not count confidential issues for project members with guest role" do
expect(milestone.closed_items_count(guest)).to eq 2
end
- it 'counts confidential issues for author' do
+ it "counts confidential issues for author" do
expect(milestone.closed_items_count(author)).to eq 4
end
- it 'counts confidential issues for assignee' do
+ it "counts confidential issues for assignee" do
expect(milestone.closed_items_count(assignee)).to eq 4
end
- it 'counts confidential issues for project members' do
+ it "counts confidential issues for project members" do
expect(milestone.closed_items_count(member)).to eq 6
end
- it 'counts all issues for admin' do
+ it "counts all issues for admin" do
expect(milestone.closed_items_count(admin)).to eq 6
end
end
- describe '#total_items_count' do
- it 'does not count confidential issues for non project members' do
+ describe "#total_items_count" do
+ it "does not count confidential issues for non project members" do
expect(milestone.total_items_count(non_member)).to eq 4
end
- it 'does not count confidential issues for project members with guest role' do
+ it "does not count confidential issues for project members with guest role" do
expect(milestone.total_items_count(guest)).to eq 4
end
- it 'counts confidential issues for author' do
+ it "counts confidential issues for author" do
expect(milestone.total_items_count(author)).to eq 7
end
- it 'counts confidential issues for assignee' do
+ it "counts confidential issues for assignee" do
expect(milestone.total_items_count(assignee)).to eq 7
end
- it 'counts confidential issues for project members' do
+ it "counts confidential issues for project members" do
expect(milestone.total_items_count(member)).to eq 10
end
- it 'counts all issues for admin' do
+ it "counts all issues for admin" do
expect(milestone.total_items_count(admin)).to eq 10
end
end
- describe '#complete?' do
- it 'returns false when has items opened' do
+ describe "#complete?" do
+ it "returns false when has items opened" do
expect(milestone.complete?(non_member)).to eq false
end
- it 'returns true when all items are closed' do
+ it "returns true when all items are closed" do
issue.close
merge_request.close
@@ -121,74 +121,74 @@ describe Milestone, 'Milestoneish' do
end
end
- describe '#percent_complete' do
- it 'does not count confidential issues for non project members' do
+ describe "#percent_complete" do
+ it "does not count confidential issues for non project members" do
expect(milestone.percent_complete(non_member)).to eq 50
end
- it 'does not count confidential issues for project members with guest role' do
+ it "does not count confidential issues for project members with guest role" do
expect(milestone.percent_complete(guest)).to eq 50
end
- it 'counts confidential issues for author' do
+ it "counts confidential issues for author" do
expect(milestone.percent_complete(author)).to eq 57
end
- it 'counts confidential issues for assignee' do
+ it "counts confidential issues for assignee" do
expect(milestone.percent_complete(assignee)).to eq 57
end
- it 'counts confidential issues for project members' do
+ it "counts confidential issues for project members" do
expect(milestone.percent_complete(member)).to eq 60
end
- it 'counts confidential issues for admin' do
+ it "counts confidential issues for admin" do
expect(milestone.percent_complete(admin)).to eq 60
end
end
- describe '#remaining_days' do
- it 'shows 0 if no due date' do
+ describe "#remaining_days" do
+ it "shows 0 if no due date" do
milestone = build_stubbed(:milestone)
expect(milestone.remaining_days).to eq(0)
end
- it 'shows 0 if expired' do
+ it "shows 0 if expired" do
milestone = build_stubbed(:milestone, due_date: 2.days.ago)
expect(milestone.remaining_days).to eq(0)
end
- it 'shows correct remaining days' do
+ it "shows correct remaining days" do
milestone = build_stubbed(:milestone, due_date: 2.days.from_now)
expect(milestone.remaining_days).to eq(2)
end
end
- describe '#elapsed_days' do
- it 'shows 0 if no start_date set' do
+ describe "#elapsed_days" do
+ it "shows 0 if no start_date set" do
milestone = build_stubbed(:milestone)
expect(milestone.elapsed_days).to eq(0)
end
- it 'shows 0 if start_date is a future' do
+ it "shows 0 if start_date is a future" do
milestone = build_stubbed(:milestone, start_date: Time.now + 2.days)
expect(milestone.elapsed_days).to eq(0)
end
- it 'shows correct amount of days' do
+ it "shows correct amount of days" do
milestone = build_stubbed(:milestone, start_date: Time.now - 2.days)
expect(milestone.elapsed_days).to eq(2)
end
end
- describe '#total_issue_time_spent' do
- it 'calculates total issue time spent' do
+ describe "#total_issue_time_spent" do
+ it "calculates total issue time spent" do
closed_issue_1.spend_time(duration: 300, user_id: author.id)
closed_issue_1.save!
closed_issue_2.spend_time(duration: 600, user_id: assignee.id)
@@ -198,8 +198,8 @@ describe Milestone, 'Milestoneish' do
end
end
- describe '#human_total_issue_time_spent' do
- it 'returns nil if no time has been spent' do
+ describe "#human_total_issue_time_spent" do
+ it "returns nil if no time has been spent" do
expect(milestone.human_total_issue_time_spent).to be_nil
end
end
diff --git a/spec/models/concerns/noteable_spec.rb b/spec/models/concerns/noteable_spec.rb
index 485a6e165a1..760b6c50679 100644
--- a/spec/models/concerns/noteable_spec.rb
+++ b/spec/models/concerns/noteable_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Noteable do
let!(:active_diff_note1) { create(:diff_note_on_merge_request) }
@@ -40,10 +40,10 @@ describe Noteable do
)
end
- describe '#discussions' do
+ describe "#discussions" do
let(:discussions) { subject.discussions }
- it 'includes discussions for diff notes, commit diff notes, commit notes, and regular notes' do
+ it "includes discussions for diff notes, commit diff notes, commit notes, and regular notes" do
expect(discussions).to eq([
DiffDiscussion.new([active_diff_note1, active_diff_note2], subject),
DiffDiscussion.new([active_diff_note3], subject),
@@ -54,12 +54,12 @@ describe Noteable do
Discussion.new([commit_discussion_note1, commit_discussion_note2], subject),
Discussion.new([commit_discussion_note3], subject),
IndividualNoteDiscussion.new([note1], subject),
- IndividualNoteDiscussion.new([note2], subject)
+ IndividualNoteDiscussion.new([note2], subject),
])
end
end
- describe '#grouped_diff_discussions' do
+ describe "#grouped_diff_discussions" do
let(:grouped_diff_discussions) { subject.grouped_diff_discussions }
it "includes active discussions" do
@@ -225,34 +225,34 @@ describe Noteable do
allow(third_discussion).to receive(:to_be_resolved?).and_return(false)
end
- it 'includes only discussions that need to be resolved' do
+ it "includes only discussions that need to be resolved" do
expect(subject.discussions_to_be_resolved).to eq([first_discussion])
end
end
- describe '#discussions_can_be_resolved_by?' do
+ describe "#discussions_can_be_resolved_by?" do
let(:user) { build(:user) }
- context 'all discussions can be resolved by the user' do
+ context "all discussions can be resolved by the user" do
before do
allow(first_discussion).to receive(:can_resolve?).with(user).and_return(true)
allow(second_discussion).to receive(:can_resolve?).with(user).and_return(true)
allow(third_discussion).to receive(:can_resolve?).with(user).and_return(true)
end
- it 'allows a user to resolve the discussions' do
+ it "allows a user to resolve the discussions" do
expect(subject.discussions_can_be_resolved_by?(user)).to be(true)
end
end
- context 'one discussion cannot be resolved by the user' do
+ context "one discussion cannot be resolved by the user" do
before do
allow(first_discussion).to receive(:can_resolve?).with(user).and_return(true)
allow(second_discussion).to receive(:can_resolve?).with(user).and_return(true)
allow(third_discussion).to receive(:can_resolve?).with(user).and_return(false)
end
- it 'allows a user to resolve the discussions' do
+ it "allows a user to resolve the discussions" do
expect(subject.discussions_can_be_resolved_by?(user)).to be(false)
end
end
diff --git a/spec/models/concerns/optionally_search_spec.rb b/spec/models/concerns/optionally_search_spec.rb
index ff4212ddf18..c03fd2ab391 100644
--- a/spec/models/concerns/optionally_search_spec.rb
+++ b/spec/models/concerns/optionally_search_spec.rb
@@ -1,42 +1,42 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe OptionallySearch do
let(:model) do
Class.new(ActiveRecord::Base) do
- self.table_name = 'users'
+ self.table_name = "users"
include OptionallySearch
end
end
- describe '.search' do
- it 'raises NotImplementedError' do
- expect { model.search('foo') }.to raise_error(NotImplementedError)
+ describe ".search" do
+ it "raises NotImplementedError" do
+ expect { model.search("foo") }.to raise_error(NotImplementedError)
end
end
- describe '.optionally_search' do
- context 'when a query is given' do
- it 'delegates to the search method' do
+ describe ".optionally_search" do
+ context "when a query is given" do
+ it "delegates to the search method" do
expect(model)
.to receive(:search)
- .with('foo')
+ .with("foo")
- model.optionally_search('foo')
+ model.optionally_search("foo")
end
end
- context 'when no query is given' do
- it 'returns the current relation' do
+ context "when no query is given" do
+ it "returns the current relation" do
expect(model.optionally_search).to be_a_kind_of(ActiveRecord::Relation)
end
end
- context 'when an empty query is given' do
- it 'returns the current relation' do
- expect(model.optionally_search(''))
+ context "when an empty query is given" do
+ it "returns the current relation" do
+ expect(model.optionally_search(""))
.to be_a_kind_of(ActiveRecord::Relation)
end
end
diff --git a/spec/models/concerns/participable_spec.rb b/spec/models/concerns/participable_spec.rb
index 431f1482615..4fb5204474f 100644
--- a/spec/models/concerns/participable_spec.rb
+++ b/spec/models/concerns/participable_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Participable do
let(:model) do
@@ -7,8 +7,8 @@ describe Participable do
end
end
- describe '.participant' do
- it 'adds the participant attributes to the existing list' do
+ describe ".participant" do
+ it "adds the participant attributes to the existing list" do
model.participant(:foo)
model.participant(:bar)
@@ -16,8 +16,8 @@ describe Participable do
end
end
- describe '#participants' do
- it 'returns the list of participants' do
+ describe "#participants" do
+ it "returns the list of participants" do
model.participant(:foo)
model.participant(:bar)
@@ -37,7 +37,7 @@ describe Participable do
expect(participants).to include(user3)
end
- it 'caches the raw list of participants' do
+ it "caches the raw list of participants" do
instance = model.new
user1 = build(:user)
@@ -47,7 +47,7 @@ describe Participable do
instance.participants(user1)
end
- it 'supports attributes returning another Participable' do
+ it "supports attributes returning another Participable" do
other_model = Class.new { include Participable }
other_model.participant(:bar)
@@ -66,15 +66,15 @@ describe Participable do
expect(instance.participants(user1)).to eq([user2])
end
- context 'when using a Proc as an attribute' do
- it 'calls the supplied Proc' do
+ context "when using a Proc as an attribute" do
+ it "calls the supplied Proc" do
user1 = build(:user)
project = build(:project, :public)
user_arg = nil
ext_arg = nil
- model.participant -> (user, ext) do
+ model.participant ->(user, ext) do
user_arg = user
ext_arg = ext
end
diff --git a/spec/models/concerns/presentable_spec.rb b/spec/models/concerns/presentable_spec.rb
index 941647a79fb..ce31c9193b8 100644
--- a/spec/models/concerns/presentable_spec.rb
+++ b/spec/models/concerns/presentable_spec.rb
@@ -1,15 +1,15 @@
-require 'spec_helper'
+require "spec_helper"
describe Presentable do
let(:build) { Ci::Build.new }
- describe '#present' do
- it 'returns a presenter' do
+ describe "#present" do
+ it "returns a presenter" do
expect(build.present).to be_a(Ci::BuildPresenter)
end
- it 'takes optional attributes' do
- expect(build.present(foo: 'bar').foo).to eq('bar')
+ it "takes optional attributes" do
+ expect(build.present(foo: "bar").foo).to eq("bar")
end
end
end
diff --git a/spec/models/concerns/project_features_compatibility_spec.rb b/spec/models/concerns/project_features_compatibility_spec.rb
index 9041690023f..b05f51c8656 100644
--- a/spec/models/concerns/project_features_compatibility_spec.rb
+++ b/spec/models/concerns/project_features_compatibility_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
+require "spec_helper"
describe ProjectFeaturesCompatibility do
let(:project) { create(:project) }
- let(:features) { %w(issues wiki builds merge_requests snippets) }
+ let(:features) { %w[issues wiki builds merge_requests snippets] }
# We had issues_enabled, snippets_enabled, builds_enabled, merge_requests_enabled and issues_enabled fields on projects table
# All those fields got moved to a new table called project_feature and are now integers instead of booleans
diff --git a/spec/models/concerns/prometheus_adapter_spec.rb b/spec/models/concerns/prometheus_adapter_spec.rb
index f4b9c57e71a..6b6681a1d69 100644
--- a/spec/models/concerns/prometheus_adapter_spec.rb
+++ b/spec/models/concerns/prometheus_adapter_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe PrometheusAdapter, :use_clean_rails_memory_store_caching do
include PrometheusHelpers
@@ -14,32 +14,32 @@ describe PrometheusAdapter, :use_clean_rails_memory_store_caching do
let(:described_class) { TestClass }
let(:environment_query) { Gitlab::Prometheus::Queries::EnvironmentQuery }
- describe '#query' do
- describe 'environment' do
- let(:environment) { build_stubbed(:environment, slug: 'env-slug') }
+ describe "#query" do
+ describe "environment" do
+ let(:environment) { build_stubbed(:environment, slug: "env-slug") }
around do |example|
Timecop.freeze { example.run }
end
- context 'with valid data' do
+ context "with valid data" do
subject { service.query(:environment, environment) }
before do
stub_reactive_cache(service, prometheus_data, environment_query, environment.id)
end
- it 'returns reactive data' do
+ it "returns reactive data" do
is_expected.to eq(prometheus_metrics_data)
end
end
end
- describe 'matched_metrics' do
+ describe "matched_metrics" do
let(:matched_metrics_query) { Gitlab::Prometheus::Queries::MatchedMetricQuery }
let(:prometheus_client_wrapper) { double(:prometheus_client_wrapper, label_values: nil) }
- context 'with valid data' do
+ context "with valid data" do
subject { service.query(:matched_metrics) }
before do
@@ -47,14 +47,14 @@ describe PrometheusAdapter, :use_clean_rails_memory_store_caching do
synchronous_reactive_cache(service)
end
- it 'returns reactive data' do
+ it "returns reactive data" do
expect(subject[:success]).to be_truthy
expect(subject[:data]).to eq([])
end
end
end
- describe 'deployment' do
+ describe "deployment" do
let(:deployment) { build_stubbed(:deployment) }
let(:deployment_query) { Gitlab::Prometheus::Queries::DeploymentQuery }
@@ -62,22 +62,22 @@ describe PrometheusAdapter, :use_clean_rails_memory_store_caching do
Timecop.freeze { example.run }
end
- context 'with valid data' do
+ context "with valid data" do
subject { service.query(:deployment, deployment) }
before do
stub_reactive_cache(service, prometheus_data, deployment_query, deployment.id)
end
- it 'returns reactive data' do
+ it "returns reactive data" do
expect(subject).to eq(prometheus_metrics_data)
end
end
end
end
- describe '#calculate_reactive_cache' do
- let(:environment) { create(:environment, slug: 'env-slug') }
+ describe "#calculate_reactive_cache" do
+ let(:environment) { create(:environment, slug: "env-slug") }
before do
service.manual_configuration = true
service.active = true
@@ -91,7 +91,7 @@ describe PrometheusAdapter, :use_clean_rails_memory_store_caching do
Timecop.freeze { example.run }
end
- context 'when service is inactive' do
+ context "when service is inactive" do
before do
service.active = false
end
@@ -99,7 +99,7 @@ describe PrometheusAdapter, :use_clean_rails_memory_store_caching do
it { is_expected.to be_nil }
end
- context 'when Prometheus responds with valid data' do
+ context "when Prometheus responds with valid data" do
before do
stub_all_prometheus_requests(environment.slug)
end
diff --git a/spec/models/concerns/protected_ref_access_spec.rb b/spec/models/concerns/protected_ref_access_spec.rb
index ce602337647..b328b74ca3e 100644
--- a/spec/models/concerns/protected_ref_access_spec.rb
+++ b/spec/models/concerns/protected_ref_access_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe ProtectedRefAccess do
subject(:protected_ref_access) do
@@ -7,21 +7,21 @@ describe ProtectedRefAccess do
let(:project) { protected_ref_access.project }
- describe '#check_access' do
- it 'is always true for admins' do
+ describe "#check_access" do
+ it "is always true for admins" do
admin = create(:admin)
expect(protected_ref_access.check_access(admin)).to be_truthy
end
- it 'is true for maintainers' do
+ it "is true for maintainers" do
maintainer = create(:user)
project.add_maintainer(maintainer)
expect(protected_ref_access.check_access(maintainer)).to be_truthy
end
- it 'is for developers of the project' do
+ it "is for developers of the project" do
developer = create(:user)
project.add_developer(developer)
diff --git a/spec/models/concerns/reactive_caching_spec.rb b/spec/models/concerns/reactive_caching_spec.rb
index 03ae45e6b17..47522c81c0d 100644
--- a/spec/models/concerns/reactive_caching_spec.rb
+++ b/spec/models/concerns/reactive_caching_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe ReactiveCaching, :use_clean_rails_memory_store_caching do
include ExclusiveLeaseHelpers
@@ -34,23 +34,23 @@ describe ReactiveCaching, :use_clean_rails_memory_store_caching do
let(:cache_key) { "foo:666" }
let(:instance) { CacheTest.new(666, &calculation) }
- describe '#with_reactive_cache' do
+ describe "#with_reactive_cache" do
before do
stub_reactive_cache
end
subject(:go!) { instance.result }
- context 'when cache is empty' do
+ context "when cache is empty" do
it { is_expected.to be_nil }
- it 'enqueues a background worker to bootstrap the cache' do
+ it "enqueues a background worker to bootstrap the cache" do
expect(ReactiveCachingWorker).to receive(:perform_async).with(CacheTest, 666)
go!
end
- it 'updates the cache lifespan' do
+ it "updates the cache lifespan" do
expect(reactive_cache_alive?(instance)).to be_falsy
go!
@@ -59,26 +59,26 @@ describe ReactiveCaching, :use_clean_rails_memory_store_caching do
end
end
- context 'when the cache is full' do
+ context "when the cache is full" do
before do
stub_reactive_cache(instance, 4)
end
it { is_expected.to eq(4) }
- it 'does not enqueue a background worker' do
+ it "does not enqueue a background worker" do
expect(ReactiveCachingWorker).not_to receive(:perform_async)
go!
end
- it 'updates the cache lifespan' do
+ it "updates the cache lifespan" do
expect(Rails.cache).to receive(:write).with(alive_reactive_cache_key(instance), true, expires_in: anything)
go!
end
- context 'and expired' do
+ context "and expired" do
before do
invalidate_reactive_cache(instance)
end
@@ -86,8 +86,8 @@ describe ReactiveCaching, :use_clean_rails_memory_store_caching do
it { is_expected.to be_nil }
end
- context 'when cache was invalidated' do
- it 'refreshes cache' do
+ context "when cache was invalidated" do
+ it "refreshes cache" do
expect(ReactiveCachingWorker).to receive(:perform_async).with(CacheTest, 666)
instance.with_reactive_cache { raise described_class::InvalidateReactiveCache }
@@ -95,7 +95,7 @@ describe ReactiveCaching, :use_clean_rails_memory_store_caching do
end
end
- context 'when cache contains non-nil but blank value' do
+ context "when cache contains non-nil but blank value" do
before do
stub_reactive_cache(instance, false)
end
@@ -104,7 +104,7 @@ describe ReactiveCaching, :use_clean_rails_memory_store_caching do
end
end
- describe '#clear_reactive_cache!' do
+ describe "#clear_reactive_cache!" do
before do
stub_reactive_cache(instance, 4)
instance.clear_reactive_cache!
@@ -114,22 +114,22 @@ describe ReactiveCaching, :use_clean_rails_memory_store_caching do
it { expect(reactive_cache_alive?(instance)).to be_falsy }
end
- describe '#exclusively_update_reactive_cache!' do
+ describe "#exclusively_update_reactive_cache!" do
subject(:go!) { instance.exclusively_update_reactive_cache! }
- context 'when the lease is free and lifetime is not exceeded' do
+ context "when the lease is free and lifetime is not exceeded" do
before do
stub_reactive_cache(instance, "preexisting")
end
- it 'takes and releases the lease' do
- expect_to_obtain_exclusive_lease(cache_key, 'uuid')
- expect_to_cancel_exclusive_lease(cache_key, 'uuid')
+ it "takes and releases the lease" do
+ expect_to_obtain_exclusive_lease(cache_key, "uuid")
+ expect_to_cancel_exclusive_lease(cache_key, "uuid")
go!
end
- it 'caches the result of #calculate_reactive_cache' do
+ it "caches the result of #calculate_reactive_cache" do
go!
expect(read_reactive_cache(instance)).to eq(calculation.call)
@@ -148,19 +148,19 @@ describe ReactiveCaching, :use_clean_rails_memory_store_caching do
2.times { instance.exclusively_update_reactive_cache! }
end
- context 'and #calculate_reactive_cache raises an exception' do
+ context "and #calculate_reactive_cache raises an exception" do
before do
stub_reactive_cache(instance, "preexisting")
end
let(:calculation) { -> { raise "foo"} }
- it 'leaves the cache untouched' do
+ it "leaves the cache untouched" do
expect { go! }.to raise_error("foo")
expect(read_reactive_cache(instance)).to eq("preexisting")
end
- it 'enqueues a repeat worker' do
+ it "enqueues a repeat worker" do
expect_reactive_cache_update_queued(instance)
expect { go! }.to raise_error("foo")
@@ -168,16 +168,16 @@ describe ReactiveCaching, :use_clean_rails_memory_store_caching do
end
end
- context 'when lifetime is exceeded' do
- it 'skips the calculation' do
+ context "when lifetime is exceeded" do
+ it "skips the calculation" do
expect(instance).to receive(:calculate_reactive_cache).never
go!
end
end
- context 'when the lease is already taken' do
- it 'skips the calculation' do
+ context "when the lease is already taken" do
+ it "skips the calculation" do
stub_exclusive_lease_taken(cache_key)
expect(instance).to receive(:calculate_reactive_cache).never
diff --git a/spec/models/concerns/redactable_spec.rb b/spec/models/concerns/redactable_spec.rb
index 7feeaa54069..156893fcc50 100644
--- a/spec/models/concerns/redactable_spec.rb
+++ b/spec/models/concerns/redactable_spec.rb
@@ -1,21 +1,21 @@
-require 'spec_helper'
+require "spec_helper"
describe Redactable do
before do
stub_commonmark_sourcepos_disabled
end
- shared_examples 'model with redactable field' do
- it 'redacts unsubscribe token' do
- model[field] = 'some text /sent_notifications/00000000000000000000000000000000/unsubscribe more text'
+ shared_examples "model with redactable field" do
+ it "redacts unsubscribe token" do
+ model[field] = "some text /sent_notifications/00000000000000000000000000000000/unsubscribe more text"
model.save!
- expect(model[field]).to eq 'some text /sent_notifications/REDACTED/unsubscribe more text'
+ expect(model[field]).to eq "some text /sent_notifications/REDACTED/unsubscribe more text"
end
- it 'ignores not hexadecimal tokens' do
- text = 'some text /sent_notifications/token/unsubscribe more text'
+ it "ignores not hexadecimal tokens" do
+ text = "some text /sent_notifications/token/unsubscribe more text"
model[field] = text
model.save!
@@ -23,8 +23,8 @@ describe Redactable do
expect(model[field]).to eq text
end
- it 'ignores not matching texts' do
- text = 'some text /sent_notifications/.*/unsubscribe more text'
+ it "ignores not matching texts" do
+ text = "some text /sent_notifications/.*/unsubscribe more text"
model[field] = text
model.save!
@@ -32,40 +32,40 @@ describe Redactable do
expect(model[field]).to eq text
end
- it 'redacts the field when saving the model before creating markdown cache' do
- model[field] = 'some text /sent_notifications/00000000000000000000000000000000/unsubscribe more text'
+ it "redacts the field when saving the model before creating markdown cache" do
+ model[field] = "some text /sent_notifications/00000000000000000000000000000000/unsubscribe more text"
model.save!
- expected = 'some text /sent_notifications/REDACTED/unsubscribe more text'
+ expected = "some text /sent_notifications/REDACTED/unsubscribe more text"
expect(model[field]).to eq expected
expect(model["#{field}_html"]).to eq "<p dir=\"auto\">#{expected}</p>"
end
end
- context 'when model is an issue' do
- it_behaves_like 'model with redactable field' do
+ context "when model is an issue" do
+ it_behaves_like "model with redactable field" do
let(:model) { create(:issue) }
let(:field) { :description }
end
end
- context 'when model is a merge request' do
- it_behaves_like 'model with redactable field' do
+ context "when model is a merge request" do
+ it_behaves_like "model with redactable field" do
let(:model) { create(:merge_request) }
let(:field) { :description }
end
end
- context 'when model is a note' do
- it_behaves_like 'model with redactable field' do
+ context "when model is a note" do
+ it_behaves_like "model with redactable field" do
let(:model) { create(:note) }
let(:field) { :note }
end
end
- context 'when model is a snippet' do
- it_behaves_like 'model with redactable field' do
+ context "when model is a snippet" do
+ it_behaves_like "model with redactable field" do
let(:model) { create(:snippet) }
let(:field) { :description }
end
diff --git a/spec/models/concerns/redis_cacheable_spec.rb b/spec/models/concerns/redis_cacheable_spec.rb
index 23c6c6233e9..7e1efb8af04 100644
--- a/spec/models/concerns/redis_cacheable_spec.rb
+++ b/spec/models/concerns/redis_cacheable_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe RedisCacheable do
let(:model) do
@@ -12,12 +12,12 @@ describe RedisCacheable do
end
def has_attribute?(attribute)
- attributes.has_key?(attribute)
+ attributes.key?(attribute)
end
end
end
- let(:payload) { { name: 'value', time: Time.zone.now } }
+ let(:payload) { {name: "value", time: Time.zone.now} }
let(:instance) { model.new(1, payload) }
let(:cache_key) { instance.__send__(:cache_attribute_key) }
@@ -25,10 +25,10 @@ describe RedisCacheable do
model.include(described_class)
end
- describe '#cached_attribute' do
+ describe "#cached_attribute" do
subject { instance.cached_attribute(payload.keys.first) }
- it 'gets the cache attribute' do
+ it "gets the cache attribute" do
Gitlab::Redis::SharedState.with do |redis|
expect(redis).to receive(:get).with(cache_key)
.and_return(payload.to_json)
@@ -38,10 +38,10 @@ describe RedisCacheable do
end
end
- describe '#cache_attributes' do
+ describe "#cache_attributes" do
subject { instance.cache_attributes(payload) }
- it 'sets the cache attributes' do
+ it "sets the cache attributes" do
Gitlab::Redis::SharedState.with do |redis|
expect(redis).to receive(:set).with(cache_key, payload.to_json, anything)
end
@@ -50,23 +50,23 @@ describe RedisCacheable do
end
end
- describe '#cached_attr_reader', :clean_gitlab_redis_shared_state do
+ describe "#cached_attr_reader", :clean_gitlab_redis_shared_state do
subject { instance.name }
before do
model.cached_attr_reader(:name)
end
- context 'when there is no cached value' do
- it 'reads the attribute' do
+ context "when there is no cached value" do
+ it "reads the attribute" do
expect(instance).to receive(:read_attribute).and_call_original
expect(subject).to eq(payload[:name])
end
end
- context 'when there is a cached value' do
- it 'reads the cached value' do
+ context "when there is a cached value" do
+ it "reads the cached value" do
expect(instance).not_to receive(:read_attribute)
instance.cache_attributes(payload)
@@ -75,24 +75,24 @@ describe RedisCacheable do
end
end
- it 'always returns the latest values' do
+ it "always returns the latest values" do
expect(instance.name).to eq(payload[:name])
- instance.cache_attributes(name: 'new_value')
+ instance.cache_attributes(name: "new_value")
- expect(instance.name).to eq('new_value')
+ expect(instance.name).to eq("new_value")
end
end
- describe '#cast_value_from_cache' do
+ describe "#cast_value_from_cache" do
subject { instance.__send__(:cast_value_from_cache, attribute, value) }
- context 'with runner contacted_at' do
+ context "with runner contacted_at" do
let(:instance) { Ci::Runner.new }
let(:attribute) { :contacted_at }
- let(:value) { '2018-05-07 13:53:08 UTC' }
+ let(:value) { "2018-05-07 13:53:08 UTC" }
- it 'converts cache string to appropriate type' do
+ it "converts cache string to appropriate type" do
expect(subject).to be_an_instance_of(ActiveSupport::TimeWithZone)
end
end
diff --git a/spec/models/concerns/relative_positioning_spec.rb b/spec/models/concerns/relative_positioning_spec.rb
index ac8da30b6c9..53adf192524 100644
--- a/spec/models/concerns/relative_positioning_spec.rb
+++ b/spec/models/concerns/relative_positioning_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe RelativePositioning do
let(:project) { create(:project) }
@@ -6,8 +6,8 @@ describe RelativePositioning do
let(:issue1) { create(:issue, project: project) }
let(:new_issue) { create(:issue, project: project) }
- describe '.move_to_end' do
- it 'moves the object to the end' do
+ describe ".move_to_end" do
+ it "moves the object to the end" do
Issue.move_to_end([issue, issue1])
expect(issue1.prev_relative_position).to eq issue.relative_position
@@ -15,7 +15,7 @@ describe RelativePositioning do
expect(issue1.next_relative_position).to eq nil
end
- it 'does not perform any moves if all issues have their relative_position set' do
+ it "does not perform any moves if all issues have their relative_position set" do
issue.update!(relative_position: 1)
expect(issue).not_to receive(:save)
@@ -24,34 +24,34 @@ describe RelativePositioning do
end
end
- describe '#max_relative_position' do
- it 'returns maximum position' do
+ describe "#max_relative_position" do
+ it "returns maximum position" do
expect(issue.max_relative_position).to eq issue1.relative_position
end
end
- describe '#prev_relative_position' do
- it 'returns previous position if there is an issue above' do
+ describe "#prev_relative_position" do
+ it "returns previous position if there is an issue above" do
expect(issue1.prev_relative_position).to eq issue.relative_position
end
- it 'returns nil if there is no issue above' do
+ it "returns nil if there is no issue above" do
expect(issue.prev_relative_position).to eq nil
end
end
- describe '#next_relative_position' do
- it 'returns next position if there is an issue below' do
+ describe "#next_relative_position" do
+ it "returns next position if there is an issue below" do
expect(issue.next_relative_position).to eq issue1.relative_position
end
- it 'returns nil if there is no issue below' do
+ it "returns nil if there is no issue below" do
expect(issue1.next_relative_position).to eq nil
end
end
- describe '#move_before' do
- it 'moves issue before' do
+ describe "#move_before" do
+ it "moves issue before" do
[issue1, issue].each(&:move_to_end)
issue.move_before(issue1)
@@ -60,8 +60,8 @@ describe RelativePositioning do
end
end
- describe '#move_after' do
- it 'moves issue after' do
+ describe "#move_after" do
+ it "moves issue after" do
[issue, issue1].each(&:move_to_end)
issue.move_after(issue1)
@@ -70,87 +70,87 @@ describe RelativePositioning do
end
end
- describe '#move_to_end' do
+ describe "#move_to_end" do
before do
[issue, issue1].each do |issue|
issue.move_to_end && issue.save
end
end
- it 'moves issue to the end' do
+ it "moves issue to the end" do
new_issue.move_to_end
expect(new_issue.relative_position).to be > issue1.relative_position
end
end
- describe '#shift_after?' do
+ describe "#shift_after?" do
before do
[issue, issue1].each do |issue|
issue.move_to_end && issue.save
end
end
- it 'returns true' do
+ it "returns true" do
issue.update(relative_position: issue1.relative_position - 1)
expect(issue.shift_after?).to be_truthy
end
- it 'returns false' do
+ it "returns false" do
issue.update(relative_position: issue1.relative_position - 2)
expect(issue.shift_after?).to be_falsey
end
end
- describe '#shift_before?' do
+ describe "#shift_before?" do
before do
[issue, issue1].each do |issue|
issue.move_to_end && issue.save
end
end
- it 'returns true' do
+ it "returns true" do
issue.update(relative_position: issue1.relative_position + 1)
expect(issue.shift_before?).to be_truthy
end
- it 'returns false' do
+ it "returns false" do
issue.update(relative_position: issue1.relative_position + 2)
expect(issue.shift_before?).to be_falsey
end
end
- describe '#move_between' do
+ describe "#move_between" do
before do
[issue, issue1].each do |issue|
issue.move_to_end && issue.save
end
end
- it 'positions issue between two other' do
+ it "positions issue between two other" do
new_issue.move_between(issue, issue1)
expect(new_issue.relative_position).to be > issue.relative_position
expect(new_issue.relative_position).to be < issue1.relative_position
end
- it 'positions issue between on top' do
+ it "positions issue between on top" do
new_issue.move_between(nil, issue)
expect(new_issue.relative_position).to be < issue.relative_position
end
- it 'positions issue between to end' do
+ it "positions issue between to end" do
new_issue.move_between(issue1, nil)
expect(new_issue.relative_position).to be > issue1.relative_position
end
- it 'positions issues even when after and before positions are the same' do
+ it "positions issues even when after and before positions are the same" do
issue1.update relative_position: issue.relative_position
new_issue.move_between(issue, issue1)
@@ -159,7 +159,7 @@ describe RelativePositioning do
expect(issue.relative_position).to be < issue1.relative_position
end
- it 'positions issues between other two if distance is 1' do
+ it "positions issues between other two if distance is 1" do
issue1.update relative_position: issue.relative_position + 1
new_issue.move_between(issue, issue1)
@@ -168,7 +168,7 @@ describe RelativePositioning do
expect(issue.relative_position).to be < issue1.relative_position
end
- it 'positions issue in the middle of other two if distance is big enough' do
+ it "positions issue in the middle of other two if distance is big enough" do
issue.update relative_position: 6000
issue1.update relative_position: 10000
@@ -177,7 +177,7 @@ describe RelativePositioning do
expect(new_issue.relative_position).to eq(8000)
end
- it 'positions issue closer to the middle if we are at the very top' do
+ it "positions issue closer to the middle if we are at the very top" do
issue1.update relative_position: 6000
new_issue.move_between(nil, issue1)
@@ -185,7 +185,7 @@ describe RelativePositioning do
expect(new_issue.relative_position).to eq(6000 - RelativePositioning::IDEAL_DISTANCE)
end
- it 'positions issue closer to the middle if we are at the very bottom' do
+ it "positions issue closer to the middle if we are at the very bottom" do
issue.update relative_position: 6000
issue1.update relative_position: nil
@@ -194,7 +194,7 @@ describe RelativePositioning do
expect(new_issue.relative_position).to eq(6000 + RelativePositioning::IDEAL_DISTANCE)
end
- it 'positions issue in the middle of other two if distance is not big enough' do
+ it "positions issue in the middle of other two if distance is not big enough" do
issue.update relative_position: 100
issue1.update relative_position: 400
@@ -203,7 +203,7 @@ describe RelativePositioning do
expect(new_issue.relative_position).to eq(250)
end
- it 'positions issue in the middle of other two is there is no place' do
+ it "positions issue in the middle of other two is there is no place" do
issue.update relative_position: 100
issue1.update relative_position: 101
@@ -212,7 +212,7 @@ describe RelativePositioning do
expect(new_issue.relative_position).to be_between(issue.relative_position, issue1.relative_position)
end
- it 'uses rebalancing if there is no place' do
+ it "uses rebalancing if there is no place" do
issue.update relative_position: 100
issue1.update relative_position: 101
issue2 = create(:issue, relative_position: 102, project: project)
@@ -225,7 +225,7 @@ describe RelativePositioning do
expect(issue.reload.relative_position).not_to eq(100)
end
- it 'positions issue right if we pass none-sequential parameters' do
+ it "positions issue right if we pass none-sequential parameters" do
issue.update relative_position: 99
issue1.update relative_position: 101
issue2 = create(:issue, relative_position: 102, project: project)
diff --git a/spec/models/concerns/resolvable_discussion_spec.rb b/spec/models/concerns/resolvable_discussion_spec.rb
index 97b046b0f21..45d689c731f 100644
--- a/spec/models/concerns/resolvable_discussion_spec.rb
+++ b/spec/models/concerns/resolvable_discussion_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Discussion, ResolvableDiscussion do
subject { described_class.new([first_note, second_note, third_note]) }
diff --git a/spec/models/concerns/resolvable_note_spec.rb b/spec/models/concerns/resolvable_note_spec.rb
index fcb5250278e..6800688b84c 100644
--- a/spec/models/concerns/resolvable_note_spec.rb
+++ b/spec/models/concerns/resolvable_note_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe Note, ResolvableNote do
let(:project) { create(:project, :repository) }
let(:merge_request) { create(:merge_request, source_project: project) }
subject { create(:discussion_note_on_merge_request, noteable: merge_request, project: project) }
- context 'resolvability scopes' do
+ context "resolvability scopes" do
let!(:note1) { create(:note, project: project) }
let!(:note2) { create(:diff_note_on_commit, project: project) }
let!(:note3) { create(:diff_note_on_merge_request, :resolved, noteable: merge_request, project: project) }
@@ -13,26 +13,26 @@ describe Note, ResolvableNote do
let!(:note5) { create(:discussion_note_on_issue, project: project) }
let!(:note6) { create(:discussion_note_on_merge_request, :system, noteable: merge_request, project: project) }
- describe '.potentially_resolvable' do
- it 'includes diff and discussion notes on merge requests' do
+ describe ".potentially_resolvable" do
+ it "includes diff and discussion notes on merge requests" do
expect(Note.potentially_resolvable).to match_array([note3, note4, note6])
end
end
- describe '.resolvable' do
- it 'includes non-system diff and discussion notes on merge requests' do
+ describe ".resolvable" do
+ it "includes non-system diff and discussion notes on merge requests" do
expect(Note.resolvable).to match_array([note3, note4])
end
end
- describe '.resolved' do
- it 'includes resolved non-system diff and discussion notes on merge requests' do
+ describe ".resolved" do
+ it "includes resolved non-system diff and discussion notes on merge requests" do
expect(Note.resolved).to match_array([note3])
end
end
- describe '.unresolved' do
- it 'includes non-resolved non-system diff and discussion notes on merge requests' do
+ describe ".unresolved" do
+ it "includes non-resolved non-system diff and discussion notes on merge requests" do
expect(Note.unresolved).to match_array([note4])
end
end
@@ -52,7 +52,7 @@ describe Note, ResolvableNote do
unresolved_note.reload
end
- it 'resolves only the resolvable, not yet resolved notes' do
+ it "resolves only the resolvable, not yet resolved notes" do
expect(commit_note.resolved_at).to be_nil
expect(resolved_note.resolved_by).not_to eq(current_user)
expect(unresolved_note.resolved_at).not_to be_nil
@@ -69,13 +69,13 @@ describe Note, ResolvableNote do
resolved_note.reload
end
- it 'unresolves the resolved notes' do
+ it "unresolves the resolved notes" do
expect(resolved_note.resolved_by).to be_nil
expect(resolved_note.resolved_at).to be_nil
end
end
- describe '#resolvable?' do
+ describe "#resolvable?" do
context "when potentially resolvable" do
before do
allow(subject).to receive(:potentially_resolvable?).and_return(true)
@@ -150,31 +150,31 @@ describe Note, ResolvableNote do
describe "#resolved?" do
let(:current_user) { create(:user) }
- context 'when not resolvable' do
+ context "when not resolvable" do
before do
subject.resolve!(current_user)
allow(subject).to receive(:resolvable?).and_return(false)
end
- it 'returns false' do
+ it "returns false" do
expect(subject.resolved?).to be_falsey
end
end
- context 'when resolvable' do
- context 'when the note has been resolved' do
+ context "when resolvable" do
+ context "when the note has been resolved" do
before do
subject.resolve!(current_user)
end
- it 'returns true' do
+ it "returns true" do
expect(subject.resolved?).to be_truthy
end
end
- context 'when the note has not been resolved' do
- it 'returns false' do
+ context "when the note has not been resolved" do
+ it "returns false" do
expect(subject.resolved?).to be_falsey
end
end
@@ -328,7 +328,7 @@ describe Note, ResolvableNote do
end
describe "#potentially_resolvable?" do
- it 'returns false if noteable could not be found' do
+ it "returns false if noteable could not be found" do
allow(subject).to receive(:noteable).and_return(nil)
expect(subject.potentially_resolvable?).to be_falsey
diff --git a/spec/models/concerns/routable_spec.rb b/spec/models/concerns/routable_spec.rb
index 565266321d3..8d5566407bf 100644
--- a/spec/models/concerns/routable_spec.rb
+++ b/spec/models/concerns/routable_spec.rb
@@ -1,82 +1,82 @@
-require 'spec_helper'
+require "spec_helper"
-describe Group, 'Routable' do
- let!(:group) { create(:group, name: 'foo') }
+describe Group, "Routable" do
+ let!(:group) { create(:group, name: "foo") }
- describe 'Validations' do
+ describe "Validations" do
it { is_expected.to validate_presence_of(:route) }
end
- describe 'Associations' do
+ describe "Associations" do
it { is_expected.to have_one(:route).dependent(:destroy) }
it { is_expected.to have_many(:redirect_routes).dependent(:destroy) }
end
- describe 'Callbacks' do
- it 'creates route record on create' do
+ describe "Callbacks" do
+ it "creates route record on create" do
expect(group.route.path).to eq(group.path)
expect(group.route.name).to eq(group.name)
end
- it 'updates route record on path change' do
- group.update(path: 'wow', name: 'much')
+ it "updates route record on path change" do
+ group.update(path: "wow", name: "much")
- expect(group.route.path).to eq('wow')
- expect(group.route.name).to eq('much')
+ expect(group.route.path).to eq("wow")
+ expect(group.route.name).to eq("much")
end
- it 'ensure route path uniqueness across different objects' do
- create(:group, parent: group, path: 'xyz')
- duplicate = build(:project, namespace: group, path: 'xyz')
+ it "ensure route path uniqueness across different objects" do
+ create(:group, parent: group, path: "xyz")
+ duplicate = build(:project, namespace: group, path: "xyz")
- expect { duplicate.save! }.to raise_error(ActiveRecord::RecordInvalid, 'Validation failed: Path has already been taken')
+ expect { duplicate.save! }.to raise_error(ActiveRecord::RecordInvalid, "Validation failed: Path has already been taken")
end
end
- describe '.find_by_full_path' do
+ describe ".find_by_full_path" do
let!(:nested_group) { create(:group, parent: group) }
- context 'without any redirect routes' do
+ context "without any redirect routes" do
it { expect(described_class.find_by_full_path(group.to_param)).to eq(group) }
it { expect(described_class.find_by_full_path(group.to_param.upcase)).to eq(group) }
it { expect(described_class.find_by_full_path(nested_group.to_param)).to eq(nested_group) }
- it { expect(described_class.find_by_full_path('unknown')).to eq(nil) }
+ it { expect(described_class.find_by_full_path("unknown")).to eq(nil) }
end
- context 'with redirect routes' do
- let!(:group_redirect_route) { group.redirect_routes.create!(path: 'bar') }
- let!(:nested_group_redirect_route) { nested_group.redirect_routes.create!(path: nested_group.path.sub('foo', 'bar')) }
+ context "with redirect routes" do
+ let!(:group_redirect_route) { group.redirect_routes.create!(path: "bar") }
+ let!(:nested_group_redirect_route) { nested_group.redirect_routes.create!(path: nested_group.path.sub("foo", "bar")) }
- context 'without follow_redirects option' do
- context 'with the given path not matching any route' do
- it { expect(described_class.find_by_full_path('unknown')).to eq(nil) }
+ context "without follow_redirects option" do
+ context "with the given path not matching any route" do
+ it { expect(described_class.find_by_full_path("unknown")).to eq(nil) }
end
- context 'with the given path matching the canonical route' do
+ context "with the given path matching the canonical route" do
it { expect(described_class.find_by_full_path(group.to_param)).to eq(group) }
it { expect(described_class.find_by_full_path(group.to_param.upcase)).to eq(group) }
it { expect(described_class.find_by_full_path(nested_group.to_param)).to eq(nested_group) }
end
- context 'with the given path matching a redirect route' do
+ context "with the given path matching a redirect route" do
it { expect(described_class.find_by_full_path(group_redirect_route.path)).to eq(nil) }
it { expect(described_class.find_by_full_path(group_redirect_route.path.upcase)).to eq(nil) }
it { expect(described_class.find_by_full_path(nested_group_redirect_route.path)).to eq(nil) }
end
end
- context 'with follow_redirects option set to true' do
- context 'with the given path not matching any route' do
- it { expect(described_class.find_by_full_path('unknown', follow_redirects: true)).to eq(nil) }
+ context "with follow_redirects option set to true" do
+ context "with the given path not matching any route" do
+ it { expect(described_class.find_by_full_path("unknown", follow_redirects: true)).to eq(nil) }
end
- context 'with the given path matching the canonical route' do
+ context "with the given path matching the canonical route" do
it { expect(described_class.find_by_full_path(group.to_param, follow_redirects: true)).to eq(group) }
it { expect(described_class.find_by_full_path(group.to_param.upcase, follow_redirects: true)).to eq(group) }
it { expect(described_class.find_by_full_path(nested_group.to_param, follow_redirects: true)).to eq(nested_group) }
end
- context 'with the given path matching a redirect route' do
+ context "with the given path matching a redirect route" do
it { expect(described_class.find_by_full_path(group_redirect_route.path, follow_redirects: true)).to eq(group) }
it { expect(described_class.find_by_full_path(group_redirect_route.path.upcase, follow_redirects: true)).to eq(group) }
it { expect(described_class.find_by_full_path(nested_group_redirect_route.path, follow_redirects: true)).to eq(nested_group) }
@@ -85,29 +85,29 @@ describe Group, 'Routable' do
end
end
- describe '.where_full_path_in' do
- context 'without any paths' do
- it 'returns an empty relation' do
+ describe ".where_full_path_in" do
+ context "without any paths" do
+ it "returns an empty relation" do
expect(described_class.where_full_path_in([])).to eq([])
end
end
- context 'without any valid paths' do
- it 'returns an empty relation' do
+ context "without any valid paths" do
+ it "returns an empty relation" do
expect(described_class.where_full_path_in(%w[unknown])).to eq([])
end
end
- context 'with valid paths' do
+ context "with valid paths" do
let!(:nested_group) { create(:group, parent: group) }
- it 'returns the projects matching the paths' do
+ it "returns the projects matching the paths" do
result = described_class.where_full_path_in([group.to_param, nested_group.to_param])
expect(result).to contain_exactly(group, nested_group)
end
- it 'returns projects regardless of the casing of paths' do
+ it "returns projects regardless of the casing of paths" do
result = described_class.where_full_path_in([group.to_param.upcase, nested_group.to_param.upcase])
expect(result).to contain_exactly(group, nested_group)
@@ -115,7 +115,7 @@ describe Group, 'Routable' do
end
end
- describe '#full_path' do
+ describe "#full_path" do
let(:group) { create(:group) }
let(:nested_group) { create(:group, parent: group) }
@@ -123,7 +123,7 @@ describe Group, 'Routable' do
it { expect(nested_group.full_path).to eq("#{group.full_path}/#{nested_group.path}") }
end
- describe '#full_name' do
+ describe "#full_name" do
let(:group) { create(:group) }
let(:nested_group) { create(:group, parent: group) }
@@ -132,14 +132,14 @@ describe Group, 'Routable' do
end
end
-describe Project, 'Routable' do
- describe '#full_path' do
+describe Project, "Routable" do
+ describe "#full_path" do
let(:project) { build_stubbed(:project) }
it { expect(project.full_path).to eq "#{project.namespace.full_path}/#{project.path}" }
end
- describe '#full_name' do
+ describe "#full_name" do
let(:project) { build_stubbed(:project) }
it { expect(project.full_name).to eq "#{project.namespace.human_name} / #{project.name}" }
diff --git a/spec/models/concerns/sha_attribute_spec.rb b/spec/models/concerns/sha_attribute_spec.rb
index 0d3beb6a6e3..8675af673c0 100644
--- a/spec/models/concerns/sha_attribute_spec.rb
+++ b/spec/models/concerns/sha_attribute_spec.rb
@@ -1,42 +1,42 @@
-require 'spec_helper'
+require "spec_helper"
describe ShaAttribute do
let(:model) { Class.new { include ShaAttribute } }
before do
columns = [
- double(:column, name: 'name', type: :text),
- double(:column, name: 'sha1', type: :binary)
+ double(:column, name: "name", type: :text),
+ double(:column, name: "sha1", type: :binary),
]
allow(model).to receive(:columns).and_return(columns)
end
- describe '#sha_attribute' do
- context 'when in non-production' do
+ describe "#sha_attribute" do
+ context "when in non-production" do
before do
allow(Rails.env).to receive(:production?).and_return(false)
end
- context 'when the table exists' do
+ context "when the table exists" do
before do
allow(model).to receive(:table_exists?).and_return(true)
end
- it 'defines a SHA attribute for a binary column' do
+ it "defines a SHA attribute for a binary column" do
expect(model).to receive(:attribute)
.with(:sha1, an_instance_of(Gitlab::Database::ShaAttribute))
model.sha_attribute(:sha1)
end
- it 'raises ArgumentError when the column type is not :binary' do
+ it "raises ArgumentError when the column type is not :binary" do
expect { model.sha_attribute(:name) }.to raise_error(ArgumentError)
end
end
- context 'when the table does not exist' do
- it 'allows the attribute to be added and issues a warning' do
+ context "when the table does not exist" do
+ it "allows the attribute to be added and issues a warning" do
allow(model).to receive(:table_exists?).and_return(false)
expect(model).not_to receive(:columns)
@@ -47,8 +47,8 @@ describe ShaAttribute do
end
end
- context 'when the column does not exist' do
- it 'allows the attribute to be added and issues a warning' do
+ context "when the column does not exist" do
+ it "allows the attribute to be added and issues a warning" do
allow(model).to receive(:table_exists?).and_return(true)
expect(model).to receive(:columns)
@@ -59,9 +59,9 @@ describe ShaAttribute do
end
end
- context 'when other execeptions are raised' do
- it 'logs and re-rasises the error' do
- allow(model).to receive(:table_exists?).and_raise(ActiveRecord::NoDatabaseError.new('does not exist'))
+ context "when other execeptions are raised" do
+ it "logs and re-rasises the error" do
+ allow(model).to receive(:table_exists?).and_raise(ActiveRecord::NoDatabaseError.new("does not exist"))
expect(model).not_to receive(:columns)
expect(model).not_to receive(:attribute)
@@ -72,12 +72,12 @@ describe ShaAttribute do
end
end
- context 'when in production' do
+ context "when in production" do
before do
allow(Rails.env).to receive(:production?).and_return(true)
end
- it 'defines a SHA attribute' do
+ it "defines a SHA attribute" do
expect(model).not_to receive(:table_exists?)
expect(model).not_to receive(:columns)
expect(model).to receive(:attribute).with(:sha1, an_instance_of(Gitlab::Database::ShaAttribute))
diff --git a/spec/models/concerns/sortable_spec.rb b/spec/models/concerns/sortable_spec.rb
index 0a9d2021a19..c253f465b88 100644
--- a/spec/models/concerns/sortable_spec.rb
+++ b/spec/models/concerns/sortable_spec.rb
@@ -1,118 +1,118 @@
-require 'spec_helper'
+require "spec_helper"
describe Sortable do
- describe '.order_by' do
+ describe ".order_by" do
let(:relation) { Group.all }
- describe 'ordering by id' do
- it 'ascending' do
+ describe "ordering by id" do
+ it "ascending" do
expect(relation).to receive(:reorder).with(id: :asc)
- relation.order_by('id_asc')
+ relation.order_by("id_asc")
end
- it 'descending' do
+ it "descending" do
expect(relation).to receive(:reorder).with(id: :desc)
- relation.order_by('id_desc')
+ relation.order_by("id_desc")
end
end
- describe 'ordering by created day' do
- it 'ascending' do
+ describe "ordering by created day" do
+ it "ascending" do
expect(relation).to receive(:reorder).with(created_at: :asc)
- relation.order_by('created_asc')
+ relation.order_by("created_asc")
end
- it 'descending' do
+ it "descending" do
expect(relation).to receive(:reorder).with(created_at: :desc)
- relation.order_by('created_desc')
+ relation.order_by("created_desc")
end
it 'order by "date"' do
expect(relation).to receive(:reorder).with(created_at: :desc)
- relation.order_by('created_date')
+ relation.order_by("created_date")
end
end
- describe 'ordering by name' do
- it 'ascending' do
+ describe "ordering by name" do
+ it "ascending" do
expect(relation).to receive(:reorder).once.and_call_original
table = Regexp.escape(ActiveRecord::Base.connection.quote_table_name(:namespaces))
column = Regexp.escape(ActiveRecord::Base.connection.quote_column_name(:name))
- sql = relation.order_by('name_asc').to_sql
+ sql = relation.order_by("name_asc").to_sql
expect(sql).to match /.+ORDER BY LOWER\(#{table}.#{column}\) ASC\z/
end
- it 'descending' do
+ it "descending" do
expect(relation).to receive(:reorder).once.and_call_original
table = Regexp.escape(ActiveRecord::Base.connection.quote_table_name(:namespaces))
column = Regexp.escape(ActiveRecord::Base.connection.quote_column_name(:name))
- sql = relation.order_by('name_desc').to_sql
+ sql = relation.order_by("name_desc").to_sql
expect(sql).to match /.+ORDER BY LOWER\(#{table}.#{column}\) DESC\z/
end
end
- describe 'ordering by Updated Time' do
- it 'ascending' do
+ describe "ordering by Updated Time" do
+ it "ascending" do
expect(relation).to receive(:reorder).with(updated_at: :asc)
- relation.order_by('updated_asc')
+ relation.order_by("updated_asc")
end
- it 'descending' do
+ it "descending" do
expect(relation).to receive(:reorder).with(updated_at: :desc)
- relation.order_by('updated_desc')
+ relation.order_by("updated_desc")
end
end
- it 'does not call reorder in case of unrecognized ordering' do
+ it "does not call reorder in case of unrecognized ordering" do
expect(relation).not_to receive(:reorder)
- relation.order_by('random_ordering')
+ relation.order_by("random_ordering")
end
end
- describe 'sorting groups' do
+ describe "sorting groups" do
def ordered_group_names(order)
Group.all.order_by(order).map(&:name)
end
- let!(:ref_time) { Time.parse('2018-05-01 00:00:00') }
- let!(:group1) { create(:group, name: 'aa', id: 1, created_at: ref_time - 15.seconds, updated_at: ref_time) }
- let!(:group2) { create(:group, name: 'AAA', id: 2, created_at: ref_time - 10.seconds, updated_at: ref_time - 5.seconds) }
- let!(:group3) { create(:group, name: 'BB', id: 3, created_at: ref_time - 5.seconds, updated_at: ref_time - 10.seconds) }
- let!(:group4) { create(:group, name: 'bbb', id: 4, created_at: ref_time, updated_at: ref_time - 15.seconds) }
+ let!(:ref_time) { Time.parse("2018-05-01 00:00:00") }
+ let!(:group1) { create(:group, name: "aa", id: 1, created_at: ref_time - 15.seconds, updated_at: ref_time) }
+ let!(:group2) { create(:group, name: "AAA", id: 2, created_at: ref_time - 10.seconds, updated_at: ref_time - 5.seconds) }
+ let!(:group3) { create(:group, name: "BB", id: 3, created_at: ref_time - 5.seconds, updated_at: ref_time - 10.seconds) }
+ let!(:group4) { create(:group, name: "bbb", id: 4, created_at: ref_time, updated_at: ref_time - 15.seconds) }
- it 'sorts groups by id' do
- expect(ordered_group_names('id_asc')).to eq(%w(aa AAA BB bbb))
- expect(ordered_group_names('id_desc')).to eq(%w(bbb BB AAA aa))
+ it "sorts groups by id" do
+ expect(ordered_group_names("id_asc")).to eq(%w[aa AAA BB bbb])
+ expect(ordered_group_names("id_desc")).to eq(%w[bbb BB AAA aa])
end
- it 'sorts groups by name via case-insensitive comparision' do
- expect(ordered_group_names('name_asc')).to eq(%w(aa AAA BB bbb))
- expect(ordered_group_names('name_desc')).to eq(%w(bbb BB AAA aa))
+ it "sorts groups by name via case-insensitive comparision" do
+ expect(ordered_group_names("name_asc")).to eq(%w[aa AAA BB bbb])
+ expect(ordered_group_names("name_desc")).to eq(%w[bbb BB AAA aa])
end
- it 'sorts groups by created_at' do
- expect(ordered_group_names('created_asc')).to eq(%w(aa AAA BB bbb))
- expect(ordered_group_names('created_desc')).to eq(%w(bbb BB AAA aa))
- expect(ordered_group_names('created_date')).to eq(%w(bbb BB AAA aa))
+ it "sorts groups by created_at" do
+ expect(ordered_group_names("created_asc")).to eq(%w[aa AAA BB bbb])
+ expect(ordered_group_names("created_desc")).to eq(%w[bbb BB AAA aa])
+ expect(ordered_group_names("created_date")).to eq(%w[bbb BB AAA aa])
end
- it 'sorts groups by updated_at' do
- expect(ordered_group_names('updated_asc')).to eq(%w(bbb BB AAA aa))
- expect(ordered_group_names('updated_desc')).to eq(%w(aa AAA BB bbb))
+ it "sorts groups by updated_at" do
+ expect(ordered_group_names("updated_asc")).to eq(%w[bbb BB AAA aa])
+ expect(ordered_group_names("updated_desc")).to eq(%w[aa AAA BB bbb])
end
end
end
diff --git a/spec/models/concerns/spammable_spec.rb b/spec/models/concerns/spammable_spec.rb
index e698207166c..d9bc03f651d 100644
--- a/spec/models/concerns/spammable_spec.rb
+++ b/spec/models/concerns/spammable_spec.rb
@@ -1,40 +1,40 @@
-require 'spec_helper'
+require "spec_helper"
describe Spammable do
- let(:issue) { create(:issue, description: 'Test Desc.') }
+ let(:issue) { create(:issue, description: "Test Desc.") }
- describe 'Associations' do
+ describe "Associations" do
subject { build(:issue) }
it { is_expected.to have_one(:user_agent_detail).dependent(:destroy) }
end
- describe 'ClassMethods' do
- it 'should return correct attr_spammable' do
+ describe "ClassMethods" do
+ it "should return correct attr_spammable" do
expect(issue.spammable_text).to eq("#{issue.title}\n#{issue.description}")
end
end
- describe 'InstanceMethods' do
+ describe "InstanceMethods" do
let(:issue) { build(:issue, spam: true) }
- it 'should be invalid if spam' do
+ it "should be invalid if spam" do
expect(issue.valid?).to be_falsey
end
- describe '#check_for_spam?' do
- it 'returns true for public project' do
+ describe "#check_for_spam?" do
+ it "returns true for public project" do
issue.project.update_attribute(:visibility_level, Gitlab::VisibilityLevel::PUBLIC)
expect(issue.check_for_spam?).to eq(true)
end
- it 'returns false for other visibility levels' do
+ it "returns false for other visibility levels" do
expect(issue.check_for_spam?).to eq(false)
end
end
- describe '#submittable_as_spam_by?' do
+ describe "#submittable_as_spam_by?" do
let(:admin) { build(:admin) }
let(:user) { build(:user) }
@@ -42,7 +42,7 @@ describe Spammable do
allow(issue).to receive(:submittable_as_spam?).and_return(true)
end
- it 'tests if the user can submit spam' do
+ it "tests if the user can submit spam" do
expect(issue.submittable_as_spam_by?(admin)).to be(true)
expect(issue.submittable_as_spam_by?(user)).to be(false)
expect(issue.submittable_as_spam_by?(nil)).to be_nil
diff --git a/spec/models/concerns/strip_attribute_spec.rb b/spec/models/concerns/strip_attribute_spec.rb
index 8c945686b66..93e2ff3a2bf 100644
--- a/spec/models/concerns/strip_attribute_spec.rb
+++ b/spec/models/concerns/strip_attribute_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe StripAttribute do
let(:milestone) { create(:milestone) }
@@ -10,10 +10,10 @@ describe StripAttribute do
describe "#strip_attributes" do
before do
- milestone.title = ' 8.3 '
+ milestone.title = " 8.3 "
milestone.valid?
end
- it { expect(milestone.title).to eq('8.3') }
+ it { expect(milestone.title).to eq("8.3") }
end
end
diff --git a/spec/models/concerns/subscribable_spec.rb b/spec/models/concerns/subscribable_spec.rb
index 45dfb136aea..7bdeabbef9a 100644
--- a/spec/models/concerns/subscribable_spec.rb
+++ b/spec/models/concerns/subscribable_spec.rb
@@ -1,47 +1,47 @@
-require 'spec_helper'
+require "spec_helper"
-describe Subscribable, 'Subscribable' do
+describe Subscribable, "Subscribable" do
let(:project) { create(:project) }
let(:resource) { create(:issue, project: project) }
let(:user_1) { create(:user) }
- describe '#subscribed?' do
- context 'without user' do
- it 'returns false' do
+ describe "#subscribed?" do
+ context "without user" do
+ it "returns false" do
expect(resource.subscribed?(nil, project)).to be_falsey
end
end
- context 'without project' do
- it 'returns false when no subscription exists' do
+ context "without project" do
+ it "returns false when no subscription exists" do
expect(resource.subscribed?(user_1)).to be_falsey
end
- it 'returns true when a subcription exists and subscribed is true' do
+ it "returns true when a subcription exists and subscribed is true" do
resource.subscriptions.create(user: user_1, subscribed: true)
expect(resource.subscribed?(user_1)).to be_truthy
end
- it 'returns false when a subcription exists and subscribed is false' do
+ it "returns false when a subcription exists and subscribed is false" do
resource.subscriptions.create(user: user_1, subscribed: false)
expect(resource.subscribed?(user_1)).to be_falsey
end
end
- context 'with project' do
- it 'returns false when no subscription exists' do
+ context "with project" do
+ it "returns false when no subscription exists" do
expect(resource.subscribed?(user_1, project)).to be_falsey
end
- it 'returns true when a subcription exists and subscribed is true' do
+ it "returns true when a subcription exists and subscribed is true" do
resource.subscriptions.create(user: user_1, project: project, subscribed: true)
expect(resource.subscribed?(user_1, project)).to be_truthy
end
- it 'returns false when a subcription exists and subscribed is false' do
+ it "returns false when a subcription exists and subscribed is false" do
resource.subscriptions.create(user: user_1, project: project, subscribed: false)
expect(resource.subscribed?(user_1, project)).to be_falsey
@@ -49,12 +49,12 @@ describe Subscribable, 'Subscribable' do
end
end
- describe '#subscribers' do
- it 'returns [] when no subcribers exists' do
+ describe "#subscribers" do
+ it "returns [] when no subcribers exists" do
expect(resource.subscribers(project)).to be_empty
end
- it 'returns the subscribed users' do
+ it "returns the subscribed users" do
user_2 = create(:user)
resource.subscriptions.create(user: user_1, subscribed: true)
resource.subscriptions.create(user: user_2, project: project, subscribed: true)
@@ -64,9 +64,9 @@ describe Subscribable, 'Subscribable' do
end
end
- describe '#toggle_subscription' do
- context 'without project' do
- it 'toggles the current subscription state for the given user' do
+ describe "#toggle_subscription" do
+ context "without project" do
+ it "toggles the current subscription state for the given user" do
expect(resource.subscribed?(user_1)).to be_falsey
resource.toggle_subscription(user_1)
@@ -75,8 +75,8 @@ describe Subscribable, 'Subscribable' do
end
end
- context 'with project' do
- it 'toggles the current subscription state for the given user' do
+ context "with project" do
+ it "toggles the current subscription state for the given user" do
expect(resource.subscribed?(user_1, project)).to be_falsey
resource.toggle_subscription(user_1, project)
@@ -86,9 +86,9 @@ describe Subscribable, 'Subscribable' do
end
end
- describe '#subscribe' do
- context 'without project' do
- it 'subscribes the given user' do
+ describe "#subscribe" do
+ context "without project" do
+ it "subscribes the given user" do
expect(resource.subscribed?(user_1)).to be_falsey
resource.subscribe(user_1)
@@ -97,8 +97,8 @@ describe Subscribable, 'Subscribable' do
end
end
- context 'with project' do
- it 'subscribes the given user' do
+ context "with project" do
+ it "subscribes the given user" do
expect(resource.subscribed?(user_1, project)).to be_falsey
resource.subscribe(user_1, project)
@@ -108,9 +108,9 @@ describe Subscribable, 'Subscribable' do
end
end
- describe '#unsubscribe' do
- context 'without project' do
- it 'unsubscribes the given current user' do
+ describe "#unsubscribe" do
+ context "without project" do
+ it "unsubscribes the given current user" do
resource.subscriptions.create(user: user_1, subscribed: true)
expect(resource.subscribed?(user_1)).to be_truthy
@@ -120,8 +120,8 @@ describe Subscribable, 'Subscribable' do
end
end
- context 'with project' do
- it 'unsubscribes the given current user' do
+ context "with project" do
+ it "unsubscribes the given current user" do
resource.subscriptions.create(user: user_1, project: project, subscribed: true)
expect(resource.subscribed?(user_1, project)).to be_truthy
diff --git a/spec/models/concerns/token_authenticatable_spec.rb b/spec/models/concerns/token_authenticatable_spec.rb
index 40cb4eef60a..77fed825132 100644
--- a/spec/models/concerns/token_authenticatable_spec.rb
+++ b/spec/models/concerns/token_authenticatable_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
-shared_examples 'TokenAuthenticatable' do
- describe 'dynamically defined methods' do
+shared_examples "TokenAuthenticatable" do
+ describe "dynamically defined methods" do
it { expect(described_class).to respond_to("find_by_#{token_field}") }
it { is_expected.to respond_to("ensure_#{token_field}") }
it { is_expected.to respond_to("set_#{token_field}") }
@@ -9,25 +9,25 @@ shared_examples 'TokenAuthenticatable' do
end
end
-describe User, 'TokenAuthenticatable' do
+describe User, "TokenAuthenticatable" do
let(:token_field) { :feed_token }
- it_behaves_like 'TokenAuthenticatable'
+ it_behaves_like "TokenAuthenticatable"
- describe 'ensures authentication token' do
+ describe "ensures authentication token" do
subject { create(:user).send(token_field) }
it { is_expected.to be_a String }
end
end
-describe ApplicationSetting, 'TokenAuthenticatable' do
+describe ApplicationSetting, "TokenAuthenticatable" do
let(:token_field) { :runners_registration_token }
let(:settings) { described_class.new }
- it_behaves_like 'TokenAuthenticatable'
+ it_behaves_like "TokenAuthenticatable"
- describe 'generating new token' do
- context 'token is not generated yet' do
- describe 'token field accessor' do
+ describe "generating new token" do
+ context "token is not generated yet" do
+ describe "token field accessor" do
subject { settings.send(token_field) }
it { is_expected.not_to be_blank }
@@ -39,46 +39,46 @@ describe ApplicationSetting, 'TokenAuthenticatable' do
it { is_expected.to be_a String }
it { is_expected.not_to be_blank }
- it 'does not persist token' do
+ it "does not persist token" do
expect(settings).not_to be_persisted
end
end
- describe 'ensure_runners_registration_token!' do
+ describe "ensure_runners_registration_token!" do
subject { settings.send("ensure_#{token_field}!") }
- it 'persists new token as an encrypted string' do
+ it "persists new token as an encrypted string" do
expect(subject).to eq settings.reload.runners_registration_token
- expect(settings.read_attribute('runners_registration_token_encrypted'))
+ expect(settings.read_attribute("runners_registration_token_encrypted"))
.to eq Gitlab::CryptoHelper.aes256_gcm_encrypt(subject)
expect(settings).to be_persisted
end
- it 'does not persist token in a clear text' do
+ it "does not persist token in a clear text" do
expect(subject).not_to eq settings.reload
- .read_attribute('runners_registration_token_encrypted')
+ .read_attribute("runners_registration_token_encrypted")
end
end
end
- context 'token is generated' do
+ context "token is generated" do
before do
settings.send("reset_#{token_field}!")
end
- it 'persists a new token' do
+ it "persists a new token" do
expect(settings.runners_registration_token).to be_a String
end
end
end
- describe 'setting new token' do
- subject { settings.send("set_#{token_field}", '0123456789') }
+ describe "setting new token" do
+ subject { settings.send("set_#{token_field}", "0123456789") }
- it { is_expected.to eq '0123456789' }
+ it { is_expected.to eq "0123456789" }
end
- describe 'multiple token fields' do
+ describe "multiple token fields" do
before(:all) do
described_class.send(:add_authentication_token_field, :yet_another_token)
end
@@ -87,18 +87,18 @@ describe ApplicationSetting, 'TokenAuthenticatable' do
it { is_expected.to respond_to(:ensure_yet_another_token) }
end
- describe 'setting same token field multiple times' do
+ describe "setting same token field multiple times" do
subject { described_class.send(:add_authentication_token_field, :runners_registration_token) }
- it 'raises error' do
+ it "raises error" do
expect {subject}.to raise_error(ArgumentError)
end
end
end
-describe PersonalAccessToken, 'TokenAuthenticatable' do
- shared_examples 'changes personal access token' do
- it 'sets new token' do
+describe PersonalAccessToken, "TokenAuthenticatable" do
+ shared_examples "changes personal access token" do
+ it "sets new token" do
subject
expect(personal_access_token.token).to eq(token_value)
@@ -106,8 +106,8 @@ describe PersonalAccessToken, 'TokenAuthenticatable' do
end
end
- shared_examples 'does not change personal access token' do
- it 'sets new token' do
+ shared_examples "does not change personal access token" do
+ it "sets new token" do
subject
expect(personal_access_token.token).to be(nil)
@@ -115,11 +115,11 @@ describe PersonalAccessToken, 'TokenAuthenticatable' do
end
end
- let(:token_value) { 'token' }
+ let(:token_value) { "token" }
let(:token_digest) { Gitlab::CryptoHelper.sha256(token_value) }
let(:user) { create(:user) }
let(:personal_access_token) do
- described_class.new(name: 'test-pat-01',
+ described_class.new(name: "test-pat-01",
user_id: user.id,
scopes: [:api],
token_digest: token_digest)
@@ -129,22 +129,22 @@ describe PersonalAccessToken, 'TokenAuthenticatable' do
allow(Devise).to receive(:friendly_token).and_return(token_value)
end
- describe '.find_by_token' do
+ describe ".find_by_token" do
subject { PersonalAccessToken.find_by_token(token_value) }
- it 'finds the token' do
+ it "finds the token" do
personal_access_token.save
expect(subject).to eq(personal_access_token)
end
end
- describe '#set_token' do
- let(:new_token_value) { 'new-token' }
+ describe "#set_token" do
+ let(:new_token_value) { "new-token" }
subject { personal_access_token.set_token(new_token_value) }
- it 'sets new token' do
+ it "sets new token" do
subject
expect(personal_access_token.token).to eq(new_token_value)
@@ -152,65 +152,65 @@ describe PersonalAccessToken, 'TokenAuthenticatable' do
end
end
- describe '#ensure_token' do
+ describe "#ensure_token" do
subject { personal_access_token.ensure_token }
- context 'token_digest does not exist' do
+ context "token_digest does not exist" do
let(:token_digest) { nil }
- it_behaves_like 'changes personal access token'
+ it_behaves_like "changes personal access token"
end
- context 'token_digest already generated' do
- let(:token_digest) { 's3cr3t' }
+ context "token_digest already generated" do
+ let(:token_digest) { "s3cr3t" }
- it_behaves_like 'does not change personal access token'
+ it_behaves_like "does not change personal access token"
end
end
- describe '#ensure_token!' do
+ describe "#ensure_token!" do
subject { personal_access_token.ensure_token! }
- context 'token_digest does not exist' do
+ context "token_digest does not exist" do
let(:token_digest) { nil }
- it_behaves_like 'changes personal access token'
+ it_behaves_like "changes personal access token"
end
- context 'token_digest already generated' do
- let(:token_digest) { 's3cr3t' }
+ context "token_digest already generated" do
+ let(:token_digest) { "s3cr3t" }
- it_behaves_like 'does not change personal access token'
+ it_behaves_like "does not change personal access token"
end
end
- describe '#reset_token!' do
+ describe "#reset_token!" do
subject { personal_access_token.reset_token! }
- context 'token_digest does not exist' do
+ context "token_digest does not exist" do
let(:token_digest) { nil }
- it_behaves_like 'changes personal access token'
+ it_behaves_like "changes personal access token"
end
- context 'token_digest already generated' do
- let(:token_digest) { 's3cr3t' }
+ context "token_digest already generated" do
+ let(:token_digest) { "s3cr3t" }
- it_behaves_like 'changes personal access token'
+ it_behaves_like "changes personal access token"
end
end
end
-describe Ci::Build, 'TokenAuthenticatable' do
+describe Ci::Build, "TokenAuthenticatable" do
let(:token_field) { :token }
let(:build) { FactoryBot.build(:ci_build) }
- it_behaves_like 'TokenAuthenticatable'
+ it_behaves_like "TokenAuthenticatable"
- describe 'generating new token' do
- context 'token is not generated yet' do
- describe 'token field accessor' do
- it 'makes it possible to access token' do
+ describe "generating new token" do
+ context "token is not generated yet" do
+ describe "token field accessor" do
+ it "makes it possible to access token" do
expect(build.token).to be_nil
build.save!
@@ -225,35 +225,35 @@ describe Ci::Build, 'TokenAuthenticatable' do
it { is_expected.to be_a String }
it { is_expected.not_to be_blank }
- it 'does not persist token' do
+ it "does not persist token" do
expect(build).not_to be_persisted
end
end
- describe 'ensure_token!' do
- it 'persists a new token' do
+ describe "ensure_token!" do
+ it "persists a new token" do
expect(build.ensure_token!).to eq build.reload.token
expect(build).to be_persisted
end
- it 'persists new token as an encrypted string' do
+ it "persists new token as an encrypted string" do
build.ensure_token!
encrypted = Gitlab::CryptoHelper.aes256_gcm_encrypt(build.token)
- expect(build.read_attribute('token_encrypted')).to eq encrypted
+ expect(build.read_attribute("token_encrypted")).to eq encrypted
end
- it 'does not persist a token in a clear text' do
+ it "does not persist a token in a clear text" do
build.ensure_token!
- expect(build.read_attribute('token')).to be_nil
+ expect(build.read_attribute("token")).to be_nil
end
end
end
- describe '#reset_token!' do
- it 'persists a new token' do
+ describe "#reset_token!" do
+ it "persists a new token" do
build.save!
build.token.yield_self do |previous_token|
@@ -266,23 +266,23 @@ describe Ci::Build, 'TokenAuthenticatable' do
end
end
- describe 'setting a new token' do
- subject { build.set_token('0123456789') }
+ describe "setting a new token" do
+ subject { build.set_token("0123456789") }
- it 'returns the token' do
- expect(subject).to eq '0123456789'
+ it "returns the token" do
+ expect(subject).to eq "0123456789"
end
- it 'writes a new encrypted token' do
- expect(build.read_attribute('token_encrypted')).to be_nil
- expect(subject).to eq '0123456789'
- expect(build.read_attribute('token_encrypted')).to be_present
+ it "writes a new encrypted token" do
+ expect(build.read_attribute("token_encrypted")).to be_nil
+ expect(subject).to eq "0123456789"
+ expect(build.read_attribute("token_encrypted")).to be_present
end
- it 'does not write a new cleartext token' do
- expect(build.read_attribute('token')).to be_nil
- expect(subject).to eq '0123456789'
- expect(build.read_attribute('token')).to be_nil
+ it "does not write a new cleartext token" do
+ expect(build.read_attribute("token")).to be_nil
+ expect(subject).to eq "0123456789"
+ expect(build.read_attribute("token")).to be_nil
end
end
end
diff --git a/spec/models/concerns/token_authenticatable_strategies/base_spec.rb b/spec/models/concerns/token_authenticatable_strategies/base_spec.rb
index 6605f1f5a5f..2208c325a0b 100644
--- a/spec/models/concerns/token_authenticatable_strategies/base_spec.rb
+++ b/spec/models/concerns/token_authenticatable_strategies/base_spec.rb
@@ -1,61 +1,61 @@
-require 'spec_helper'
+require "spec_helper"
describe TokenAuthenticatableStrategies::Base do
let(:instance) { double(:instance) }
let(:field) { double(:field) }
- describe '.fabricate' do
- context 'when digest stragegy is specified' do
- it 'fabricates digest strategy object' do
+ describe ".fabricate" do
+ context "when digest stragegy is specified" do
+ it "fabricates digest strategy object" do
strategy = described_class.fabricate(instance, field, digest: true)
expect(strategy).to be_a TokenAuthenticatableStrategies::Digest
end
end
- context 'when encrypted strategy is specified' do
- it 'fabricates encrypted strategy object' do
+ context "when encrypted strategy is specified" do
+ it "fabricates encrypted strategy object" do
strategy = described_class.fabricate(instance, field, encrypted: true)
expect(strategy).to be_a TokenAuthenticatableStrategies::Encrypted
end
end
- context 'when no strategy is specified' do
- it 'fabricates insecure strategy object' do
+ context "when no strategy is specified" do
+ it "fabricates insecure strategy object" do
strategy = described_class.fabricate(instance, field, something: true)
expect(strategy).to be_a TokenAuthenticatableStrategies::Insecure
end
end
- context 'when incompatible options are provided' do
- it 'raises an error' do
+ context "when incompatible options are provided" do
+ it "raises an error" do
expect { described_class.fabricate(instance, field, digest: true, encrypted: true) }
.to raise_error ArgumentError
end
end
end
- describe '#fallback?' do
- context 'when fallback is set' do
- it 'recognizes fallback setting' do
+ describe "#fallback?" do
+ context "when fallback is set" do
+ it "recognizes fallback setting" do
strategy = described_class.new(instance, field, fallback: true)
expect(strategy.fallback?).to be true
end
end
- context 'when fallback is not a valid value' do
- it 'raises an error' do
- strategy = described_class.new(instance, field, fallback: 'something')
+ context "when fallback is not a valid value" do
+ it "raises an error" do
+ strategy = described_class.new(instance, field, fallback: "something")
expect { strategy.fallback? }.to raise_error ArgumentError
end
end
- context 'when fallback is not set' do
- it 'raises an error' do
+ context "when fallback is not set" do
+ it "raises an error" do
strategy = described_class.new(instance, field, {})
expect(strategy.fallback?).to eq false
diff --git a/spec/models/concerns/token_authenticatable_strategies/encrypted_spec.rb b/spec/models/concerns/token_authenticatable_strategies/encrypted_spec.rb
index 93cab80cb1f..630227fe149 100644
--- a/spec/models/concerns/token_authenticatable_strategies/encrypted_spec.rb
+++ b/spec/models/concerns/token_authenticatable_strategies/encrypted_spec.rb
@@ -1,155 +1,155 @@
-require 'spec_helper'
+require "spec_helper"
describe TokenAuthenticatableStrategies::Encrypted do
let(:model) { double(:model) }
let(:instance) { double(:instance) }
let(:encrypted) do
- Gitlab::CryptoHelper.aes256_gcm_encrypt('my-value')
+ Gitlab::CryptoHelper.aes256_gcm_encrypt("my-value")
end
subject do
- described_class.new(model, 'some_field', options)
+ described_class.new(model, "some_field", options)
end
- describe '.new' do
- context 'when fallback and migration strategies are set' do
- let(:options) { { fallback: true, migrating: true } }
+ describe ".new" do
+ context "when fallback and migration strategies are set" do
+ let(:options) { {fallback: true, migrating: true} }
- it 'raises an error' do
+ it "raises an error" do
expect { subject }.to raise_error ArgumentError, /not compatible/
end
end
end
- describe '#find_token_authenticatable' do
- context 'when using fallback strategy' do
- let(:options) { { fallback: true } }
+ describe "#find_token_authenticatable" do
+ context "when using fallback strategy" do
+ let(:options) { {fallback: true} }
- it 'finds the encrypted resource by cleartext' do
+ it "finds the encrypted resource by cleartext" do
allow(model).to receive(:find_by)
- .with('some_field_encrypted' => encrypted)
- .and_return('encrypted resource')
+ .with("some_field_encrypted" => encrypted)
+ .and_return("encrypted resource")
- expect(subject.find_token_authenticatable('my-value'))
- .to eq 'encrypted resource'
+ expect(subject.find_token_authenticatable("my-value"))
+ .to eq "encrypted resource"
end
- it 'uses insecure strategy when encrypted token cannot be found' do
+ it "uses insecure strategy when encrypted token cannot be found" do
allow(subject.send(:insecure_strategy))
.to receive(:find_token_authenticatable)
- .and_return('plaintext resource')
+ .and_return("plaintext resource")
allow(model).to receive(:find_by)
- .with('some_field_encrypted' => encrypted)
+ .with("some_field_encrypted" => encrypted)
.and_return(nil)
- expect(subject.find_token_authenticatable('my-value'))
- .to eq 'plaintext resource'
+ expect(subject.find_token_authenticatable("my-value"))
+ .to eq "plaintext resource"
end
end
- context 'when using migration strategy' do
- let(:options) { { migrating: true } }
+ context "when using migration strategy" do
+ let(:options) { {migrating: true} }
- it 'finds the cleartext resource by cleartext' do
+ it "finds the cleartext resource by cleartext" do
allow(model).to receive(:find_by)
- .with('some_field' => 'my-value')
- .and_return('cleartext resource')
+ .with("some_field" => "my-value")
+ .and_return("cleartext resource")
- expect(subject.find_token_authenticatable('my-value'))
- .to eq 'cleartext resource'
+ expect(subject.find_token_authenticatable("my-value"))
+ .to eq "cleartext resource"
end
- it 'returns nil if resource cannot be found' do
+ it "returns nil if resource cannot be found" do
allow(model).to receive(:find_by)
- .with('some_field' => 'my-value')
+ .with("some_field" => "my-value")
.and_return(nil)
- expect(subject.find_token_authenticatable('my-value'))
+ expect(subject.find_token_authenticatable("my-value"))
.to be_nil
end
end
end
- describe '#get_token' do
- context 'when using fallback strategy' do
- let(:options) { { fallback: true } }
+ describe "#get_token" do
+ context "when using fallback strategy" do
+ let(:options) { {fallback: true} }
- it 'returns decrypted token when an encrypted token is present' do
+ it "returns decrypted token when an encrypted token is present" do
allow(instance).to receive(:read_attribute)
- .with('some_field_encrypted')
+ .with("some_field_encrypted")
.and_return(encrypted)
- expect(subject.get_token(instance)).to eq 'my-value'
+ expect(subject.get_token(instance)).to eq "my-value"
end
- it 'returns the plaintext token when encrypted token is not present' do
+ it "returns the plaintext token when encrypted token is not present" do
allow(instance).to receive(:read_attribute)
- .with('some_field_encrypted')
+ .with("some_field_encrypted")
.and_return(nil)
allow(instance).to receive(:read_attribute)
- .with('some_field')
- .and_return('cleartext value')
+ .with("some_field")
+ .and_return("cleartext value")
- expect(subject.get_token(instance)).to eq 'cleartext value'
+ expect(subject.get_token(instance)).to eq "cleartext value"
end
end
- context 'when using migration strategy' do
- let(:options) { { migrating: true } }
+ context "when using migration strategy" do
+ let(:options) { {migrating: true} }
- it 'returns cleartext token when an encrypted token is present' do
+ it "returns cleartext token when an encrypted token is present" do
allow(instance).to receive(:read_attribute)
- .with('some_field_encrypted')
+ .with("some_field_encrypted")
.and_return(encrypted)
allow(instance).to receive(:read_attribute)
- .with('some_field')
- .and_return('my-cleartext-value')
+ .with("some_field")
+ .and_return("my-cleartext-value")
- expect(subject.get_token(instance)).to eq 'my-cleartext-value'
+ expect(subject.get_token(instance)).to eq "my-cleartext-value"
end
- it 'returns the cleartext token when encrypted token is not present' do
+ it "returns the cleartext token when encrypted token is not present" do
allow(instance).to receive(:read_attribute)
- .with('some_field_encrypted')
+ .with("some_field_encrypted")
.and_return(nil)
allow(instance).to receive(:read_attribute)
- .with('some_field')
- .and_return('cleartext value')
+ .with("some_field")
+ .and_return("cleartext value")
- expect(subject.get_token(instance)).to eq 'cleartext value'
+ expect(subject.get_token(instance)).to eq "cleartext value"
end
end
end
- describe '#set_token' do
- context 'when using fallback strategy' do
- let(:options) { { fallback: true } }
+ describe "#set_token" do
+ context "when using fallback strategy" do
+ let(:options) { {fallback: true} }
- it 'writes encrypted token and removes plaintext token and returns it' do
+ it "writes encrypted token and removes plaintext token and returns it" do
expect(instance).to receive(:[]=)
- .with('some_field_encrypted', encrypted)
+ .with("some_field_encrypted", encrypted)
expect(instance).to receive(:[]=)
- .with('some_field', nil)
+ .with("some_field", nil)
- expect(subject.set_token(instance, 'my-value')).to eq 'my-value'
+ expect(subject.set_token(instance, "my-value")).to eq "my-value"
end
end
- context 'when using migration strategy' do
- let(:options) { { migrating: true } }
+ context "when using migration strategy" do
+ let(:options) { {migrating: true} }
- it 'writes encrypted token and writes plaintext token' do
+ it "writes encrypted token and writes plaintext token" do
expect(instance).to receive(:[]=)
- .with('some_field_encrypted', encrypted)
+ .with("some_field_encrypted", encrypted)
expect(instance).to receive(:[]=)
- .with('some_field', 'my-value')
+ .with("some_field", "my-value")
- expect(subject.set_token(instance, 'my-value')).to eq 'my-value'
+ expect(subject.set_token(instance, "my-value")).to eq "my-value"
end
end
end
diff --git a/spec/models/concerns/triggerable_hooks_spec.rb b/spec/models/concerns/triggerable_hooks_spec.rb
index 265abd6bd72..15eb162e89b 100644
--- a/spec/models/concerns/triggerable_hooks_spec.rb
+++ b/spec/models/concerns/triggerable_hooks_spec.rb
@@ -1,4 +1,4 @@
-require 'rails_helper'
+require "rails_helper"
RSpec.describe TriggerableHooks do
before do
@@ -8,43 +8,43 @@ RSpec.describe TriggerableHooks do
end
end
- describe 'scopes' do
- it 'defines a scope for each of the requested triggers' do
+ describe "scopes" do
+ it "defines a scope for each of the requested triggers" do
expect(TestableHook).to respond_to :push_hooks
expect(TestableHook).not_to respond_to :tag_push_hooks
end
end
- describe '.hooks_for' do
- context 'the model has the required trigger scope' do
- it 'returns the record' do
- hook = TestableHook.create!(url: 'http://example.com', push_events: true)
+ describe ".hooks_for" do
+ context "the model has the required trigger scope" do
+ it "returns the record" do
+ hook = TestableHook.create!(url: "http://example.com", push_events: true)
expect(TestableHook.hooks_for(:push_hooks)).to eq [hook]
end
end
- context 'the model does not have the required trigger scope' do
- it 'returns an empty relation' do
- TestableHook.create!(url: 'http://example.com')
+ context "the model does not have the required trigger scope" do
+ it "returns an empty relation" do
+ TestableHook.create!(url: "http://example.com")
expect(TestableHook.hooks_for(:tag_push_hooks)).to eq []
end
end
context 'the stock scope ".all" is accepted' do
- it 'returns the record' do
- hook = TestableHook.create!(url: 'http://example.com')
+ it "returns the record" do
+ hook = TestableHook.create!(url: "http://example.com")
expect(TestableHook.hooks_for(:all)).to eq [hook]
end
end
end
- describe '.select_active' do
- it 'returns hooks that match the active filter' do
- TestableHook.create!(url: 'http://example1.com', push_events: true)
- TestableHook.create!(url: 'http://example2.com', push_events: true)
+ describe ".select_active" do
+ it "returns hooks that match the active filter" do
+ TestableHook.create!(url: "http://example1.com", push_events: true)
+ TestableHook.create!(url: "http://example2.com", push_events: true)
filter1 = double(:filter1)
filter2 = double(:filter2)
allow(ActiveHookFilter).to receive(:new).exactly(2).times.and_return(filter1, filter2)
@@ -55,8 +55,8 @@ RSpec.describe TriggerableHooks do
expect(hooks.select_active(:push_hooks, {})).to eq [hooks.first]
end
- it 'returns empty list if no hooks match the active filter' do
- TestableHook.create!(url: 'http://example1.com', push_events: true)
+ it "returns empty list if no hooks match the active filter" do
+ TestableHook.create!(url: "http://example1.com", push_events: true)
filter = double(:filter)
allow(ActiveHookFilter).to receive(:new).and_return(filter)
expect(filter).to receive(:matches?).and_return(false)
diff --git a/spec/models/concerns/uniquify_spec.rb b/spec/models/concerns/uniquify_spec.rb
index 6cd2de6dcce..0da6f5a4d0d 100644
--- a/spec/models/concerns/uniquify_spec.rb
+++ b/spec/models/concerns/uniquify_spec.rb
@@ -1,42 +1,42 @@
-require 'spec_helper'
+require "spec_helper"
describe Uniquify do
let(:uniquify) { described_class.new }
describe "#string" do
- it 'returns the given string if it does not exist' do
- result = uniquify.string('test_string') { |s| false }
+ it "returns the given string if it does not exist" do
+ result = uniquify.string("test_string") { |s| false }
- expect(result).to eq('test_string')
+ expect(result).to eq("test_string")
end
- it 'returns the given string with a counter attached if the string exists' do
- result = uniquify.string('test_string') { |s| s == 'test_string' }
+ it "returns the given string with a counter attached if the string exists" do
+ result = uniquify.string("test_string") { |s| s == "test_string" }
- expect(result).to eq('test_string1')
+ expect(result).to eq("test_string1")
end
- it 'increments the counter for each candidate string that also exists' do
- result = uniquify.string('test_string') { |s| s == 'test_string' || s == 'test_string1' }
+ it "increments the counter for each candidate string that also exists" do
+ result = uniquify.string("test_string") { |s| s == "test_string" || s == "test_string1" }
- expect(result).to eq('test_string2')
+ expect(result).to eq("test_string2")
end
- it 'allows to pass an initial value for the counter' do
+ it "allows to pass an initial value for the counter" do
start_counting_from = 2
uniquify = described_class.new(start_counting_from)
- result = uniquify.string('test_string') { |s| s == 'test_string' }
+ result = uniquify.string("test_string") { |s| s == "test_string" }
- expect(result).to eq('test_string2')
+ expect(result).to eq("test_string2")
end
- it 'allows passing in a base function that defines the location of the counter' do
- result = uniquify.string(-> (counter) { "test_#{counter}_string" }) do |s|
- s == 'test__string'
- end
+ it "allows passing in a base function that defines the location of the counter" do
+ result = uniquify.string(->(counter) { "test_#{counter}_string" }) { |s|
+ s == "test__string"
+ }
- expect(result).to eq('test_1_string')
+ expect(result).to eq("test_1_string")
end
end
end