diff options
38 files changed, 697 insertions, 12 deletions
diff --git a/app/controllers/chouette_controller.rb b/app/controllers/chouette_controller.rb new file mode 100644 index 000000000..051e2fd77 --- /dev/null +++ b/app/controllers/chouette_controller.rb @@ -0,0 +1,13 @@ +class ChouetteController < InheritedResources::Base + + before_filter :switch_referential + + def switch_referential + Apartment::Database.switch(referential.slug) + end + + def referential + @referential = Referential.find params[:referential_id] + end + +end
\ No newline at end of file diff --git a/app/controllers/companies_controller.rb b/app/controllers/companies_controller.rb new file mode 100644 index 000000000..3cb440ea2 --- /dev/null +++ b/app/controllers/companies_controller.rb @@ -0,0 +1,7 @@ +class CompaniesController < ChouetteController + defaults :resource_class => Chouette::Company + respond_to :html + respond_to :xml + respond_to :json + +end diff --git a/app/controllers/networks_controller.rb b/app/controllers/networks_controller.rb new file mode 100644 index 000000000..eed00f365 --- /dev/null +++ b/app/controllers/networks_controller.rb @@ -0,0 +1,7 @@ +class NetworksController < ChouetteController + defaults :resource_class => Chouette::Network + respond_to :html + respond_to :xml + respond_to :json + +end diff --git a/app/views/companies/_form.erb b/app/views/companies/_form.erb new file mode 100644 index 000000000..19a3b8b84 --- /dev/null +++ b/app/views/companies/_form.erb @@ -0,0 +1,18 @@ +<%= semantic_form_for [@referential, @line] do |form| %> + <%= form.inputs do %> + <%= form.input :network, :as => :select, :collection => Chouette::Network.all, :include_blank => false %> + <%= form.input :company, :as => :select, :collection => Chouette::Company.all, :include_blank => false%> + <%= form.input :registrationnumber %> + <%= form.input :name %> + <%= form.input :publishedname %> + <%= form.input :number %> + <%= form.input :transportmodename, :as => :select, :collection => Chouette::TransportMode.definitions, :include_blank => false, :member_label => Proc.new { |a| t("#{a[0]}") } %> + <%= form.input :comment, :as => :text %> + <% end %> + + <%= form.buttons do %> + <%= form.commit_button true %> + <li><%= t('or') %></li> + <li><%= link_to t('back'), :back %></li> + <% end %> +<% end %> diff --git a/app/views/companies/_line.erb b/app/views/companies/_line.erb new file mode 100644 index 000000000..f594c7f9d --- /dev/null +++ b/app/views/companies/_line.erb @@ -0,0 +1,11 @@ +<%= div_for(line) do %> + <%= link_to([@referential, line], :class => "preview") do %> + <div class="color" style="background-color: grey "> + <div class="number"><%= line.number %></div> + </div> + <% end %> + <%= link_to line.name, [@referential, line] %> + <div class="info"> + + </div> +<% end %> diff --git a/app/views/companies/edit.html.erb b/app/views/companies/edit.html.erb new file mode 100644 index 000000000..491a821fa --- /dev/null +++ b/app/views/companies/edit.html.erb @@ -0,0 +1,3 @@ +<%= title_tag "Modifier la Ligne #{@line.name}" %> + +<%= render "form" %> diff --git a/app/views/companies/index.html.erb b/app/views/companies/index.html.erb new file mode 100644 index 000000000..03f5331e0 --- /dev/null +++ b/app/views/companies/index.html.erb @@ -0,0 +1,17 @@ +<div class="order"> + Trier par + <%= link_to_order "Code", "code" %> | + <%= link_to_order "Priorité", "priority" %> | + <%= link_to_order "Nom", "name" %> +</div> + +<%= title_tag Chouette::Line.model_name.human.pluralize %> + +<%= render :partial => "line", :collection => @lines %> + +<% content_for :sidebar do %> +<ul class="actions"> + <li><%= link_to t('lines.actions.new'), new_referential_line_path(@referential), :class => "add" %></li> + <br> +</ul> +<% end %> diff --git a/app/views/companies/new.html.erb b/app/views/companies/new.html.erb new file mode 100644 index 000000000..d580a2aae --- /dev/null +++ b/app/views/companies/new.html.erb @@ -0,0 +1,3 @@ +<%= title_tag "Créer la Ligne" %> + +<%= render "form" %> diff --git a/app/views/companies/show.html.erb b/app/views/companies/show.html.erb new file mode 100644 index 000000000..f0d987d3f --- /dev/null +++ b/app/views/companies/show.html.erb @@ -0,0 +1,47 @@ +<%= title_tag @line.name %> + +<div class="line_show"> + + <div class="summary"> + <p> + <label><%= Chouette::Line.human_attribute_name(:network) %>: </label> + <%= @line.network.name if @line.network.present? %> + </p> + <p> + <label><%= Chouette::Line.human_attribute_name("company") %>: </label> + <%= @line.company.name if @line.company.present? %> + </p> + <p> + <label><%= Chouette::Line.human_attribute_name("registrationnumber") %>: </label> + <%= @line.registrationnumber %> + </p> + <p> + <label><%= Chouette::Line.human_attribute_name("name") %>: </label> + <%= @line.name %> + </p> + <p> + <label><%= Chouette::Line.human_attribute_name("publishedname") %>: </label> + <%= @line.publishedname %> + </p> + <p> + <label><%= Chouette::Line.human_attribute_name("number") %>: </label> + <%= @line.number %> + </p> + <p> + <label><%= Chouette::Line.human_attribute_name("transportmodename") %>: </label> + <%= @line.transportmodename %> + </p> + <p> + <label><%= Chouette::Line.human_attribute_name("comment") %>: </label> + <%= @line.comment %> + </p> + </div> +</div> + +<% content_for :sidebar do %> +<ul class="actions"> + <li><%= link_to t('lines.actions.edit'), edit_referential_line_path(@referential, @line), :class => "edit" %></li> + <li><%= link_to t('lines.actions.destroy'), referential_line_path(@referential, @line), :method => :delete, :confirm => t('lines.actions.destroy_confirm'), :class => "remove" %></li> + <br> +</ul> +<% end %> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 7e0460ebb..50633675d 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -16,7 +16,14 @@ <div class="tabs"> <ul class="main"> - <li><%= tab_link_to t('activerecord.models.line'), lines_path %></li> + <% unless @referential %> + <li><%= tab_link_to t('activerecord.models.referential'), referentials_path %></li> + <% else %> + <li><%= link_to "Tableau de bord", referential_path(@referential), :class => ("current" if current_page?(referential_path(@referential))) %></li> + <li><%= tab_link_to t('activerecord.models.line'), referential_lines_path(@referential) %></li> + <li><%= tab_link_to t('activerecord.models.network'), referential_networks_path(@referential) %></li> + <li><%= tab_link_to t('activerecord.models.company'), referential_companies_path(@referential) %></li> + <% end %> </ul> </div> </div> diff --git a/app/views/networks/_form.erb b/app/views/networks/_form.erb new file mode 100644 index 000000000..877e238bf --- /dev/null +++ b/app/views/networks/_form.erb @@ -0,0 +1,17 @@ +<%= semantic_form_for [@referential, @network] do |form| %> + <%= form.inputs do %> + <%= form.input :name %> + <%= form.input :registration_number %> + <%= form.input :comment, :as => :text %> + <%= form.input :version_date %> + <%= form.input :description, :as => :text %> + <%= form.input :source_name, :as => :text %> + <%= form.input :source_identifier, :as => :text %> + <% end %> + + <%= form.buttons do %> + <%= form.commit_button %> + <li><%= t('or') %></li> + <li><%= link_to t('back'), :back %></li> + <% end %> +<% end %> diff --git a/app/views/networks/_form.erb~ b/app/views/networks/_form.erb~ new file mode 100644 index 000000000..19a3b8b84 --- /dev/null +++ b/app/views/networks/_form.erb~ @@ -0,0 +1,18 @@ +<%= semantic_form_for [@referential, @line] do |form| %> + <%= form.inputs do %> + <%= form.input :network, :as => :select, :collection => Chouette::Network.all, :include_blank => false %> + <%= form.input :company, :as => :select, :collection => Chouette::Company.all, :include_blank => false%> + <%= form.input :registrationnumber %> + <%= form.input :name %> + <%= form.input :publishedname %> + <%= form.input :number %> + <%= form.input :transportmodename, :as => :select, :collection => Chouette::TransportMode.definitions, :include_blank => false, :member_label => Proc.new { |a| t("#{a[0]}") } %> + <%= form.input :comment, :as => :text %> + <% end %> + + <%= form.buttons do %> + <%= form.commit_button true %> + <li><%= t('or') %></li> + <li><%= link_to t('back'), :back %></li> + <% end %> +<% end %> diff --git a/app/views/networks/_line.erb~ b/app/views/networks/_line.erb~ new file mode 100644 index 000000000..f594c7f9d --- /dev/null +++ b/app/views/networks/_line.erb~ @@ -0,0 +1,11 @@ +<%= div_for(line) do %> + <%= link_to([@referential, line], :class => "preview") do %> + <div class="color" style="background-color: grey "> + <div class="number"><%= line.number %></div> + </div> + <% end %> + <%= link_to line.name, [@referential, line] %> + <div class="info"> + + </div> +<% end %> diff --git a/app/views/networks/_network.erb b/app/views/networks/_network.erb new file mode 100644 index 000000000..4adf6896b --- /dev/null +++ b/app/views/networks/_network.erb @@ -0,0 +1,6 @@ +<%= div_for(network) do %> + <%= link_to network.name, [@referential, network] %> + <div class="info"> + + </div> +<% end %> diff --git a/app/views/networks/edit.html.erb b/app/views/networks/edit.html.erb new file mode 100644 index 000000000..90ffef291 --- /dev/null +++ b/app/views/networks/edit.html.erb @@ -0,0 +1,3 @@ +<%= title_tag t('networks.index.title'), {@line.name} %> + +<%= render "form" %> diff --git a/app/views/networks/edit.html.erb~ b/app/views/networks/edit.html.erb~ new file mode 100644 index 000000000..491a821fa --- /dev/null +++ b/app/views/networks/edit.html.erb~ @@ -0,0 +1,3 @@ +<%= title_tag "Modifier la Ligne #{@line.name}" %> + +<%= render "form" %> diff --git a/app/views/networks/index.html.erb b/app/views/networks/index.html.erb new file mode 100644 index 000000000..3743a1865 --- /dev/null +++ b/app/views/networks/index.html.erb @@ -0,0 +1,10 @@ +<%= title_tag t('networks.index.title') %> + +<%= render :partial => "network", :collection => @networks %> + +<% content_for :sidebar do %> +<ul class="actions"> + <li><%= link_to t('networks.actions.new'), new_referential_network_path(@referential), :class => "add" %></li> + <br> +</ul> +<% end %> diff --git a/app/views/networks/index.html.erb~ b/app/views/networks/index.html.erb~ new file mode 100644 index 000000000..03f5331e0 --- /dev/null +++ b/app/views/networks/index.html.erb~ @@ -0,0 +1,17 @@ +<div class="order"> + Trier par + <%= link_to_order "Code", "code" %> | + <%= link_to_order "Priorité", "priority" %> | + <%= link_to_order "Nom", "name" %> +</div> + +<%= title_tag Chouette::Line.model_name.human.pluralize %> + +<%= render :partial => "line", :collection => @lines %> + +<% content_for :sidebar do %> +<ul class="actions"> + <li><%= link_to t('lines.actions.new'), new_referential_line_path(@referential), :class => "add" %></li> + <br> +</ul> +<% end %> diff --git a/app/views/networks/new.html.erb b/app/views/networks/new.html.erb new file mode 100644 index 000000000..749beb197 --- /dev/null +++ b/app/views/networks/new.html.erb @@ -0,0 +1,3 @@ +<%= title_tag t('networks.new.title') %> + +<%= render "form" %> diff --git a/app/views/networks/new.html.erb~ b/app/views/networks/new.html.erb~ new file mode 100644 index 000000000..d580a2aae --- /dev/null +++ b/app/views/networks/new.html.erb~ @@ -0,0 +1,3 @@ +<%= title_tag "Créer la Ligne" %> + +<%= render "form" %> diff --git a/app/views/networks/show.html.erb b/app/views/networks/show.html.erb new file mode 100644 index 000000000..478d2f8aa --- /dev/null +++ b/app/views/networks/show.html.erb @@ -0,0 +1,47 @@ +<%= title_tag t('networks.show.title'), @line.name %> + +<div class="line_show"> + + <div class="summary"> + <p> + <label><%= Chouette::Line.human_attribute_name(:network) %>: </label> + <%= @line.network.name if @line.network.present? %> + </p> + <p> + <label><%= Chouette::Line.human_attribute_name("company") %>: </label> + <%= @line.company.name if @line.company.present? %> + </p> + <p> + <label><%= Chouette::Line.human_attribute_name("registrationnumber") %>: </label> + <%= @line.registrationnumber %> + </p> + <p> + <label><%= Chouette::Line.human_attribute_name("name") %>: </label> + <%= @line.name %> + </p> + <p> + <label><%= Chouette::Line.human_attribute_name("publishedname") %>: </label> + <%= @line.publishedname %> + </p> + <p> + <label><%= Chouette::Line.human_attribute_name("number") %>: </label> + <%= @line.number %> + </p> + <p> + <label><%= Chouette::Line.human_attribute_name("transportmodename") %>: </label> + <%= @line.transportmodename %> + </p> + <p> + <label><%= Chouette::Line.human_attribute_name("comment") %>: </label> + <%= @line.comment %> + </p> + </div> +</div> + +<% content_for :sidebar do %> +<ul class="actions"> + <li><%= link_to t('lines.actions.edit'), edit_referential_line_path(@referential, @line), :class => "edit" %></li> + <li><%= link_to t('lines.actions.destroy'), referential_line_path(@referential, @line), :method => :delete, :confirm => t('lines.actions.destroy_confirm'), :class => "remove" %></li> + <br> +</ul> +<% end %> diff --git a/app/views/networks/show.html.erb~ b/app/views/networks/show.html.erb~ new file mode 100644 index 000000000..f0d987d3f --- /dev/null +++ b/app/views/networks/show.html.erb~ @@ -0,0 +1,47 @@ +<%= title_tag @line.name %> + +<div class="line_show"> + + <div class="summary"> + <p> + <label><%= Chouette::Line.human_attribute_name(:network) %>: </label> + <%= @line.network.name if @line.network.present? %> + </p> + <p> + <label><%= Chouette::Line.human_attribute_name("company") %>: </label> + <%= @line.company.name if @line.company.present? %> + </p> + <p> + <label><%= Chouette::Line.human_attribute_name("registrationnumber") %>: </label> + <%= @line.registrationnumber %> + </p> + <p> + <label><%= Chouette::Line.human_attribute_name("name") %>: </label> + <%= @line.name %> + </p> + <p> + <label><%= Chouette::Line.human_attribute_name("publishedname") %>: </label> + <%= @line.publishedname %> + </p> + <p> + <label><%= Chouette::Line.human_attribute_name("number") %>: </label> + <%= @line.number %> + </p> + <p> + <label><%= Chouette::Line.human_attribute_name("transportmodename") %>: </label> + <%= @line.transportmodename %> + </p> + <p> + <label><%= Chouette::Line.human_attribute_name("comment") %>: </label> + <%= @line.comment %> + </p> + </div> +</div> + +<% content_for :sidebar do %> +<ul class="actions"> + <li><%= link_to t('lines.actions.edit'), edit_referential_line_path(@referential, @line), :class => "edit" %></li> + <li><%= link_to t('lines.actions.destroy'), referential_line_path(@referential, @line), :method => :delete, :confirm => t('lines.actions.destroy_confirm'), :class => "remove" %></li> + <br> +</ul> +<% end %> diff --git a/config/database.yml b/config/database.yml index 317b1c4a9..c3bfe0abf 100644 --- a/config/database.yml +++ b/config/database.yml @@ -6,19 +6,21 @@ # development: adapter: jdbcpostgresql - database: chouette - schema_search_path: avignon - hostname: localhost - username: luc - password: monalisa + database: chouette_dev + username: chouette + password: chouette # Warning: The database defined as "test" will be erased and # re-generated from your development database when you run "rake". # Do not set this db to the same as development or production. test: adapter: jdbcpostgresql - database: db/test.sqlite3 + database: chouette_test + username: chouette + password: chouette production: adapter: jdbcpostgresql - database: db/production.sqlite3 + database: chouette_prod + username: chouette + password: chouette diff --git a/config/locales/networks.yml b/config/locales/networks.yml new file mode 100644 index 000000000..8878bc4c2 --- /dev/null +++ b/config/locales/networks.yml @@ -0,0 +1,43 @@ +en: + networks: + actions: + new: Add a new network + edit: Edit this network + destroy: Remove this network + destroy_confirm: "Are you sure you want destroy this network?" + new: + title: "Add a new network" + edit: + title: "Update network" + show: + title: "Network" + index: + title: "Networks" + +fr: + networks: + actions: + new: Ajouter un réseau + edit: Modifier ce réseau + destroy: Supprimer ce réseau + destroy_confirm: "Etes vous sûr de détruire cette réseau ?" + new: + title: "Ajouter un réseau" + edit: + title: "Modifier le réseau" + show: + title: "Réseau" + index: + title: "Réseaux" + activerecord: + models: + network: Réseaux + attributes: + network: + registrationnumber: "Identifiant" + name: "Nom" + comment: "Commentaire" + version_date: Date de version + description: Description + source_name: Nom de la source + source_identifier: Identifiant de la source diff --git a/config/routes.rb b/config/routes.rb index 81dd47560..26a425ae6 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -12,8 +12,9 @@ ChouetteIhm::Application.routes.draw do # Sample resource route (maps HTTP verbs to controller actions automatically): # resources :products - resources :lines - resources :referentials + resources :referentials do + resources :lines, :networks, :companies + end # Sample resource route with options: # resources :products do @@ -50,7 +51,7 @@ ChouetteIhm::Application.routes.draw do # You can have the root of your site routed with "root" # just remember to delete public/index.html. - root :to => 'lines#index' + root :to => 'referentials#index' # See how all your routes lay out with "rake routes" diff --git a/db/migrate/20120214101458_create_chouette_company.rb b/db/migrate/20120214101458_create_chouette_company.rb new file mode 100644 index 000000000..5a15a26e6 --- /dev/null +++ b/db/migrate/20120214101458_create_chouette_company.rb @@ -0,0 +1,25 @@ +class CreateChouetteCompany < ActiveRecord::Migration + def up + create_table "company", :force => true do |t| + t.string "objectid" + t.integer "objectversion" + t.datetime "creationtime" + t.string "creatorid" + t.string "name" + t.string "shortname" + t.string "organizationalunit" + t.string "operatingdepartmentname" + t.string "code" + t.string "phone" + t.string "fax" + t.string "email" + t.string "registrationnumber" + end + + add_index "company", ["objectid"], :name => "company_objectid_key", :unique => true + add_index "company", ["registrationnumber"], :name => "company_registrationnumber_key", :unique => true + end + + def down + end +end diff --git a/db/migrate/20120214101645_create_chouette_ptnetwork.rb b/db/migrate/20120214101645_create_chouette_ptnetwork.rb new file mode 100644 index 000000000..13f294345 --- /dev/null +++ b/db/migrate/20120214101645_create_chouette_ptnetwork.rb @@ -0,0 +1,23 @@ +class CreateChouettePtnetwork < ActiveRecord::Migration + def up + create_table "ptnetwork", :force => true do |t| + t.string "objectid" + t.integer "objectversion" + t.datetime "creationtime" + t.string "creatorid" + t.date "versiondate" + t.string "description" + t.string "name" + t.string "registrationnumber" + t.string "sourcename" + t.string "sourceidentifier" + t.string "comment" + end + + add_index "ptnetwork", ["objectid"], :name => "ptnetwork_objectid_key", :unique => true + add_index "ptnetwork", ["registrationnumber"], :name => "ptnetwork_registrationnumber_key", :unique => true + end + + def down + end +end diff --git a/db/schema.rb b/db/schema.rb index 2740b6590..4b3e892f5 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,63 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20120126110946) do +ActiveRecord::Schema.define(:version => 20120214101645) do + + create_table "company", :force => true do |t| + t.string "objectid" + t.integer "objectversion" + t.datetime "creationtime" + t.string "creatorid" + t.string "name" + t.string "shortname" + t.string "organizationalunit" + t.string "operatingdepartmentname" + t.string "code" + t.string "phone" + t.string "fax" + t.string "email" + t.string "registrationnumber" + end + + add_index "company", ["objectid"], :name => "company_objectid_key", :unique => true + add_index "company", ["registrationnumber"], :name => "company_registrationnumber_key", :unique => true + + create_table "line", :force => true do |t| + t.integer "ptnetworkid", :limit => 8 + t.integer "companyid", :limit => 8 + t.string "objectid" + t.integer "objectversion" + t.datetime "creationtime" + t.string "creatorid" + t.string "name" + t.string "number" + t.string "publishedname" + t.string "transportmodename" + t.string "registrationnumber" + t.string "comment" + t.boolean "mobilityrestrictedsuitable" + t.integer "userneeds", :limit => 8 + end + + add_index "line", ["objectid"], :name => "line_objectid_key", :unique => true + add_index "line", ["registrationnumber"], :name => "line_registrationnumber_key", :unique => true + + create_table "ptnetwork", :force => true do |t| + t.string "objectid" + t.integer "objectversion" + t.datetime "creationtime" + t.string "creatorid" + t.date "versiondate" + t.string "description" + t.string "name" + t.string "registrationnumber" + t.string "sourcename" + t.string "sourceidentifier" + t.string "comment" + end + + add_index "ptnetwork", ["objectid"], :name => "ptnetwork_objectid_key", :unique => true + add_index "ptnetwork", ["registrationnumber"], :name => "ptnetwork_registrationnumber_key", :unique => true create_table "referentials", :force => true do |t| t.string "name" diff --git a/spec/factories/chouette_companies.rb b/spec/factories/chouette_companies.rb new file mode 100644 index 000000000..db6ed2b1e --- /dev/null +++ b/spec/factories/chouette_companies.rb @@ -0,0 +1,3 @@ +Factory.define :company, :class => "Chouette::Company" do |f| + f.sequence(:name) { |n| "Company #{n}" } +end diff --git a/spec/factories/chouette_networks.rb b/spec/factories/chouette_networks.rb new file mode 100644 index 000000000..343070868 --- /dev/null +++ b/spec/factories/chouette_networks.rb @@ -0,0 +1,3 @@ +Factory.define :network, :class => "Chouette::Network" do |f| + f.sequence(:name) { |n| "Network #{n}" } +end diff --git a/spec/views/companies/edit.html.erb_spec.rb b/spec/views/companies/edit.html.erb_spec.rb new file mode 100644 index 000000000..98216eb52 --- /dev/null +++ b/spec/views/companies/edit.html.erb_spec.rb @@ -0,0 +1,35 @@ +require 'spec_helper' + +describe "/lines/edit" do + let!(:referential) { assign(:referential, Factory(:referential)) } + let!(:network) { Factory(:network) } + let!(:company) { Factory(:company) } + let!(:line) { assign(:line, Factory(:line, :network => network, :company => company)) } + let!(:lines) { Array.new(2) { Factory(:line, :network => network, :company => company) } } + + describe "test" do + it "should render h2 with the group name" do + render + rendered.should have_selector("h2", :text => Regexp.new(line.name)) + end + end + + describe "form" do + it "should render input for name" do + render + rendered.should have_selector("form") do + with_tag "input[type=text][name='line[name]'][value=?]", line.name + end + end + + it "should render a checkbox for each line" do + render + lines.each do |line| + rendered.should have_selector("form") do + with_tag "input[type='checkbox'][value=?]", line.id + end + end + + end + end +end diff --git a/spec/views/companies/index.html.erb_spec.rb b/spec/views/companies/index.html.erb_spec.rb new file mode 100644 index 000000000..a290080eb --- /dev/null +++ b/spec/views/companies/index.html.erb_spec.rb @@ -0,0 +1,27 @@ +require 'spec_helper' + +describe "/lines/index" do + + let!(:referential) { assign( :referential, Factory(:referential) ) } + let!(:network) { Factory(:network) } + let!(:company) { Factory(:company) } + let!(:lines) { assign( :lines, Array.new(2) { Factory(:line, :network => network, :company => company) } ) } + + before :each do + rendered.stub(:collection).and_return( lines.order_by [[:number, :asc]] ) + view.stub(:link_to_order).and_return( "#" ) + end + + it "should render a show link for each group" do + render + lines.each do |line| + rendered.should have_selector(".line a[href='#{view.referential_line_path(referential, line)}']", :text => line.name) + end + end + + it "should render a link to create a new group" do + render + view.content_for(:sidebar).should have_selector(".actions a[href='#{new_referential_line_path(referential)}']") + end + +end diff --git a/spec/views/companies/new.html.erb_spec.rb b/spec/views/companies/new.html.erb_spec.rb new file mode 100644 index 000000000..48f36a036 --- /dev/null +++ b/spec/views/companies/new.html.erb_spec.rb @@ -0,0 +1,19 @@ +require 'spec_helper' + +describe "/lines/new" do + let!(:referential) { assign(:referential, Factory(:referential)) } + let!(:network) { Factory(:network) } + let!(:company) { Factory(:company) } + let!(:line) { assign(:line, Factory.build(:line, :network => network, :company => company )) } + + describe "form" do + + it "should render input for name" do + render + rendered.should have_selector("form") do + with_selector "input[type=text][name=?]", line.name + end + end + + end +end diff --git a/spec/views/companies/show.html.erb_spec.rb b/spec/views/companies/show.html.erb_spec.rb new file mode 100644 index 000000000..9d5b53cd3 --- /dev/null +++ b/spec/views/companies/show.html.erb_spec.rb @@ -0,0 +1,29 @@ +require 'spec_helper' + +describe "/lines/show" do + + let!(:referential) { assign(:referential, Factory(:referential)) } + let!(:line) { assign(:line, Factory(:line)) } + + it "should render h2 with the line name" do + render + rendered.should have_selector("h2", :text => Regexp.new(line.name)) + end + + # it "should display a map with class 'line'" do + # render + # rendered.should have_selector("#map", :class => 'line') + # end + + it "should render a link to edit the line" do + render + view.content_for(:sidebar).should have_selector(".actions a[href='#{view.edit_referential_line_path(referential, line)}']") + end + + it "should render a link to remove the line" do + render + view.content_for(:sidebar).should have_selector(".actions a[href='#{view.referential_line_path(referential, line)}'][class='remove']") + end + +end + diff --git a/spec/views/networks/edit.html.erb_spec.rb b/spec/views/networks/edit.html.erb_spec.rb new file mode 100644 index 000000000..a64fc6860 --- /dev/null +++ b/spec/views/networks/edit.html.erb_spec.rb @@ -0,0 +1,33 @@ +require 'spec_helper' + +describe "/networks/edit" do + let!(:referential) { assign(:referential, Factory(:referential)) } + let!(:network) { assign(:network, Factory(:network) ) } + let!(:networks) { Array.new(2) { Factory(:network) } } + + describe "test" do + it "should render h2 with the group name" do + render + rendered.should have_selector("h2", :text => Regexp.new(network.name)) + end + end + + describe "form" do + it "should render input for name" do + render + rendered.should have_selector("form") do + with_tag "input[type=text][name='network[name]'][value=?]", network.name + end + end + + it "should render a checkbox for each network" do + render + networks.each do |network| + rendered.should have_selector("form") do + with_tag "input[type='checkbox'][value=?]", network.id + end + end + + end + end +end diff --git a/spec/views/networks/index.html.erb_spec.rb b/spec/views/networks/index.html.erb_spec.rb new file mode 100644 index 000000000..2ad218ca6 --- /dev/null +++ b/spec/views/networks/index.html.erb_spec.rb @@ -0,0 +1,20 @@ +require 'spec_helper' + +describe "/lines/index" do + + let!(:referential) { assign( :referential, Factory(:referential) ) } + let!(:networks) { assign( :networks, Array.new(2) { Factory(:network) } ) } + + it "should render a show link for each group" do + render + networks.each do |network| + rendered.should have_selector(".network a[href='#{view.referential_network_path(referential, network)}']", :text => network.name) + end + end + + it "should render a link to create a new group" do + render + view.content_for(:sidebar).should have_selector(".actions a[href='#{new_referential_network_path(referential)}']") + end + +end diff --git a/spec/views/networks/new.html.erb_spec.rb b/spec/views/networks/new.html.erb_spec.rb new file mode 100644 index 000000000..48f36a036 --- /dev/null +++ b/spec/views/networks/new.html.erb_spec.rb @@ -0,0 +1,19 @@ +require 'spec_helper' + +describe "/lines/new" do + let!(:referential) { assign(:referential, Factory(:referential)) } + let!(:network) { Factory(:network) } + let!(:company) { Factory(:company) } + let!(:line) { assign(:line, Factory.build(:line, :network => network, :company => company )) } + + describe "form" do + + it "should render input for name" do + render + rendered.should have_selector("form") do + with_selector "input[type=text][name=?]", line.name + end + end + + end +end diff --git a/spec/views/networks/show.html.erb_spec.rb b/spec/views/networks/show.html.erb_spec.rb new file mode 100644 index 000000000..9d5b53cd3 --- /dev/null +++ b/spec/views/networks/show.html.erb_spec.rb @@ -0,0 +1,29 @@ +require 'spec_helper' + +describe "/lines/show" do + + let!(:referential) { assign(:referential, Factory(:referential)) } + let!(:line) { assign(:line, Factory(:line)) } + + it "should render h2 with the line name" do + render + rendered.should have_selector("h2", :text => Regexp.new(line.name)) + end + + # it "should display a map with class 'line'" do + # render + # rendered.should have_selector("#map", :class => 'line') + # end + + it "should render a link to edit the line" do + render + view.content_for(:sidebar).should have_selector(".actions a[href='#{view.edit_referential_line_path(referential, line)}']") + end + + it "should render a link to remove the line" do + render + view.content_for(:sidebar).should have_selector(".actions a[href='#{view.referential_line_path(referential, line)}'][class='remove']") + end + +end + |
