aboutsummaryrefslogtreecommitdiffstats
path: root/spec/features/referential_companies_spec.rb
blob: 82f86b19214e39a64902e4237f5d77e7a2e6faac (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
32
33
34
35
36
37
38
39
40
41
# -*- coding: utf-8 -*-
require 'spec_helper'

describe 'ReferentialCompanies', type: :feature do
  login_user

  let(:referential) { Referential.first }
  let!(:companies) { Array.new(2) { create :company, line_referential: referential.line_referential } }

  describe 'index' do
    before(:each) { visit referential_companies_path(referential) }

    it 'displays referential companies' do
      expect(page).to have_content(companies.first.name)
      expect(page).to have_content(companies.last.name)
    end

    context 'filtering' do
      it 'supports filtering by name' do
        fill_in 'q[name_or_objectid_cont]', with: companies.first.name
        click_button 'search-btn'
        expect(page).to have_content(companies.first.name)
        expect(page).not_to have_content(companies.last.name)
      end

      it 'supports filtering by objectid' do
        fill_in 'q[name_or_objectid_cont]', with: companies.first.objectid
        click_button 'search-btn'
        expect(page).to have_content(companies.first.name)
        expect(page).not_to have_content(companies.last.name)
      end
    end
  end

  describe 'show' do
    it 'displays referential company' do
      visit referential_company_path(referential, companies.first)
      expect(page).to have_content(companies.first.name)
    end
  end
end