aboutsummaryrefslogtreecommitdiffstats
path: root/spec/features/networks_spec.rb
blob: ae318ce77e02b01117ca7a90a60d137aa7c83eed (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
# -*- coding: utf-8 -*-
require 'spec_helper'

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

  let!(:networks) { Array.new(2) { create(:network) } }
  subject { networks.first }

  describe "list" do
    it "display networks" do
      visit referential_networks_path(referential)
      expect(page).to have_content(networks.first.name)
      expect(page).to have_content(networks.last.name)
    end
    
  end 

  describe "show" do
    it "display network" do
      # allow(subject).to receive(:stop_areas).and_return(Array.new(2) { create(:stop_area) })
      visit referential_networks_path(referential)
      click_link "#{networks.first.name}"
      expect(page).to have_content(networks.first.name)
    end

    it "display map" do
      # allow(subject).to receive(:stop_areas).and_return(Array.new(2) { create(:stop_area) })
      visit referential_networks_path(referential)
      click_link "#{networks.first.name}"
      expect(page).to have_selector("#map.network")
    end
    
  end

  # describe "new" do
  #   it "creates network and return to show" do
  #     # allow(subject).to receive(:stop_areas).and_return(Array.new(2) { create(:stop_area) })
  #     visit referential_networks_path(referential)
  #     click_link "Ajouter un réseau"
  #     fill_in "network_name", :with => "Network 1"
  #     fill_in "Numéro d'enregistrement", :with => "test-1"
  #     fill_in "Identifiant Neptune", :with => "chouette:test:GroupOfLine:1"
  #     click_button("Créer réseau")
  #     expect(page).to have_content("Network 1")
  #   end
  # end

  describe "edit and return to show" do
    it "edit network" do
      # allow(subject).to receive(:stop_areas).and_return(Array.new(2) { create(:stop_area) })
      visit referential_network_path(referential, subject)
      click_link "Modifier ce réseau"
      fill_in "network_name", :with => "Network Modified"
      fill_in "Numéro d'enregistrement", :with => "test-1"
      click_button("Modifier réseau")
      expect(page).to have_content("Network Modified")
    end
  end

  # describe "delete", :js => true do
  #   it "delete network and return to the list" do
  #     subject.stub(:stop_areas).and_return(Array.new(2) { create(:stop_area) })     
  #     visit referential_network_path(referential, subject)
  #     click_link "Supprimer ce réseau"
  #     page.evaluate_script('window.confirm = function() { return true; }')
  #     click_button "Valider"
  #     page.should have_no_content(subject.name)
  #   end

  # end
end