Add latest changes from gitlab-org/gitlab@master
This commit is contained in:
parent
a66a37ceff
commit
a4c6555151
21 changed files with 193 additions and 80 deletions
|
@ -1,7 +1,5 @@
|
|||
import ClustersBundle from '~/clusters/clusters_bundle';
|
||||
import initClusterHealth from '~/pages/projects/clusters/show/cluster_health';
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
new ClustersBundle(); // eslint-disable-line no-new
|
||||
initClusterHealth();
|
||||
});
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
import ClustersBundle from '~/clusters/clusters_bundle';
|
||||
import initClusterHealth from '~/pages/projects/clusters/show/cluster_health';
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
new ClustersBundle(); // eslint-disable-line no-new
|
||||
initClusterHealth();
|
||||
});
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
import monitoringApp from '~/monitoring/monitoring_app';
|
||||
|
||||
export default () => {
|
||||
const el = document.getElementById('prometheus-graphs');
|
||||
|
||||
if (el && el.dataset) {
|
||||
monitoringApp({
|
||||
...el.dataset,
|
||||
showLegend: false,
|
||||
showHeader: false,
|
||||
showPanels: false,
|
||||
forceSmallGraph: true,
|
||||
smallEmptyState: true,
|
||||
currentEnvironmentName: '',
|
||||
hasMetrics: true,
|
||||
});
|
||||
}
|
||||
};
|
|
@ -1,9 +1,7 @@
|
|||
import ClustersBundle from '~/clusters/clusters_bundle';
|
||||
import initGkeNamespace from '~/create_cluster/gke_cluster_namespace';
|
||||
import initClusterHealth from './cluster_health';
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
new ClustersBundle(); // eslint-disable-line no-new
|
||||
initGkeNamespace();
|
||||
initClusterHealth();
|
||||
});
|
||||
|
|
|
@ -52,6 +52,14 @@ export default {
|
|||
// $root.$emit is a workaround because other b-modal approaches don't work yet with gl-modal
|
||||
this.$root.$emit('bv::hide::modal', this.modalId);
|
||||
},
|
||||
cancel() {
|
||||
this.$emit('cancel');
|
||||
this.syncHide();
|
||||
},
|
||||
ok() {
|
||||
this.$emit('ok');
|
||||
this.syncHide();
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
@ -65,5 +73,6 @@ export default {
|
|||
@hidden="syncHide"
|
||||
>
|
||||
<slot></slot>
|
||||
<slot slot="modal-footer" name="modal-footer" :ok="ok" :cancel="cancel"></slot>
|
||||
</gl-modal>
|
||||
</template>
|
||||
|
|
|
@ -1,9 +1,4 @@
|
|||
.alert-management-list {
|
||||
// Migrate this to gitlab-ui
|
||||
.gl-w-12 {
|
||||
width: $gl-spacing-scale-12;
|
||||
}
|
||||
|
||||
// these styles need to be deleted once GlTable component looks in GitLab same as in @gitlab/ui
|
||||
table {
|
||||
color: $gray-700;
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
%ul.nav-links.mobile-separator.nav.nav-tabs{ role: 'tablist' }
|
||||
= render 'details_tab'
|
||||
= render_if_exists 'clusters/clusters/environments_tab'
|
||||
= render 'clusters/clusters/health_tab'
|
||||
= render_if_exists 'clusters/clusters/health_tab'
|
||||
= render 'applications_tab'
|
||||
= render 'advanced_settings_tab'
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
---
|
||||
type: howto, tutorial
|
||||
description: "Introduction to using Git through the command line."
|
||||
last_updated: 2020-04-22
|
||||
last_updated: 2020-06-30
|
||||
---
|
||||
|
||||
# Start using Git on the command line
|
||||
|
|
|
@ -20,7 +20,7 @@ Adjust your project's name, description, avatar, [default branch](../repository/
|
|||
|
||||
The project description also partially supports [standard Markdown](../../markdown.md#standard-markdown-and-extensions-in-gitlab). You can use [emphasis](../../markdown.md#emphasis), [links](../../markdown.md#links), and [line-breaks](../../markdown.md#line-breaks) to add more context to the project description.
|
||||
|
||||
#### Compliance framework **(ULTIMATE)**
|
||||
#### Compliance framework **(PREMIUM)**
|
||||
|
||||
You can select a framework label to identify that your project has certain compliance requirements or needs additional oversight. Available labels include:
|
||||
|
||||
|
|
|
@ -22,16 +22,32 @@ module Gitlab
|
|||
end
|
||||
end
|
||||
|
||||
prepended do
|
||||
def self.preload_markdown_cache!(objects)
|
||||
fields = Gitlab::MarkdownCache::Redis::Store.bulk_read(objects)
|
||||
|
||||
objects.each do |object|
|
||||
fields[object.cache_key].value.each do |field_name, value|
|
||||
object.write_markdown_field(field_name, value)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def write_markdown_field(field_name, value)
|
||||
# The value read from redis is a string, so we're converting it back
|
||||
# to an int.
|
||||
value = value.to_i if field_name == :cached_markdown_version
|
||||
|
||||
instance_variable_set("@#{field_name}", value)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def save_markdown(updates)
|
||||
markdown_store.save(updates)
|
||||
end
|
||||
|
||||
def write_markdown_field(field_name, value)
|
||||
instance_variable_set("@#{field_name}", value)
|
||||
end
|
||||
|
||||
def markdown_field_changed?(field_name)
|
||||
false
|
||||
end
|
||||
|
|
|
@ -6,6 +6,20 @@ module Gitlab
|
|||
class Store
|
||||
EXPIRES_IN = 1.day
|
||||
|
||||
def self.bulk_read(subjects)
|
||||
results = {}
|
||||
|
||||
Gitlab::Redis::Cache.with do |r|
|
||||
r.pipelined do
|
||||
subjects.each do |subject|
|
||||
results[subject.cache_key] = new(subject).read
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
results
|
||||
end
|
||||
|
||||
def initialize(subject)
|
||||
@subject = subject
|
||||
@loaded = false
|
||||
|
@ -23,13 +37,9 @@ module Gitlab
|
|||
def read
|
||||
@loaded = true
|
||||
|
||||
results = Gitlab::Redis::Cache.with do |r|
|
||||
Gitlab::Redis::Cache.with do |r|
|
||||
r.mapped_hmget(markdown_cache_key, *fields)
|
||||
end
|
||||
# The value read from redis is a string, so we're converting it back
|
||||
# to an int.
|
||||
results[:cached_markdown_version] = results[:cached_markdown_version].to_i
|
||||
results
|
||||
end
|
||||
|
||||
def loaded?
|
||||
|
|
|
@ -39,7 +39,7 @@ module Gitlab
|
|||
.merge(object_store_usage_data)
|
||||
.merge(topology_usage_data)
|
||||
.merge(usage_activity_by_stage)
|
||||
.merge(usage_activity_by_stage(:usage_activity_by_stage_monthly, default_time_period))
|
||||
.merge(usage_activity_by_stage(:usage_activity_by_stage_monthly, last_28_days_time_period))
|
||||
.merge(analytics_unique_visits_data)
|
||||
end
|
||||
end
|
||||
|
@ -160,7 +160,7 @@ module Gitlab
|
|||
user_preferences_usage,
|
||||
ingress_modsecurity_usage,
|
||||
container_expiration_policies_usage,
|
||||
merge_requests_usage(default_time_period)
|
||||
merge_requests_usage(last_28_days_time_period)
|
||||
).tap do |data|
|
||||
data[:snippets] = data[:personal_snippets] + data[:project_snippets]
|
||||
end
|
||||
|
@ -171,8 +171,8 @@ module Gitlab
|
|||
def system_usage_data_monthly
|
||||
{
|
||||
counts_monthly: {
|
||||
personal_snippets: count(PersonalSnippet.where(default_time_period)),
|
||||
project_snippets: count(ProjectSnippet.where(default_time_period))
|
||||
personal_snippets: count(PersonalSnippet.where(last_28_days_time_period)),
|
||||
project_snippets: count(ProjectSnippet.where(last_28_days_time_period))
|
||||
}.tap do |data|
|
||||
data[:snippets] = data[:personal_snippets] + data[:project_snippets]
|
||||
end
|
||||
|
@ -433,7 +433,7 @@ module Gitlab
|
|||
end
|
||||
end
|
||||
|
||||
def default_time_period
|
||||
def last_28_days_time_period
|
||||
{ created_at: 28.days.ago..Time.current }
|
||||
end
|
||||
|
||||
|
|
|
@ -1391,6 +1391,9 @@ msgstr ""
|
|||
msgid "Add approval rule"
|
||||
msgstr ""
|
||||
|
||||
msgid "Add approvers"
|
||||
msgstr ""
|
||||
|
||||
msgid "Add bold text"
|
||||
msgstr ""
|
||||
|
||||
|
@ -2281,6 +2284,9 @@ msgstr ""
|
|||
msgid "An error occurred while acknowledging the notification. Refresh the page and try again."
|
||||
msgstr ""
|
||||
|
||||
msgid "An error occurred while adding approvers"
|
||||
msgstr ""
|
||||
|
||||
msgid "An error occurred while adding formatted title for epic"
|
||||
msgstr ""
|
||||
|
||||
|
@ -12716,6 +12722,9 @@ msgstr ""
|
|||
msgid "January"
|
||||
msgstr ""
|
||||
|
||||
msgid "Jira Issues"
|
||||
msgstr ""
|
||||
|
||||
msgid "Jira import is already running."
|
||||
msgstr ""
|
||||
|
||||
|
@ -13261,6 +13270,12 @@ msgstr ""
|
|||
msgid "License-Check"
|
||||
msgstr ""
|
||||
|
||||
msgid "LicenseCompliance|%{docLinkStart}License Approvals%{docLinkEnd} are active"
|
||||
msgstr ""
|
||||
|
||||
msgid "LicenseCompliance|%{docLinkStart}License Approvals%{docLinkEnd} are inactive"
|
||||
msgstr ""
|
||||
|
||||
msgid "LicenseCompliance|Add a license"
|
||||
msgstr ""
|
||||
|
||||
|
@ -13282,9 +13297,15 @@ msgstr ""
|
|||
msgid "LicenseCompliance|Deny"
|
||||
msgstr ""
|
||||
|
||||
msgid "LicenseCompliance|Learn more about %{linkStart}License Approvals%{linkEnd}"
|
||||
msgstr ""
|
||||
|
||||
msgid "LicenseCompliance|License"
|
||||
msgstr ""
|
||||
|
||||
msgid "LicenseCompliance|License Approvals"
|
||||
msgstr ""
|
||||
|
||||
msgid "LicenseCompliance|License Compliance detected %d license and policy violation for the source branch only; approval required"
|
||||
msgid_plural "LicenseCompliance|License Compliance detected %d licenses and policy violations for the source branch only; approval required"
|
||||
msgstr[0] ""
|
||||
|
@ -24573,6 +24594,9 @@ msgstr ""
|
|||
msgid "Update approval rule"
|
||||
msgstr ""
|
||||
|
||||
msgid "Update approvers"
|
||||
msgstr ""
|
||||
|
||||
msgid "Update failed"
|
||||
msgstr ""
|
||||
|
||||
|
@ -27186,6 +27210,9 @@ msgstr ""
|
|||
msgid "load it anyway"
|
||||
msgstr ""
|
||||
|
||||
msgid "loading"
|
||||
msgstr ""
|
||||
|
||||
msgid "locked by %{path_lock_user_name} %{created_at}"
|
||||
msgstr ""
|
||||
|
||||
|
|
|
@ -38,6 +38,9 @@ describe('GlModalVuex', () => {
|
|||
localVue,
|
||||
store,
|
||||
propsData,
|
||||
stubs: {
|
||||
GlModal,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -148,4 +151,29 @@ describe('GlModalVuex', () => {
|
|||
.then(done)
|
||||
.catch(done.fail);
|
||||
});
|
||||
|
||||
it.each(['ok', 'cancel'])(
|
||||
'passes an "%s" handler to the "modal-footer" slot scope',
|
||||
handlerName => {
|
||||
state.isVisible = true;
|
||||
|
||||
const modalFooterSlotContent = jest.fn();
|
||||
|
||||
factory({
|
||||
scopedSlots: {
|
||||
'modal-footer': modalFooterSlotContent,
|
||||
},
|
||||
});
|
||||
|
||||
const handler = modalFooterSlotContent.mock.calls[0][0][handlerName];
|
||||
|
||||
expect(wrapper.emitted(handlerName)).toBeFalsy();
|
||||
expect(actions.hide).not.toHaveBeenCalled();
|
||||
|
||||
handler();
|
||||
|
||||
expect(actions.hide).toHaveBeenCalledTimes(1);
|
||||
expect(wrapper.emitted(handlerName)).toBeTruthy();
|
||||
},
|
||||
);
|
||||
});
|
||||
|
|
|
@ -49,6 +49,31 @@ RSpec.describe Gitlab::MarkdownCache::Redis::Extension, :clean_gitlab_redis_cach
|
|||
expect(thing.cached_markdown_version).to eq(cache_version)
|
||||
end
|
||||
|
||||
describe '.preload_markdown_cache!' do
|
||||
before do
|
||||
Gitlab::Redis::Cache.with do |r|
|
||||
r.mapped_hmset(expected_cache_key,
|
||||
title_html: 'hello',
|
||||
description_html: 'world',
|
||||
cached_markdown_version: cache_version)
|
||||
end
|
||||
end
|
||||
|
||||
it 'does not preload the markdown twice' do
|
||||
expect(Gitlab::MarkdownCache::Redis::Store).to receive(:bulk_read).and_call_original
|
||||
expect(Gitlab::Redis::Cache).to receive(:with).twice.and_call_original
|
||||
|
||||
klass.preload_markdown_cache!([thing])
|
||||
|
||||
aggregate_failures do
|
||||
expect(Gitlab::Redis::Cache).not_to receive(:with)
|
||||
expect(thing.title_html).to eq('hello')
|
||||
expect(thing.description_html).to eq('world')
|
||||
expect(thing.cached_markdown_version).to eq(cache_version)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#refresh_markdown_cache!" do
|
||||
it "stores the value in redis" do
|
||||
expected_results = { "title_html" => "`Hello`",
|
||||
|
|
|
@ -37,6 +37,23 @@ RSpec.describe Gitlab::MarkdownCache::Redis::Store, :clean_gitlab_redis_cache do
|
|||
end
|
||||
end
|
||||
|
||||
describe '.bulk_read' do
|
||||
before do
|
||||
store.save(field_1_html: "hello", field_2_html: "world", cached_markdown_version: 1)
|
||||
end
|
||||
|
||||
it 'returns a hash of values from store' do
|
||||
Gitlab::Redis::Cache.with do |redis|
|
||||
expect(redis).to receive(:pipelined).and_call_original
|
||||
end
|
||||
|
||||
results = described_class.bulk_read([storable])
|
||||
|
||||
expect(results[storable.cache_key].value.symbolize_keys)
|
||||
.to eq(field_1_html: "hello", field_2_html: "world", cached_markdown_version: "1")
|
||||
end
|
||||
end
|
||||
|
||||
describe '#save' do
|
||||
it 'stores updates to html fields and version' do
|
||||
values_to_store = { field_1_html: "hello", field_2_html: "world", cached_markdown_version: 1 }
|
||||
|
@ -44,7 +61,7 @@ RSpec.describe Gitlab::MarkdownCache::Redis::Store, :clean_gitlab_redis_cache do
|
|||
store.save(values_to_store)
|
||||
|
||||
expect(read_values)
|
||||
.to eq({ field_1_html: "hello", field_2_html: "world", cached_markdown_version: "1" })
|
||||
.to eq(field_1_html: "hello", field_2_html: "world", cached_markdown_version: "1")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -54,7 +71,8 @@ RSpec.describe Gitlab::MarkdownCache::Redis::Store, :clean_gitlab_redis_cache do
|
|||
|
||||
store_values(stored_values)
|
||||
|
||||
expect(store.read.symbolize_keys).to eq(stored_values)
|
||||
expect(store.read.symbolize_keys)
|
||||
.to eq(field_1_html: "hello", field_2_html: "world", cached_markdown_version: "1")
|
||||
end
|
||||
|
||||
it 'is mared loaded after reading' do
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
require 'fast_spec_helper'
|
||||
require 'rubocop'
|
||||
require 'parser/current'
|
||||
require_relative '../../rubocop/code_reuse_helpers'
|
||||
|
@ -69,13 +69,13 @@ RSpec.describe RuboCop::CodeReuseHelpers do
|
|||
|
||||
describe '#in_finder?' do
|
||||
it 'returns true for a node in the finders directory' do
|
||||
node = parse_source('10', Rails.root.join('app', 'finders', 'foo.rb'))
|
||||
node = parse_source('10', rails_root_join('app', 'finders', 'foo.rb'))
|
||||
|
||||
expect(cop.in_finder?(node)).to eq(true)
|
||||
end
|
||||
|
||||
it 'returns false for a node outside the finders directory' do
|
||||
node = parse_source('10', Rails.root.join('app', 'foo', 'foo.rb'))
|
||||
node = parse_source('10', rails_root_join('app', 'foo', 'foo.rb'))
|
||||
|
||||
expect(cop.in_finder?(node)).to eq(false)
|
||||
end
|
||||
|
@ -83,13 +83,13 @@ RSpec.describe RuboCop::CodeReuseHelpers do
|
|||
|
||||
describe '#in_model?' do
|
||||
it 'returns true for a node in the models directory' do
|
||||
node = parse_source('10', Rails.root.join('app', 'models', 'foo.rb'))
|
||||
node = parse_source('10', rails_root_join('app', 'models', 'foo.rb'))
|
||||
|
||||
expect(cop.in_model?(node)).to eq(true)
|
||||
end
|
||||
|
||||
it 'returns false for a node outside the models directory' do
|
||||
node = parse_source('10', Rails.root.join('app', 'foo', 'foo.rb'))
|
||||
node = parse_source('10', rails_root_join('app', 'foo', 'foo.rb'))
|
||||
|
||||
expect(cop.in_model?(node)).to eq(false)
|
||||
end
|
||||
|
@ -97,13 +97,13 @@ RSpec.describe RuboCop::CodeReuseHelpers do
|
|||
|
||||
describe '#in_service_class?' do
|
||||
it 'returns true for a node in the services directory' do
|
||||
node = parse_source('10', Rails.root.join('app', 'services', 'foo.rb'))
|
||||
node = parse_source('10', rails_root_join('app', 'services', 'foo.rb'))
|
||||
|
||||
expect(cop.in_service_class?(node)).to eq(true)
|
||||
end
|
||||
|
||||
it 'returns false for a node outside the services directory' do
|
||||
node = parse_source('10', Rails.root.join('app', 'foo', 'foo.rb'))
|
||||
node = parse_source('10', rails_root_join('app', 'foo', 'foo.rb'))
|
||||
|
||||
expect(cop.in_service_class?(node)).to eq(false)
|
||||
end
|
||||
|
@ -111,13 +111,13 @@ RSpec.describe RuboCop::CodeReuseHelpers do
|
|||
|
||||
describe '#in_presenter?' do
|
||||
it 'returns true for a node in the presenters directory' do
|
||||
node = parse_source('10', Rails.root.join('app', 'presenters', 'foo.rb'))
|
||||
node = parse_source('10', rails_root_join('app', 'presenters', 'foo.rb'))
|
||||
|
||||
expect(cop.in_presenter?(node)).to eq(true)
|
||||
end
|
||||
|
||||
it 'returns false for a node outside the presenters directory' do
|
||||
node = parse_source('10', Rails.root.join('app', 'foo', 'foo.rb'))
|
||||
node = parse_source('10', rails_root_join('app', 'foo', 'foo.rb'))
|
||||
|
||||
expect(cop.in_presenter?(node)).to eq(false)
|
||||
end
|
||||
|
@ -125,13 +125,13 @@ RSpec.describe RuboCop::CodeReuseHelpers do
|
|||
|
||||
describe '#in_serializer?' do
|
||||
it 'returns true for a node in the serializers directory' do
|
||||
node = parse_source('10', Rails.root.join('app', 'serializers', 'foo.rb'))
|
||||
node = parse_source('10', rails_root_join('app', 'serializers', 'foo.rb'))
|
||||
|
||||
expect(cop.in_serializer?(node)).to eq(true)
|
||||
end
|
||||
|
||||
it 'returns false for a node outside the serializers directory' do
|
||||
node = parse_source('10', Rails.root.join('app', 'foo', 'foo.rb'))
|
||||
node = parse_source('10', rails_root_join('app', 'foo', 'foo.rb'))
|
||||
|
||||
expect(cop.in_serializer?(node)).to eq(false)
|
||||
end
|
||||
|
@ -139,13 +139,13 @@ RSpec.describe RuboCop::CodeReuseHelpers do
|
|||
|
||||
describe '#in_worker?' do
|
||||
it 'returns true for a node in the workers directory' do
|
||||
node = parse_source('10', Rails.root.join('app', 'workers', 'foo.rb'))
|
||||
node = parse_source('10', rails_root_join('app', 'workers', 'foo.rb'))
|
||||
|
||||
expect(cop.in_worker?(node)).to eq(true)
|
||||
end
|
||||
|
||||
it 'returns false for a node outside the workers directory' do
|
||||
node = parse_source('10', Rails.root.join('app', 'foo', 'foo.rb'))
|
||||
node = parse_source('10', rails_root_join('app', 'foo', 'foo.rb'))
|
||||
|
||||
expect(cop.in_worker?(node)).to eq(false)
|
||||
end
|
||||
|
@ -153,13 +153,13 @@ RSpec.describe RuboCop::CodeReuseHelpers do
|
|||
|
||||
describe '#in_api?' do
|
||||
it 'returns true for a node in the API directory' do
|
||||
node = parse_source('10', Rails.root.join('lib', 'api', 'foo.rb'))
|
||||
node = parse_source('10', rails_root_join('lib', 'api', 'foo.rb'))
|
||||
|
||||
expect(cop.in_api?(node)).to eq(true)
|
||||
end
|
||||
|
||||
it 'returns false for a node outside the API directory' do
|
||||
node = parse_source('10', Rails.root.join('lib', 'foo', 'foo.rb'))
|
||||
node = parse_source('10', rails_root_join('lib', 'foo', 'foo.rb'))
|
||||
|
||||
expect(cop.in_api?(node)).to eq(false)
|
||||
end
|
||||
|
@ -167,21 +167,21 @@ RSpec.describe RuboCop::CodeReuseHelpers do
|
|||
|
||||
describe '#in_directory?' do
|
||||
it 'returns true for a directory in the CE app/ directory' do
|
||||
node = parse_source('10', Rails.root.join('app', 'models', 'foo.rb'))
|
||||
node = parse_source('10', rails_root_join('app', 'models', 'foo.rb'))
|
||||
|
||||
expect(cop.in_directory?(node, 'models')).to eq(true)
|
||||
end
|
||||
|
||||
it 'returns true for a directory in the EE app/ directory' do
|
||||
node =
|
||||
parse_source('10', Rails.root.join('ee', 'app', 'models', 'foo.rb'))
|
||||
parse_source('10', rails_root_join('ee', 'app', 'models', 'foo.rb'))
|
||||
|
||||
expect(cop.in_directory?(node, 'models')).to eq(true)
|
||||
end
|
||||
|
||||
it 'returns false for a directory in the lib/ directory' do
|
||||
node =
|
||||
parse_source('10', Rails.root.join('lib', 'models', 'foo.rb'))
|
||||
parse_source('10', rails_root_join('lib', 'models', 'foo.rb'))
|
||||
|
||||
expect(cop.in_directory?(node, 'models')).to eq(false)
|
||||
end
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
require 'fast_spec_helper'
|
||||
require 'rubocop'
|
||||
require 'rubocop/rspec/support'
|
||||
require_relative '../../../../rubocop/cop/code_reuse/active_record'
|
||||
|
||||
RSpec.describe RuboCop::Cop::CodeReuse::ActiveRecord do
|
||||
RSpec.describe RuboCop::Cop::CodeReuse::ActiveRecord, type: :rubocop do
|
||||
include CopHelper
|
||||
|
||||
subject(:cop) { described_class.new }
|
||||
|
@ -46,7 +45,7 @@ RSpec.describe RuboCop::Cop::CodeReuse::ActiveRecord do
|
|||
end
|
||||
|
||||
it 'does not flag the use of ActiveRecord models in a model' do
|
||||
path = Rails.root.join('app', 'models', 'foo.rb').to_s
|
||||
path = rails_root_join('app', 'models', 'foo.rb').to_s
|
||||
|
||||
expect_no_offenses(<<~SOURCE, path)
|
||||
def foo
|
||||
|
@ -56,7 +55,7 @@ RSpec.describe RuboCop::Cop::CodeReuse::ActiveRecord do
|
|||
end
|
||||
|
||||
it 'does not flag the use of ActiveRecord models in a spec' do
|
||||
path = Rails.root.join('spec', 'foo_spec.rb').to_s
|
||||
path = rails_root_join('spec', 'foo_spec.rb').to_s
|
||||
|
||||
expect_no_offenses(<<~SOURCE, path)
|
||||
def foo
|
||||
|
@ -66,10 +65,7 @@ RSpec.describe RuboCop::Cop::CodeReuse::ActiveRecord do
|
|||
end
|
||||
|
||||
it 'does not flag the use of ActiveRecord models in a background migration' do
|
||||
path = Rails
|
||||
.root
|
||||
.join('lib', 'gitlab', 'background_migration', 'foo.rb')
|
||||
.to_s
|
||||
path = rails_root_join('lib', 'gitlab', 'background_migration', 'foo.rb').to_s
|
||||
|
||||
expect_no_offenses(<<~SOURCE, path)
|
||||
def foo
|
||||
|
@ -79,7 +75,7 @@ RSpec.describe RuboCop::Cop::CodeReuse::ActiveRecord do
|
|||
end
|
||||
|
||||
it 'does not flag the use of ActiveRecord models in lib/gitlab/database' do
|
||||
path = Rails.root.join('lib', 'gitlab', 'database', 'foo.rb').to_s
|
||||
path = rails_root_join('lib', 'gitlab', 'database', 'foo.rb').to_s
|
||||
|
||||
expect_no_offenses(<<~SOURCE, path)
|
||||
def foo
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
require 'fast_spec_helper'
|
||||
require 'rubocop'
|
||||
require 'parser/current'
|
||||
require_relative '../../rubocop/qa_helpers'
|
||||
|
||||
RSpec.describe RuboCop::QAHelpers do
|
||||
RSpec.describe RuboCop::QAHelpers, type: :rubocop do
|
||||
def parse_source(source, path = 'foo.rb')
|
||||
buffer = Parser::Source::Buffer.new(path)
|
||||
buffer.source = source
|
||||
|
@ -23,13 +24,13 @@ RSpec.describe RuboCop::QAHelpers do
|
|||
|
||||
describe '#in_qa_file?' do
|
||||
it 'returns true for a node in the qa/ directory' do
|
||||
node = parse_source('10', Rails.root.join('qa', 'qa', 'page', 'dashboard', 'groups.rb'))
|
||||
node = parse_source('10', rails_root_join('qa', 'qa', 'page', 'dashboard', 'groups.rb'))
|
||||
|
||||
expect(cop.in_qa_file?(node)).to eq(true)
|
||||
end
|
||||
|
||||
it 'returns false for a node outside the qa/ directory' do
|
||||
node = parse_source('10', Rails.root.join('app', 'foo', 'foo.rb'))
|
||||
node = parse_source('10', rails_root_join('app', 'foo', 'foo.rb'))
|
||||
|
||||
expect(cop.in_qa_file?(node)).to eq(false)
|
||||
end
|
||||
|
|
10
spec/support/helpers/fast_rails_root.rb
Normal file
10
spec/support/helpers/fast_rails_root.rb
Normal file
|
@ -0,0 +1,10 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# For specs which don't load Rails, provide a path to Rails root
|
||||
module FastRailsRoot
|
||||
RAILS_ROOT = File.absolute_path("#{__dir__}/../../..")
|
||||
|
||||
def rails_root_join(*args)
|
||||
File.join(RAILS_ROOT, *args)
|
||||
end
|
||||
end
|
|
@ -4,6 +4,7 @@ require_relative "helpers/stub_configuration"
|
|||
require_relative "helpers/stub_metrics"
|
||||
require_relative "helpers/stub_object_storage"
|
||||
require_relative "helpers/stub_env"
|
||||
require_relative "helpers/fast_rails_root"
|
||||
require 'rubocop/rspec/support'
|
||||
|
||||
RSpec.configure do |config|
|
||||
|
@ -14,6 +15,7 @@ RSpec.configure do |config|
|
|||
config.include StubMetrics
|
||||
config.include StubObjectStorage
|
||||
config.include StubENV
|
||||
config.include FastRailsRoot
|
||||
|
||||
config.include RuboCop::RSpec::ExpectOffense, type: :rubocop
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue