Commit c4227778 authored by Alex Kalderimis's avatar Alex Kalderimis

Remove references to service from field entity spec

parent 7405a8e4
......@@ -5,7 +5,7 @@ require 'spec_helper'
RSpec.describe ServiceFieldEntity do
let(:request) { double('request') }
subject { described_class.new(field, request: request, service: service).as_json }
subject { described_class.new(field, request: request, service: integration).as_json }
before do
allow(request).to receive(:service).and_return(integration)
......@@ -16,7 +16,7 @@ RSpec.describe ServiceFieldEntity do
let(:integration) { create(:jira_integration) }
context 'field with type text' do
let(:field) { integration.global_fields.find { |field| field[:name] == 'username' } }
let(:field) { integration_field('username') }
it 'exposes correct attributes' do
expected_hash = {
......@@ -35,7 +35,7 @@ RSpec.describe ServiceFieldEntity do
end
context 'field with type password' do
let(:field) { integration.global_fields.find { |field| field[:name] == 'password' } }
let(:field) { integration_field('password') }
it 'exposes correct attributes but hides password' do
expected_hash = {
......@@ -56,10 +56,9 @@ RSpec.describe ServiceFieldEntity do
context 'EmailsOnPush Service' do
let(:integration) { create(:emails_on_push_integration, send_from_committer_email: '1') }
let(:service) { integration } # TODO: remove when https://gitlab.com/gitlab-org/gitlab/-/issues/330300 is complete
context 'field with type checkbox' do
let(:field) { integration.global_fields.find { |field| field[:name] == 'send_from_committer_email' } }
let(:field) { integration_field('send_from_committer_email') }
it 'exposes correct attributes and casts value to Boolean' do
expected_hash = {
......@@ -78,7 +77,7 @@ RSpec.describe ServiceFieldEntity do
end
context 'field with type select' do
let(:field) { integration.global_fields.find { |field| field[:name] == 'branches_to_be_notified' } }
let(:field) { integration_field('branches_to_be_notified') }
it 'exposes correct attributes' do
expected_hash = {
......@@ -97,4 +96,8 @@ RSpec.describe ServiceFieldEntity do
end
end
end
def integration_field(name)
integration.global_fields.find { |f| f[:name] == name }
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment