summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--changelogs/unreleased/refactoring-entities-file-25.yml5
-rw-r--r--doc/user/packages/npm_registry/index.md14
-rw-r--r--lib/api/entities.rb30
-rw-r--r--lib/api/entities/feature.rb22
-rw-r--r--lib/api/entities/feature_gate.rb10
-rw-r--r--lib/api/entities/impersonation_token.rb9
-rw-r--r--lib/api/entities/impersonation_token_with_token.rb9
-rw-r--r--lib/gitlab/runtime.rb5
-rw-r--r--spec/lib/gitlab/runtime_spec.rb8
-rw-r--r--spec/services/ci/stop_environments_service_spec.rb10
10 files changed, 80 insertions, 42 deletions
diff --git a/changelogs/unreleased/refactoring-entities-file-25.yml b/changelogs/unreleased/refactoring-entities-file-25.yml
new file mode 100644
index 00000000000..95bae988e3d
--- /dev/null
+++ b/changelogs/unreleased/refactoring-entities-file-25.yml
@@ -0,0 +1,5 @@
+---
+title: Separate token entities into own class files
+merge_request: 24974
+author: Rajendra Kadam
+type: added
diff --git a/doc/user/packages/npm_registry/index.md b/doc/user/packages/npm_registry/index.md
index a2944667b7e..7504137fbea 100644
--- a/doc/user/packages/npm_registry/index.md
+++ b/doc/user/packages/npm_registry/index.md
@@ -373,14 +373,12 @@ Starting from GitLab 12.6, new packages published to the GitLab NPM Registry exp
## NPM distribution tags
-> [Introduced](https://gitlab.com/gitlab-org/gitlab/issues/9425) in GitLab Premium 12.7.
-
-Dist Tags for newly published packages are supported, and they follow NPM's convention where they are optional, and each tag can only be assigned to 1 package at
-You can add [distribution tags](https://docs.npmjs.com/cli/dist-tag) for newly
-published packages. They follow NPM's convention where they are optional, and
-each tag can only be assigned to one package at a time. The latest tag is added
-by default when a package is published without a tag. The same goes to installing
-a package without specifying the tag or version.
+> [Introduced](https://gitlab.com/gitlab-org/gitlab/issues/9425) in GitLab Premium 12.8.
+
+You can add [distribution tags](https://docs.npmjs.com/cli/dist-tag) for newly published packages.
+They follow NPM's convention where they are optional, and each tag can only be assigned to one
+package at a time. The `latest` tag is added by default when a package is published without a tag.
+The same applies to installing a package without specifying the tag or version.
Examples of the supported `dist-tag` commands and using tags in general:
diff --git a/lib/api/entities.rb b/lib/api/entities.rb
index 3435d1d6f11..c0970b4cd6c 100644
--- a/lib/api/entities.rb
+++ b/lib/api/entities.rb
@@ -169,36 +169,6 @@ module API
expose :last_pipeline, using: Entities::PipelineBasic
expose :variables, using: Entities::Variable
end
-
- class ImpersonationToken < PersonalAccessToken
- expose :impersonation
- end
-
- class ImpersonationTokenWithToken < PersonalAccessTokenWithToken
- expose :impersonation
- end
-
- class FeatureGate < Grape::Entity
- expose :key
- expose :value
- end
-
- class Feature < Grape::Entity
- expose :name
- expose :state
- expose :gates, using: FeatureGate do |model|
- model.gates.map do |gate|
- value = model.gate_values[gate.key]
-
- # By default all gate values are populated. Only show relevant ones.
- if (value.is_a?(Integer) && value.zero?) || (value.is_a?(Set) && value.empty?)
- next
- end
-
- { key: gate.key, value: value }
- end.compact
- end
- end
end
end
diff --git a/lib/api/entities/feature.rb b/lib/api/entities/feature.rb
new file mode 100644
index 00000000000..3c9182340ea
--- /dev/null
+++ b/lib/api/entities/feature.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+module API
+ module Entities
+ class Feature < Grape::Entity
+ expose :name
+ expose :state
+ expose :gates, using: Entities::FeatureGate do |model|
+ model.gates.map do |gate|
+ value = model.gate_values[gate.key]
+
+ # By default all gate values are populated. Only show relevant ones.
+ if (value.is_a?(Integer) && value.zero?) || (value.is_a?(Set) && value.empty?)
+ next
+ end
+
+ { key: gate.key, value: value }
+ end.compact
+ end
+ end
+ end
+end
diff --git a/lib/api/entities/feature_gate.rb b/lib/api/entities/feature_gate.rb
new file mode 100644
index 00000000000..bea9c9474b3
--- /dev/null
+++ b/lib/api/entities/feature_gate.rb
@@ -0,0 +1,10 @@
+# frozen_string_literal: true
+
+module API
+ module Entities
+ class FeatureGate < Grape::Entity
+ expose :key
+ expose :value
+ end
+ end
+end
diff --git a/lib/api/entities/impersonation_token.rb b/lib/api/entities/impersonation_token.rb
new file mode 100644
index 00000000000..9ee8f8bf77b
--- /dev/null
+++ b/lib/api/entities/impersonation_token.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+module API
+ module Entities
+ class ImpersonationToken < Entities::PersonalAccessToken
+ expose :impersonation
+ end
+ end
+end
diff --git a/lib/api/entities/impersonation_token_with_token.rb b/lib/api/entities/impersonation_token_with_token.rb
new file mode 100644
index 00000000000..4904f107628
--- /dev/null
+++ b/lib/api/entities/impersonation_token_with_token.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+module API
+ module Entities
+ class ImpersonationTokenWithToken < Entities::PersonalAccessTokenWithToken
+ expose :impersonation
+ end
+ end
+end
diff --git a/lib/gitlab/runtime.rb b/lib/gitlab/runtime.rb
index 182c13980e6..3f6361c7276 100644
--- a/lib/gitlab/runtime.rb
+++ b/lib/gitlab/runtime.rb
@@ -12,6 +12,7 @@ module Gitlab
:console,
:geo_log_cursor,
:puma,
+ :rails_runner,
:rake,
:sidekiq,
:test_suite,
@@ -64,6 +65,10 @@ module Gitlab
!!defined?(::GeoLogCursorOptionParser)
end
+ def rails_runner?
+ !!defined?(::Rails::Command::RunnerCommand)
+ end
+
def web_server?
puma? || unicorn?
end
diff --git a/spec/lib/gitlab/runtime_spec.rb b/spec/lib/gitlab/runtime_spec.rb
index f6e8ad8ae79..56df73161b4 100644
--- a/spec/lib/gitlab/runtime_spec.rb
+++ b/spec/lib/gitlab/runtime_spec.rb
@@ -97,4 +97,12 @@ describe Gitlab::Runtime do
it_behaves_like "valid runtime", :geo_log_cursor, 1
end
+
+ context "rails runner" do
+ before do
+ stub_const('::Rails::Command::RunnerCommand', double('::Rails::Command::RunnerCommand'))
+ end
+
+ it_behaves_like "valid runtime", :rails_runner, 1
+ end
end
diff --git a/spec/services/ci/stop_environments_service_spec.rb b/spec/services/ci/stop_environments_service_spec.rb
index 88f2f5618c2..19a6bcc307f 100644
--- a/spec/services/ci/stop_environments_service_spec.rb
+++ b/spec/services/ci/stop_environments_service_spec.rb
@@ -217,18 +217,20 @@ describe Ci::StopEnvironmentsService do
context 'when user does not have a permission to play the stop action' do
before do
- Ci::Build.find_by_ref('review/feature-2').update_column(:user_id, nil)
+ project.team.truncate
end
it 'tracks the exception' do
- deployable = Ci::Build.find_by_ref('review/feature-2')
-
expect(Gitlab::ErrorTracking)
.to receive(:track_error)
- .with(Gitlab::Access::AccessDeniedError, deployable_id: deployable.id).once
+ .with(Gitlab::Access::AccessDeniedError, anything).twice
subject
end
+
+ after do
+ project.add_developer(user)
+ end
end
end