aboutsummaryrefslogtreecommitdiffstats
path: root/spec/features/stop_areas_spec.rb
blob: ae17363091fa3e9b508a1050550d23d26f6614ed (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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# -*- coding: utf-8 -*-
require 'spec_helper'

describe "StopAreas", :type => :feature do
  login_user

  let(:stop_area_referential) { create :stop_area_referential, member: @user.organisation }
  let!(:stop_areas) { Array.new(2) { create :stop_area, stop_area_referential: stop_area_referential } }
  subject { stop_areas.first }

  describe "index" do
    before(:each) { visit stop_area_referential_stop_areas_path(stop_area_referential) }

    it "displays stop_areas" do
      expect(page).to have_content(stop_areas.first.name)
      expect(page).to have_content(stop_areas.last.name)
    end

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

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

      context 'filtering by status' do
        before(:each) do
          stop_areas.first.activate!
          stop_areas.last.activate!
          stop_areas.last.deactivate!
        end

        describe 'updated stop areas in before block' do

          it 'supports displaying only stop areas in creation' do
            find("#q_status_eq_any_in_creation").set(true)
            click_button 'search-btn'
            expect(page).not_to have_content(stop_areas.first.name)
            expect(page).not_to have_content(stop_areas.last.name)
          end

          it 'supports displaying only confirmed stop areas' do
            find("#q_status_eq_any_confirmed").set(true)
            click_button 'search-btn'
            expect(page).to have_content(stop_areas.first.name)
            expect(page).not_to have_content(stop_areas.last.name)
          end

          it 'supports displaying only deactivated stop areas' do
            find("#q_status_eq_any_deactivated").set(true)
            click_button 'search-btn'
            expect(page).not_to have_content(stop_areas.first.name)
            expect(page).to have_content(stop_areas.last.name)
          end

          it 'should display all stop areas if all filters are checked' do
            find("#q_status_eq_any_in_creation").set(true)
            find("#q_status_eq_any_confirmed").set(true)
            find("#q_status_eq_any_deactivated").set(true)
            click_button 'search-btn'
            expect(page).to have_content(stop_areas.first.name)
            expect(page).to have_content(stop_areas.last.name)
          end
        end
      end
    end
  end

  describe "show" do
    it "displays stop_area" do
      visit stop_area_referential_stop_area_path(stop_area_referential, stop_areas.first)
      expect(page).to have_content(stop_areas.first.name)
    end

    # it "display map" do
    #   visit stop_area_referential_stop_areas_path(stop_area_referential)
    #   # click_link "#{stop_areas.first.name}"
    #   visit stop_area_referential_stop_area_path(stop_area_referential, stop_areas.first)
    #   expect(page).to have_selector("#map.stop_area")
    # end

  end

  # Fixme #1780
  # describe "new" do
  #   it "creates stop_area and return to show" do
  #     visit stop_area_referential_stop_areas_path(stop_area_referential)
  #     click_link "Ajouter un arrêt"
  #     fill_in "stop_area_name", :with => "StopArea 1"
  #     fill_in "Numéro d'enregistrement", :with => "test-1"
  #     fill_in "Identifiant Neptune", :with => "test:StopArea:1"
  #     click_button("Créer arrêt")
  #     expect(page).to have_content("StopArea 1")
  #   end
  # end

  # Fixme #1780
  # describe "edit and return to show" do
  #   it "edit stop_area" do
  #     visit stop_area_referential_stop_area_path(stop_area_referential, subject)
  #     click_link "Editer cet arrêt"
  #     fill_in "stop_area_name", :with => "StopArea Modified"
  #     fill_in "Numéro d'enregistrement", :with => "test-1"
  #     click_button("Editer arrêt")
  #     expect(page).to have_content("StopArea Modified")
  #   end
  # end

end