aboutsummaryrefslogtreecommitdiffstats
path: root/spec/features/group_of_lines_spec.rb
blob: 6b2f1968a3fd9af25fb12454cca2f0bc402dbfd1 (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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# -*- coding: utf-8 -*-
require 'spec_helper'

describe "Group of lines", :type => :feature do
  login_user

  let!(:network) { create(:network) }
  let!(:company) { create(:company) }
  let!(:line) { create(:line_with_stop_areas, :network => network, :company => company) }
  let!(:group_of_lines) { Array.new(2) { create(:group_of_line, line_referential: line_referential) } }
  subject { group_of_lines.first }

  let(:line_referential) { create :line_referential, member: @user.organisation }

  before :each do
    subject.lines << line
  end

  describe "index" do
    before(:each) { visit line_referential_group_of_lines_path(line_referential) }

    it "displays groups of lines" do
      expect(page).to have_content(group_of_lines.first.name)
      expect(page).to have_content(group_of_lines.last.name)
    end

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

  describe "show" do
    it "displays group of line" do
      visit line_referential_group_of_lines_path(line_referential)
      click_link subject.name
      expect(page).to have_content(subject.name)
    end
  end

  # Fixme #1780
  # describe "new" do
  #   it "creates group of line and return to show" do
  #     visit line_referential_group_of_lines_path(line_referential)
  #     click_link I18n.t('group_of_lines.actions.new')
  #     fill_in "group_of_line[name]", :with => "Group of lines 1"
  #     fill_in "group_of_line[registration_number]", :with => "1"
  #     fill_in "group_of_line[objectid]", :with => "chouette:test:GroupOfLine:999"
  #     click_button(I18n.t('formtastic.create',model: I18n.t('activerecord.models.group_of_line.one')))
  #     expect(page).to have_content("Group of lines 1")
  #   end
  # end

  # describe "edit and return to show" do
  #   it "edit line" do
  #     visit line_referential_group_of_line_path(line_referential, subject)
  #     click_link I18n.t('group_of_lines.actions.edit')
  #     fill_in "group_of_line[name]", :with => "Group of lines Modified"
  #     fill_in "group_of_line[registration_number]", :with => "test-1"
  #     click_button(I18n.t('formtastic.update',model: I18n.t('activerecord.models.group_of_line.one')))
  #     expect(page).to have_content("Group of lines Modified")
  #   end
  # end

end