summaryrefslogtreecommitdiff
path: root/spec/models/integrations/field_spec.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-06-15 03:09:07 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-06-15 03:09:07 +0000
commitca520489ffe196b194843851148a3d0a17064957 (patch)
treec83b2696d21bed7a1888fb39aca0b10cb021fd63 /spec/models/integrations/field_spec.rb
parent0624d0c79f2c2151a7a6e04b9850cb78e2a93826 (diff)
downloadgitlab-ce-ca520489ffe196b194843851148a3d0a17064957.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/integrations/field_spec.rb')
-rw-r--r--spec/models/integrations/field_spec.rb21
1 files changed, 16 insertions, 5 deletions
diff --git a/spec/models/integrations/field_spec.rb b/spec/models/integrations/field_spec.rb
index c8caf831191..6b1ce7fcbde 100644
--- a/spec/models/integrations/field_spec.rb
+++ b/spec/models/integrations/field_spec.rb
@@ -5,7 +5,14 @@ require 'spec_helper'
RSpec.describe ::Integrations::Field do
subject(:field) { described_class.new(**attrs) }
- let(:attrs) { { name: nil } }
+ let(:attrs) { { name: nil, integration_class: test_integration } }
+ let(:test_integration) do
+ Class.new(Integration) do
+ def self.default_placeholder
+ 'my placeholder'
+ end
+ end
+ end
describe '#name' do
before do
@@ -68,11 +75,8 @@ RSpec.describe ::Integrations::Field do
end
context 'when set to a dynamic value' do
- before do
- attrs[name] = -> { Time.current }
- end
-
it 'is computed' do
+ attrs[name] = -> { Time.current }
start = Time.current
travel_to(start + 1.minute) do
@@ -80,6 +84,13 @@ RSpec.describe ::Integrations::Field do
expect(field.send(name)).to be_after(start)
end
end
+
+ it 'is executed in the class scope' do
+ attrs[name] = -> { default_placeholder }
+
+ expect(field[name]).to eq('my placeholder')
+ expect(field.send(name)).to eq('my placeholder')
+ end
end
end
end