\ No newline at end of file
diff --git a/config/application.rb b/config/application.rb
index 07b94ace7..8c7e93062 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -11,6 +11,11 @@ end
module ChouetteIhm
class Application < Rails::Application
+
+ config.generators do |g|
+ g.test_framework :rspec
+ end
+
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
diff --git a/config/initializers/apartment.rb b/config/initializers/apartment.rb
new file mode 100644
index 000000000..d51724a04
--- /dev/null
+++ b/config/initializers/apartment.rb
@@ -0,0 +1,4 @@
+Apartment.configure do |config|
+ # set your options (described below) here
+ config.excluded_models = ["Referential"] # these models will not be multi-tenanted, but remain in the global (public) namespace
+end
\ No newline at end of file
diff --git a/config/locales/referentials.yml b/config/locales/referentials.yml
new file mode 100644
index 000000000..624dba689
--- /dev/null
+++ b/config/locales/referentials.yml
@@ -0,0 +1,21 @@
+fr:
+ referentials:
+ edit:
+ title: "Modifier le référentiel"
+ show:
+ title: Référentiel
+ new:
+ title: Créer une nouveau référentiel
+ submit: "Créer un référentiel"
+ actions:
+ new: Ajouter une référentiel
+ destroy_confirm: "Etes vous sûr de vouloir supprimer le référentiel ?"
+ destroy: Supprimer
+ edit: Modifier
+ activerecord:
+ models:
+ referential: Référentiel
+ attributes:
+ referential:
+ name: Nom
+ slug: Code
diff --git a/config/routes.rb b/config/routes.rb
index 53fcaae98..81dd47560 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -13,6 +13,7 @@ ChouetteIhm::Application.routes.draw do
# Sample resource route (maps HTTP verbs to controller actions automatically):
# resources :products
resources :lines
+ resources :referentials
# Sample resource route with options:
# resources :products do
@@ -49,7 +50,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 => 'welcome#index'
+ root :to => 'lines#index'
# See how all your routes lay out with "rake routes"
diff --git a/db/migrate/20120126110946_create_referentials.rb b/db/migrate/20120126110946_create_referentials.rb
new file mode 100644
index 000000000..64af40135
--- /dev/null
+++ b/db/migrate/20120126110946_create_referentials.rb
@@ -0,0 +1,10 @@
+class CreateReferentials < ActiveRecord::Migration
+ def change
+ create_table :referentials do |t|
+ t.string :name
+ t.string :slug
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
new file mode 100644
index 000000000..2740b6590
--- /dev/null
+++ b/db/schema.rb
@@ -0,0 +1,22 @@
+# This file is auto-generated from the current state of the database. Instead
+# of editing this file, please use the migrations feature of Active Record to
+# incrementally modify your database, and then regenerate this schema definition.
+#
+# Note that this schema.rb definition is the authoritative source for your
+# database schema. If you need to create the application database on another
+# system, you should be using db:schema:load, not running all the migrations
+# from scratch. The latter is a flawed and unsustainable approach (the more migrations
+# you'll amass, the slower it'll run and the greater likelihood for issues).
+#
+# It's strongly recommended to check this file into your version control system.
+
+ActiveRecord::Schema.define(:version => 20120126110946) do
+
+ create_table "referentials", :force => true do |t|
+ t.string "name"
+ t.string "slug"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+end
diff --git a/spec/controllers/referentials_controller_spec.rb b/spec/controllers/referentials_controller_spec.rb
new file mode 100644
index 000000000..eba195a1f
--- /dev/null
+++ b/spec/controllers/referentials_controller_spec.rb
@@ -0,0 +1,5 @@
+require 'spec_helper'
+
+describe ReferentialsController do
+
+end
diff --git a/spec/factories/chouette_lines.rb b/spec/factories/chouette_lines.rb
new file mode 100644
index 000000000..913b88538
--- /dev/null
+++ b/spec/factories/chouette_lines.rb
@@ -0,0 +1,4 @@
+Factory.define :chouette_line, :class => "Chouette::Line" do |f|
+ f.sequence(:name) { |n| "Line #{n}" }
+ f.objectid
+end
\ No newline at end of file
diff --git a/spec/factories/chouette_stop_areas.rb b/spec/factories/chouette_stop_areas.rb
new file mode 100644
index 000000000..315b84679
--- /dev/null
+++ b/spec/factories/chouette_stop_areas.rb
@@ -0,0 +1,7 @@
+Factory.define :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
\ No newline at end of file
diff --git a/spec/factories/referential.rb b/spec/factories/referential.rb
new file mode 100644
index 000000000..4bdacb8c7
--- /dev/null
+++ b/spec/factories/referential.rb
@@ -0,0 +1,4 @@
+Factory.define :referential, :class => "Referential" do |f|
+ f.sequence(:name) { |n| "Referential #{n}" }
+ f.sequence(:slug) { |n| "referential_#{n}" }
+end
\ No newline at end of file
diff --git a/spec/helpers/referentials_helper_spec.rb b/spec/helpers/referentials_helper_spec.rb
new file mode 100644
index 000000000..883116983
--- /dev/null
+++ b/spec/helpers/referentials_helper_spec.rb
@@ -0,0 +1,15 @@
+require 'spec_helper'
+
+# Specs in this file have access to a helper object that includes
+# the ReferentialsHelper. For example:
+#
+# describe ReferentialsHelper do
+# describe "string concat" do
+# it "concats two strings with spaces" do
+# helper.concat_strings("this","that").should == "this that"
+# end
+# end
+# end
+describe ReferentialsHelper do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
diff --git a/spec/models/referential_spec.rb b/spec/models/referential_spec.rb
new file mode 100644
index 000000000..363fe237f
--- /dev/null
+++ b/spec/models/referential_spec.rb
@@ -0,0 +1,8 @@
+require 'spec_helper'
+
+describe Referential do
+
+ it { should validate_presence_of(:name) }
+ it { should validate_presence_of(:slug) }
+
+end
\ No newline at end of file
diff --git a/spec/requests/referentials_spec.rb b/spec/requests/referentials_spec.rb
new file mode 100644
index 000000000..1fcd4f8a3
--- /dev/null
+++ b/spec/requests/referentials_spec.rb
@@ -0,0 +1,14 @@
+require 'spec_helper'
+
+describe "Referentials" do
+
+ # describe "create" do
+ # get new_referential_path
+ # fill_in "Nom", :with => "Test"
+ # fill_in "Slug", :with => "test"
+ # click_button "Créer"
+
+ # Referential.where(:name => "Test").should_not be_nil
+ # end
+
+end
\ No newline at end of file
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
new file mode 100644
index 000000000..e66d9802c
--- /dev/null
+++ b/spec/spec_helper.rb
@@ -0,0 +1,32 @@
+# This file is copied to spec/ when you run 'rails generate rspec:install'
+ENV["RAILS_ENV"] ||= 'test'
+require File.expand_path("../../config/environment", __FILE__)
+require 'rspec/rails'
+require 'rspec/autorun'
+
+# Requires supporting ruby files with custom matchers and macros, etc,
+# in spec/support/ and its subdirectories.
+Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
+
+RSpec.configure do |config|
+ # ## Mock Framework
+ #
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
+ #
+ # config.mock_with :mocha
+ # config.mock_with :flexmock
+ # config.mock_with :rr
+
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
+
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
+ # examples within a transaction, remove the following line or assign false
+ # instead of true.
+ config.use_transactional_fixtures = true
+
+ # If true, the base class of anonymous controllers will be inferred
+ # automatically. This will be the default behavior in future versions of
+ # rspec-rails.
+ config.infer_base_class_for_anonymous_controllers = false
+end
diff --git a/spec/views/lines/edit.html.erb_spec.rb b/spec/views/lines/edit.html.erb_spec.rb
new file mode 100644
index 000000000..f889410ee
--- /dev/null
+++ b/spec/views/lines/edit.html.erb_spec.rb
@@ -0,0 +1,33 @@
+require 'spec_helper'
+
+describe "/lines/edit" do
+ let!(:network) { assign(:network, Factory(:network)) }
+ let!(:line) { assign(:line, Factory(:line, :network => network)) }
+ let!(:lines) { Array.new(2) { Factory(:line, :network => network) } }
+
+ 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/lines/index.html.erb_spec.rb b/spec/views/lines/index.html.erb_spec.rb
new file mode 100644
index 000000000..dee3565f4
--- /dev/null
+++ b/spec/views/lines/index.html.erb_spec.rb
@@ -0,0 +1,25 @@
+require 'spec_helper'
+
+describe "/lines/index" do
+
+ let!(:network) { assign( :network, Factory(:network) ) }
+ let!(:lines) { assign( :lines, Array.new(2) { Factory(:line, :network => network) } ) }
+
+ before :each do
+ rendered.stub(:collection).and_return( lines.order_by [[:code, :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.line_path(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_network_line_path(network)}']")
+ end
+
+end
diff --git a/spec/views/lines/new.html.erb_spec.rb b/spec/views/lines/new.html.erb_spec.rb
new file mode 100644
index 000000000..b50f73356
--- /dev/null
+++ b/spec/views/lines/new.html.erb_spec.rb
@@ -0,0 +1,17 @@
+require 'spec_helper'
+
+describe "/lines/new" do
+ let!(:network) { assign(:network, Factory(:network)) }
+ let!(:line) { assign(:line, Factory.build(:line, :network => network)) }
+
+ 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/lines/show.html.erb_spec.rb b/spec/views/lines/show.html.erb_spec.rb
new file mode 100644
index 000000000..14f315333
--- /dev/null
+++ b/spec/views/lines/show.html.erb_spec.rb
@@ -0,0 +1,30 @@
+require 'spec_helper'
+
+describe "/lines/show" do
+
+ let!(:network) { assign(:network, Factory(:network)) }
+ let!(:line) { assign(:line, Factory(:line, :network => network)) }
+ let!(:map) { assign(:map, LineMap.new(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_line_path(line)}']")
+ end
+
+ it "should render a link to remove the line" do
+ render
+ view.content_for(:sidebar).should have_selector(".actions a[href='#{view.line_path(line)}'][class='remove']")
+ end
+
+end
+
diff --git a/spec/views/referentials/edit.html.erb_spec.rb b/spec/views/referentials/edit.html.erb_spec.rb
new file mode 100644
index 000000000..3c2fbc5c3
--- /dev/null
+++ b/spec/views/referentials/edit.html.erb_spec.rb
@@ -0,0 +1,5 @@
+require 'spec_helper'
+
+describe "referentials/edit.html.erb" do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
diff --git a/spec/views/referentials/new.html.erb_spec.rb b/spec/views/referentials/new.html.erb_spec.rb
new file mode 100644
index 000000000..dccd990cb
--- /dev/null
+++ b/spec/views/referentials/new.html.erb_spec.rb
@@ -0,0 +1,17 @@
+require 'spec_helper'
+
+describe "referentials/new.html.erb" do
+
+ let!(:referential) { assign(:referential, Referential.new) }
+
+ it "should have a textfield for name" do
+ render
+ rendered.should have_selector("input", :name => "referential[name]")
+ end
+
+ it "should have a textfield for slug" do
+ render
+ rendered.should have_selector("input", :name => "referential[slug]")
+ end
+
+end
diff --git a/spec/views/referentials/show.html.erb_spec.rb b/spec/views/referentials/show.html.erb_spec.rb
new file mode 100644
index 000000000..2f3a64568
--- /dev/null
+++ b/spec/views/referentials/show.html.erb_spec.rb
@@ -0,0 +1,12 @@
+require 'spec_helper'
+
+describe "referentials/show.html.erb" do
+ let!(:referential) { assign(:referential, Factory(:referential)) }
+
+ it "should have a title with name" do
+ render
+ puts render
+ rendered.should have_selector("h2", :text => Regexp.new(referential.name))
+ end
+
+end
diff --git a/test/fixtures/.gitkeep b/test/fixtures/.gitkeep
deleted file mode 100644
index e69de29bb..000000000
diff --git a/test/functional/.gitkeep b/test/functional/.gitkeep
deleted file mode 100644
index e69de29bb..000000000
diff --git a/test/functional/lines_controller_test.rb b/test/functional/lines_controller_test.rb
deleted file mode 100644
index 7e8bfcd51..000000000
--- a/test/functional/lines_controller_test.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-require 'test_helper'
-
-class LinesControllerTest < ActionController::TestCase
- # test "the truth" do
- # assert true
- # end
-end
diff --git a/test/functional/welcome_controller_test.rb b/test/functional/welcome_controller_test.rb
deleted file mode 100644
index fb5085692..000000000
--- a/test/functional/welcome_controller_test.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-require 'test_helper'
-
-class WelcomeControllerTest < ActionController::TestCase
- # test "the truth" do
- # assert true
- # end
-end
diff --git a/test/integration/.gitkeep b/test/integration/.gitkeep
deleted file mode 100644
index e69de29bb..000000000
diff --git a/test/performance/browsing_test.rb b/test/performance/browsing_test.rb
deleted file mode 100644
index 3fea27b91..000000000
--- a/test/performance/browsing_test.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-require 'test_helper'
-require 'rails/performance_test_help'
-
-class BrowsingTest < ActionDispatch::PerformanceTest
- # Refer to the documentation for all available options
- # self.profile_options = { :runs => 5, :metrics => [:wall_time, :memory]
- # :output => 'tmp/performance', :formats => [:flat] }
-
- def test_homepage
- get '/'
- end
-end
diff --git a/test/test_helper.rb b/test/test_helper.rb
deleted file mode 100644
index 8bf1192ff..000000000
--- a/test/test_helper.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-ENV["RAILS_ENV"] = "test"
-require File.expand_path('../../config/environment', __FILE__)
-require 'rails/test_help'
-
-class ActiveSupport::TestCase
- # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
- #
- # Note: You'll currently still have to declare fixtures explicitly in integration tests
- # -- they do not yet inherit this setting
- fixtures :all
-
- # Add more helper methods to be used by all tests here...
-end
diff --git a/test/unit/.gitkeep b/test/unit/.gitkeep
deleted file mode 100644
index e69de29bb..000000000
diff --git a/test/unit/helpers/lines_helper_test.rb b/test/unit/helpers/lines_helper_test.rb
deleted file mode 100644
index f9353c9b7..000000000
--- a/test/unit/helpers/lines_helper_test.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'test_helper'
-
-class LinesHelperTest < ActionView::TestCase
-end
diff --git a/test/unit/helpers/welcome_helper_test.rb b/test/unit/helpers/welcome_helper_test.rb
deleted file mode 100644
index d6ded5995..000000000
--- a/test/unit/helpers/welcome_helper_test.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'test_helper'
-
-class WelcomeHelperTest < ActionView::TestCase
-end
--
cgit v1.2.3