summaryrefslogtreecommitdiff
path: root/spec/support/shared_examples/models/services_fields_shared_examples.rb
blob: cb36f74460d2a38cb7d1dfe15d65ee490fc56e0e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# frozen_string_literal: true

RSpec.shared_examples 'issue tracker fields' do
  let(:title) { 'custom title' }
  let(:description) { 'custom description' }
  let(:url) { 'http://issue_tracker.example.com' }

  context 'when data are stored in the properties' do
    describe '#update' do
      before do
        service.update(title: 'new_title', description: 'new description')
      end

      it 'removes title and description from properties' do
        expect(service.reload.properties).not_to include('title', 'description')
      end

      it 'stores title & description in services table' do
        expect(service.read_attribute(:title)).to eq('new_title')
        expect(service.read_attribute(:description)).to eq('new description')
      end
    end

    describe 'reading fields' do
      it 'returns correct values' do
        expect(service.title).to eq(title)
        expect(service.description).to eq(description)
      end
    end
  end
end