diff options
| author | Luc Donnet | 2012-04-25 10:40:15 +0200 |
|---|---|---|
| committer | Luc Donnet | 2012-04-25 10:40:15 +0200 |
| commit | 07b8f918639b6095f0f0bb700ca310deaa18841c (patch) | |
| tree | 68d6a319164a0d633ed7052fa482c93788c3930c | |
| parent | fcac578e38f4e620113b3b877e27b952cf4caa95 (diff) | |
| download | chouette-core-07b8f918639b6095f0f0bb700ca310deaa18841c.tar.bz2 | |
Add spec request for lines networks and companies
| -rw-r--r-- | Gemfile | 67 | ||||
| -rw-r--r-- | Gemfile.lock | 57 | ||||
| -rw-r--r-- | db/migrate/20120425080337_create_chouette_route.rb | 21 | ||||
| -rw-r--r-- | db/schema.rb | 17 | ||||
| -rw-r--r-- | spec/factories.rb | 16 | ||||
| -rw-r--r-- | spec/requests/companies_spec.rb | 41 | ||||
| -rw-r--r-- | spec/requests/lines_spec.rb | 56 | ||||
| -rw-r--r-- | spec/requests/networks_spec.rb | 74 |
8 files changed, 235 insertions, 114 deletions
@@ -1,31 +1,34 @@ source 'http://rubygems.org' gem 'rails', '3.1.3' - -# Bundle edge Rails instead: -# gem 'rails', :git => 'git://github.com/rails/rails.git' - -gem 'user_interface', :git => 'git://sim.dryade.priv/user_interface' - -gem 'apartment', :git => 'git://github.com/dryade/apartment.git' - +gem 'jquery-rails' gem 'devise' -gem "map_layers", "~> 0.0.4" - platforms :jruby do gem 'activerecord-jdbcpostgresql-adapter', :git => 'git://github.com/dryade/activerecord-jdbc-adapter.git' gem 'activerecord-jdbcsqlite3-adapter' gem 'jruby-openssl' + gem 'warbler' end platforms :ruby do gem 'pg', '~> 0.11.0' gem 'sqlite3' + gem 'capybara-webkit' end +gem "map_layers", "~> 0.0.4" + +gem 'user_interface', :git => 'git://sim.dryade.priv/user_interface' gem 'json' -gem 'warbler' +gem 'formtastic' +gem 'inherited_resources' +gem 'will_paginate', '~> 3.0' +gem 'ransack' +gem 'squeel' + +gem 'apartment', :git => 'git://github.com/dryade/apartment.git' +gem 'ninoxe', :git => 'git://chouette.dryade.priv/ninoxe'#, :path => '~/projects/ninoxe' # Gems used only for assets and not required # in production environments by default. @@ -37,39 +40,14 @@ group :assets do gem 'therubyrhino' end -gem 'jquery-rails' - -# To use ActiveModel has_secure_password -# gem 'bcrypt-ruby', '~> 3.0.0' - -# Use unicorn as the web server -# gem 'unicorn' - -# Deploy with Capistrano -# gem 'capistrano' - -# To use debugger -# gem 'ruby-debug' - -gem 'formtastic' -gem 'inherited_resources' -gem 'will_paginate', '~> 3.0' -gem 'ransack' -gem 'squeel' -gem 'RedCloth' - -gem 'ninoxe', :git => 'git://chouette.dryade.priv/ninoxe'#, :path => '~/projects/ninoxe' - group :development do - gem 'autotest-rails' - gem 'autotest-notification' gem 'capistrano' gem 'capistrano-ext' gem 'guard' gem 'guard-rspec' end -group :test, :development, :cucumber do +group :test, :development do gem "rspec" gem "rspec-rails" gem "remarkable", "~> 4.0.0.alpha4" @@ -77,20 +55,11 @@ group :test, :development, :cucumber do gem "shoulda", :git => 'git://github.com/thoughtbot/shoulda.git' end -group :cucumber do - gem 'capybara' - gem 'cucumber' - gem 'cucumber-rails' - gem 'launchy' - gem 'pickle', :git => 'git://github.com/mflorisson/pickle.git' -end - -group :test, :cucumber do - gem 'capybara' +group :test do + gem 'capybara' gem 'launchy' gem 'database_cleaner' - gem 'factory_girl_rails' - gem 'factory_girl' + gem 'factory_girl_rails', '1.7' end group :production do diff --git a/Gemfile.lock b/Gemfile.lock index 536c6edca..663ccaf5f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,6 +1,6 @@ GIT remote: git://chouette.dryade.priv/ninoxe - revision: be3072bcfbceb597bc74ee7661733ea01110632a + revision: b0092753d05902daba83fe717159ba056fdd4b6f specs: ninoxe (0.0.8) GeoRuby @@ -26,16 +26,6 @@ GIT apartment (0.14.1) GIT - remote: git://github.com/mflorisson/pickle.git - revision: 4316faa3ef00c414bf286336c57a6d10addcf79f - specs: - pickle (0.4.4) - cucumber (>= 0.8) - rake - rspec (>= 1.3) - yard - -GIT remote: git://github.com/thoughtbot/shoulda.git revision: 80545637b957fc68a3b7be8993033d089913ac66 specs: @@ -54,11 +44,8 @@ GEM remote: http://rubygems.org/ specs: GeoRuby (1.3.4) - RedCloth (4.2.9) - RedCloth (4.2.9-java) SyslogLogger (1.4.0) hoe (>= 1.2.0) - ZenTest (4.5.0) actionmailer (3.1.3) actionpack (= 3.1.3) mail (~> 2.3.0) @@ -92,11 +79,6 @@ GEM multi_json (~> 1.0) addressable (2.2.6) arel (2.2.3) - autotest-notification (2.3.4) - autotest-standalone (~> 4.5) - autotest-rails (4.1.1) - ZenTest (= 4.5) - autotest-standalone (4.5.9) bcrypt-ruby (3.0.1) bcrypt-ruby (3.0.1-java) bouncy-castle-java (1.5.0146.1) @@ -116,6 +98,9 @@ GEM rack-test (>= 0.5.4) selenium-webdriver (~> 2.0) xpath (~> 0.1.4) + capybara-webkit (0.11.0) + capybara (>= 1.0.0, < 1.2) + json childprocess (0.3.0) ffi (~> 1.0.6) coffee-rails (3.1.1) @@ -127,16 +112,6 @@ GEM coffee-script-source (1.1.2) composite_primary_keys (4.1.2) activerecord (~> 3.1) - cucumber (1.1.4) - builder (>= 2.1.2) - diff-lcs (>= 1.1.2) - gherkin (~> 2.7.1) - json (>= 1.4.6) - term-ansicolor (>= 1.0.6) - cucumber-rails (1.2.1) - capybara (>= 1.1.2) - cucumber (>= 1.1.3) - nokogiri (>= 1.5.0) database_cleaner (0.7.1) devise (2.0.4) bcrypt-ruby (~> 3.0) @@ -147,10 +122,10 @@ GEM erubis (2.7.0) execjs (1.2.13) multi_json (~> 1.0) - factory_girl (2.5.0) - activesupport - factory_girl_rails (1.6.0) - factory_girl (~> 2.5.0) + factory_girl (2.6.4) + activesupport (>= 2.3.9) + factory_girl_rails (1.7.0) + factory_girl (~> 2.6.0) railties (>= 3.0.0) ffi (1.0.11) ffi (1.0.11-java) @@ -158,10 +133,6 @@ GEM rails (~> 3.0) geokit (1.6.5) multi_json - gherkin (2.7.6) - json (>= 1.4.6) - gherkin (2.7.6-java) - json (>= 1.4.6) guard (1.0.1) ffi (>= 0.5.0) thor (~> 0.14.6) @@ -292,7 +263,6 @@ GEM activerecord (~> 3.0) activesupport (~> 3.0) polyamorous (~> 0.5.0) - term-ansicolor (1.0.7) therubyrhino (1.73.1) thor (0.14.6) tilt (1.3.3) @@ -313,31 +283,25 @@ GEM will_paginate (3.0.3) xpath (0.1.4) nokogiri (~> 1.3) - yard (0.7.4) PLATFORMS java ruby DEPENDENCIES - RedCloth SyslogLogger activerecord-jdbcpostgresql-adapter! activerecord-jdbcsqlite3-adapter apartment! - autotest-notification - autotest-rails capistrano capistrano-ext capybara + capybara-webkit coffee-rails (~> 3.1.1) coffee-script-source - cucumber - cucumber-rails database_cleaner devise - factory_girl - factory_girl_rails + factory_girl_rails (= 1.7) formtastic guard guard-rspec @@ -349,7 +313,6 @@ DEPENDENCIES map_layers (~> 0.0.4) ninoxe! pg (~> 0.11.0) - pickle! rails (= 3.1.3) ransack remarkable (~> 4.0.0.alpha4) diff --git a/db/migrate/20120425080337_create_chouette_route.rb b/db/migrate/20120425080337_create_chouette_route.rb new file mode 100644 index 000000000..98d0f3c11 --- /dev/null +++ b/db/migrate/20120425080337_create_chouette_route.rb @@ -0,0 +1,21 @@ +class CreateChouetteRoute < ActiveRecord::Migration + def up + create_table "route", :force => true do |t| + t.integer "lineid", :limit => 8 + t.string "objectid" + t.integer "objectversion" + t.datetime "creationtime" + t.string "creatorid" + t.string "name" + t.string "comment" + t.integer "oppositerouteid", :limit => 8 + t.string "publishedname" + t.string "number" + t.string "direction" + t.string "wayback" + end + end + + def down + end +end diff --git a/db/schema.rb b/db/schema.rb index 89a3326fd..c21ab020c 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20120416095046) do +ActiveRecord::Schema.define(:version => 20120425080337) do create_table "company", :force => true do |t| t.string "objectid" @@ -75,6 +75,21 @@ ActiveRecord::Schema.define(:version => 20120416095046) do t.datetime "updated_at" end + create_table "route", :force => true do |t| + t.integer "lineid", :limit => 8 + t.string "objectid" + t.integer "objectversion" + t.datetime "creationtime" + t.string "creatorid" + t.string "name" + t.string "comment" + t.integer "oppositerouteid", :limit => 8 + t.string "publishedname" + t.string "number" + t.string "direction" + t.string "wayback" + end + create_table "stoparea", :force => true do |t| t.integer "parentid", :limit => 8 t.string "objectid" diff --git a/spec/factories.rb b/spec/factories.rb index f0d8cc86b..91ee3e0f0 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -33,16 +33,16 @@ FactoryGirl.define do network.sequence(:name) { |n| "Network #{n}" } network.sequence(:objectid) { |n| "test:GroupOfLine:#{n}" } network.sequence(:registration_number) { |n| "test-#{n}" } - end - # factory :chouette_stop_area, :class => "Chouette::StopArea" do |f| - # f.latitude 10 * rand - # f.longitude 10 * rand - # f.sequence(:name) { |n| "StopArea #{n}" } - # f.areatype "CommercialStopPoint" - # f.objectid - # end + factory :stop_area, :class => "Chouette::StopArea" do |stop_area| + stop_area.sequence(:name) { |n| "StopArea #{n}" } + stop_area.latitude 10 + stop_area.longitude 10 + stop_area.areatype "CommercialStopPoint" + stop_area.sequence(:registration_number) { |n| "test-#{n}" } + stop_area.sequence(:objectid) { |n| "test:StopArea:#{n}" } + end factory :referential do |f| f.sequence(:name) { |n| "Test #{n}" } diff --git a/spec/requests/companies_spec.rb b/spec/requests/companies_spec.rb index 77a08743b..d464fd307 100644 --- a/spec/requests/companies_spec.rb +++ b/spec/requests/companies_spec.rb @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- require 'spec_helper' describe "Companies" do @@ -5,11 +6,47 @@ describe "Companies" do let!(:referential) { create(:referential).switch } let!(:companies) { referential; Array.new(2) { create(:company) } } + subject { companies.first } - describe "GET /companies" do - it "should display company names" do + describe "list" do + it "display companies" do visit referential_companies_path(referential) page.should have_content(companies.first.name) + page.should have_content(companies.last.name) + end + + end + + describe "show" do + it "display company" do + visit referential_companies_path(referential) + click_link "#{companies.first.name}" + page.should have_content(companies.first.name) + end + + end + + describe "new" do + it "creates company and return to show" do + visit referential_companies_path(referential) + click_link "Ajouter un transporteur" + fill_in "Nom", :with => "Company 1" + fill_in "Numéro d'enregistrement", :with => "test-1" + fill_in "Identifiant Neptune", :with => "test:Company:1" + click_button("Créer Transporteur") + page.should have_content("Company 1") + end + end + + describe "edit and return to show" do + it "edit company" do + visit referential_company_path(referential, subject) + click_link "Modifier ce transporteur" + fill_in "Nom", :with => "Company Modified" + fill_in "Numéro d'enregistrement", :with => "test-1" + click_button("Modifier Transporteur") + page.should have_content("Company Modified") end end + end diff --git a/spec/requests/lines_spec.rb b/spec/requests/lines_spec.rb index 00048361c..3a5e4d507 100644 --- a/spec/requests/lines_spec.rb +++ b/spec/requests/lines_spec.rb @@ -1,16 +1,64 @@ +# -*- coding: utf-8 -*- require 'spec_helper' describe "Lines" do login_user let!(:referential) { create(:referential).switch } - let!(:lines) { referential; Array.new(2) { create(:line) } } + let!(:network) { Factory(:network) } + let!(:company) { Factory(:company) } + let!(:lines) { referential; Array.new(2) { Factory(:line, :network => network, :company => company) } } + subject { lines.first } - describe "GET /lines" do - it "works! (now write some real specs)" do - # Run the generator again with the --webrat flag if you want to use webrat methods/matchers + describe "list" do + it "display lines" do visit referential_lines_path(referential) page.should have_content(lines.first.name) + page.should have_content(lines.last.name) + end + + end + + + describe "show" do + it "display line" do + subject.stub(:stop_areas).and_return(Array.new(2) { Factory(:stop_area) }) + visit referential_lines_path(referential) + click_link "#{lines.first.name}" + page.should have_content(lines.first.name) + end + + it "display map" do + subject.stub(:stop_areas).and_return(Array.new(2) { Factory(:stop_area) }) + visit referential_lines_path(referential) + click_link "#{lines.first.name}" + page.should have_selector("#map", :class => 'line') + end + + end + + describe "new" do + it "creates line and return to show" do + subject.stub(:stop_areas).and_return(Array.new(2) { Factory(:stop_area) }) + visit referential_lines_path(referential) + click_link "Ajouter une ligne" + fill_in "Nom", :with => "Line 1" + fill_in "Numéro d'enregistrement", :with => "test-1" + fill_in "Identifiant Neptune", :with => "test:Line:1" + click_button("Créer Ligne") + page.should have_content("Line 1") + end + end + + describe "edit and return to show" do + it "edit line" do + subject.stub(:stop_areas).and_return(Array.new(2) { Factory(:stop_area) }) + visit referential_line_path(referential, subject) + click_link "Modifier cette ligne" + fill_in "Nom", :with => "Line Modified" + fill_in "Numéro d'enregistrement", :with => "test-1" + click_button("Modifier Ligne") + page.should have_content("Line Modified") end end diff --git a/spec/requests/networks_spec.rb b/spec/requests/networks_spec.rb index dddf6e09b..b48f0312c 100644 --- a/spec/requests/networks_spec.rb +++ b/spec/requests/networks_spec.rb @@ -1,15 +1,83 @@ +# -*- coding: utf-8 -*- require 'spec_helper' describe "Networks" do login_user let!(:referential) { create(:referential).switch } - let!(:networks) { referential; Array.new(2) { create(:network) } } + let!(:networks) { referential; Array.new(2) { Factory(:network) } } + subject { networks.first } - describe "GET /networks" do - it "works! (now write some real specs)" do + describe "list" do + it "display networks" do visit referential_networks_path(referential) page.should have_content(networks.first.name) + page.should have_content(networks.last.name) end + + end + + describe "show" do + it "display network" do + subject.stub(:stop_areas).and_return(Array.new(2) { Factory(:stop_area) }) + visit referential_networks_path(referential) + click_link "#{networks.first.name}" + page.should have_content(networks.first.name) + end + + it "display map" do + subject.stub(:stop_areas).and_return(Array.new(2) { Factory(:stop_area) }) + visit referential_networks_path(referential) + click_link "#{networks.first.name}" + page.should have_selector("#map", :class => 'network') + end + + end + + describe "new" do + it "creates network and return to show" do + subject.stub(:stop_areas).and_return(Array.new(2) { Factory(:stop_area) }) + visit referential_networks_path(referential) + click_link "Ajouter un réseau" + fill_in "Nom", :with => "Network 1" + fill_in "Numéro d'enregistrement", :with => "test-1" + fill_in "Identifiant Neptune", :with => "test:GroupOfLine:1" + click_button("Créer Réseau") + page.should have_content("Network 1") + end + end + + describe "edit and return to show" do + it "edit network" do + subject.stub(:stop_areas).and_return(Array.new(2) { Factory(:stop_area) }) + visit referential_network_path(referential, subject) + click_link "Modifier ce réseau" + fill_in "Nom", :with => "Network Modified" + fill_in "Numéro d'enregistrement", :with => "test-1" + click_button("Modifier Réseau") + page.should 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) { Factory(:stop_area) }) + + # visit referential_networks_path(referential) + # puts page.body + # click_link "#{networks.first.name}" + # click_link "Modifier ce réseau" + # fill_in "Nom", :with => "Network 1" + # fill_in "Numéro d'enregistrement", :with => "test-1" + # click_button("Modifier Réseau") + # page.should have_content("Network 1") + # visit referential_network_path(referential, subject) + # puts page.body.inspect + # click_link "Supprimer ce réseau" + # page.evaluate_script('window.confirm = function() { return true; }') + # click_button "Valider" + # page.should have_no_content("Network 1") + end + end end |
