diff --git a/app/assets/javascripts/cities.js.coffee b/app/assets/javascripts/cities.js.coffee new file mode 100644 index 00000000..24f83d18 --- /dev/null +++ b/app/assets/javascripts/cities.js.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/regions.js.coffee b/app/assets/javascripts/regions.js.coffee new file mode 100644 index 00000000..24f83d18 --- /dev/null +++ b/app/assets/javascripts/regions.js.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/stylesheets/cities.css.sass b/app/assets/stylesheets/cities.css.sass new file mode 100644 index 00000000..e2622520 --- /dev/null +++ b/app/assets/stylesheets/cities.css.sass @@ -0,0 +1,3 @@ +// Place all the styles related to the cities controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/regions.css.sass b/app/assets/stylesheets/regions.css.sass new file mode 100644 index 00000000..9dd55106 --- /dev/null +++ b/app/assets/stylesheets/regions.css.sass @@ -0,0 +1,3 @@ +// Place all the styles related to the regions controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/scaffolds.css.sass b/app/assets/stylesheets/scaffolds.css.sass new file mode 100644 index 00000000..b35eb619 --- /dev/null +++ b/app/assets/stylesheets/scaffolds.css.sass @@ -0,0 +1,56 @@ +body + background-color: #fff + color: #333 + font-family: verdana, arial, helvetica, sans-serif + font-size: 13px + line-height: 18px + +p, ol, ul, td + font-family: verdana, arial, helvetica, sans-serif + font-size: 13px + line-height: 18px + +pre + background-color: #eee + padding: 10px + font-size: 11px + +a + color: #000 + &:visited + color: #666 + &:hover + color: #fff + background-color: #000 + +div + &.field, &.actions + margin-bottom: 10px + +#notice + color: green + +.field_with_errors + padding: 2px + background-color: red + display: table + +#error_explanation + width: 450px + border: 2px solid red + padding: 7px + padding-bottom: 0 + margin-bottom: 20px + background-color: #f0f0f0 + h2 + text-align: left + font-weight: bold + padding: 5px 5px 5px 15px + font-size: 12px + margin: -7px + margin-bottom: 0px + background-color: #c00 + color: #fff + ul li + font-size: 12px + list-style: square diff --git a/app/controllers/cities_controller.rb b/app/controllers/cities_controller.rb new file mode 100644 index 00000000..761dddbd --- /dev/null +++ b/app/controllers/cities_controller.rb @@ -0,0 +1,2 @@ +class CitiesController < InheritedResources::Base +end diff --git a/app/controllers/regions_controller.rb b/app/controllers/regions_controller.rb new file mode 100644 index 00000000..4837c4f5 --- /dev/null +++ b/app/controllers/regions_controller.rb @@ -0,0 +1,2 @@ +class RegionsController < InheritedResources::Base +end diff --git a/app/helpers/cities_helper.rb b/app/helpers/cities_helper.rb new file mode 100644 index 00000000..dce779d1 --- /dev/null +++ b/app/helpers/cities_helper.rb @@ -0,0 +1,2 @@ +module CitiesHelper +end diff --git a/app/helpers/regions_helper.rb b/app/helpers/regions_helper.rb new file mode 100644 index 00000000..2a11e5df --- /dev/null +++ b/app/helpers/regions_helper.rb @@ -0,0 +1,2 @@ +module RegionsHelper +end diff --git a/app/models/city.rb b/app/models/city.rb new file mode 100644 index 00000000..ceba1d0c --- /dev/null +++ b/app/models/city.rb @@ -0,0 +1,2 @@ +class City < ActiveRecord::Base +end diff --git a/app/models/region.rb b/app/models/region.rb new file mode 100644 index 00000000..2e39f32c --- /dev/null +++ b/app/models/region.rb @@ -0,0 +1,2 @@ +class Region < ActiveRecord::Base +end diff --git a/app/views/cities/_form.html.haml b/app/views/cities/_form.html.haml new file mode 100644 index 00000000..0f0f2bdf --- /dev/null +++ b/app/views/cities/_form.html.haml @@ -0,0 +1,31 @@ += form_for @city do |f| + - if @city.errors.any? + #error_explanation + %h2= "#{pluralize(@city.errors.count, "error")} prohibited this city from being saved:" + %ul + - @city.errors.full_messages.each do |msg| + %li= msg + + .field + = f.label :name + = f.text_field :name + .field + = f.label :majname + = f.text_field :majname + .field + = f.label :postalcode + = f.number_field :postalcode + .field + = f.label :inseecode + = f.number_field :inseecode + .field + = f.label :regioncode + = f.number_field :regioncode + .field + = f.label :latitude + = f.text_field :latitude + .field + = f.label :longitude + = f.text_field :longitude + .actions + = f.submit 'Save' diff --git a/app/views/cities/edit.html.haml b/app/views/cities/edit.html.haml new file mode 100644 index 00000000..6d24cb39 --- /dev/null +++ b/app/views/cities/edit.html.haml @@ -0,0 +1,7 @@ +%h1 Editing city + += render 'form' + += link_to 'Show', @city +\| += link_to 'Back', cities_path diff --git a/app/views/cities/index.html.haml b/app/views/cities/index.html.haml new file mode 100644 index 00000000..0186cf8d --- /dev/null +++ b/app/views/cities/index.html.haml @@ -0,0 +1,31 @@ +%h1 Listing cities + +%table + %tr + %th Name + %th Majname + %th Postalcode + %th Inseecode + %th Regioncode + %th Latitude + %th Longitude + %th + %th + %th + + - @cities.each do |city| + %tr + %td= city.name + %td= city.majname + %td= city.postalcode + %td= city.inseecode + %td= city.regioncode + %td= city.latitude + %td= city.longitude + %td= link_to 'Show', city + %td= link_to 'Edit', edit_city_path(city) + %td= link_to 'Destroy', city, :method => :delete, :data => { :confirm => 'Are you sure?' } + +%br + += link_to 'New City', new_city_path diff --git a/app/views/cities/index.json.jbuilder b/app/views/cities/index.json.jbuilder new file mode 100644 index 00000000..7788f181 --- /dev/null +++ b/app/views/cities/index.json.jbuilder @@ -0,0 +1,4 @@ +json.array!(@cities) do |city| + json.extract! city, :name, :majname, :postalcode, :inseecode, :regioncode, :latitude, :longitude + json.url city_url(city, format: :json) +end diff --git a/app/views/cities/new.html.haml b/app/views/cities/new.html.haml new file mode 100644 index 00000000..43666166 --- /dev/null +++ b/app/views/cities/new.html.haml @@ -0,0 +1,5 @@ +%h1 New city + += render 'form' + += link_to 'Back', cities_path diff --git a/app/views/cities/show.html.haml b/app/views/cities/show.html.haml new file mode 100644 index 00000000..ff16d03b --- /dev/null +++ b/app/views/cities/show.html.haml @@ -0,0 +1,27 @@ +%p#notice= notice + +%p + %b Name: + = @city.name +%p + %b Majname: + = @city.majname +%p + %b Postalcode: + = @city.postalcode +%p + %b Inseecode: + = @city.inseecode +%p + %b Regioncode: + = @city.regioncode +%p + %b Latitude: + = @city.latitude +%p + %b Longitude: + = @city.longitude + += link_to 'Edit', edit_city_path(@city) +\| += link_to 'Back', cities_path diff --git a/app/views/cities/show.json.jbuilder b/app/views/cities/show.json.jbuilder new file mode 100644 index 00000000..0e2fcaf8 --- /dev/null +++ b/app/views/cities/show.json.jbuilder @@ -0,0 +1 @@ +json.extract! @city, :name, :majname, :postalcode, :inseecode, :regioncode, :latitude, :longitude, :created_at, :updated_at diff --git a/app/views/regions/_form.html.haml b/app/views/regions/_form.html.haml new file mode 100644 index 00000000..660255cd --- /dev/null +++ b/app/views/regions/_form.html.haml @@ -0,0 +1,13 @@ += form_for @region do |f| + - if @region.errors.any? + #error_explanation + %h2= "#{pluralize(@region.errors.count, "error")} prohibited this region from being saved:" + %ul + - @region.errors.full_messages.each do |msg| + %li= msg + + .field + = f.label :name + = f.text_field :name + .actions + = f.submit 'Save' diff --git a/app/views/regions/edit.html.haml b/app/views/regions/edit.html.haml new file mode 100644 index 00000000..9e038958 --- /dev/null +++ b/app/views/regions/edit.html.haml @@ -0,0 +1,7 @@ +%h1 Editing region + += render 'form' + += link_to 'Show', @region +\| += link_to 'Back', regions_path diff --git a/app/views/regions/index.html.haml b/app/views/regions/index.html.haml new file mode 100644 index 00000000..3be6fcd7 --- /dev/null +++ b/app/views/regions/index.html.haml @@ -0,0 +1,19 @@ +%h1 Listing regions + +%table + %tr + %th Name + %th + %th + %th + + - @regions.each do |region| + %tr + %td= region.name + %td= link_to 'Show', region + %td= link_to 'Edit', edit_region_path(region) + %td= link_to 'Destroy', region, :method => :delete, :data => { :confirm => 'Are you sure?' } + +%br + += link_to 'New Region', new_region_path diff --git a/app/views/regions/index.json.jbuilder b/app/views/regions/index.json.jbuilder new file mode 100644 index 00000000..7ca68886 --- /dev/null +++ b/app/views/regions/index.json.jbuilder @@ -0,0 +1,4 @@ +json.array!(@regions) do |region| + json.extract! region, :name + json.url region_url(region, format: :json) +end diff --git a/app/views/regions/new.html.haml b/app/views/regions/new.html.haml new file mode 100644 index 00000000..42ce0d5e --- /dev/null +++ b/app/views/regions/new.html.haml @@ -0,0 +1,5 @@ +%h1 New region + += render 'form' + += link_to 'Back', regions_path diff --git a/app/views/regions/show.html.haml b/app/views/regions/show.html.haml new file mode 100644 index 00000000..2d9cc32c --- /dev/null +++ b/app/views/regions/show.html.haml @@ -0,0 +1,9 @@ +%p#notice= notice + +%p + %b Name: + = @region.name + += link_to 'Edit', edit_region_path(@region) +\| += link_to 'Back', regions_path diff --git a/app/views/regions/show.json.jbuilder b/app/views/regions/show.json.jbuilder new file mode 100644 index 00000000..a1469641 --- /dev/null +++ b/app/views/regions/show.json.jbuilder @@ -0,0 +1 @@ +json.extract! @region, :name, :created_at, :updated_at diff --git a/config/initializers/active_admin.rb b/config/initializers/active_admin.rb index c0f1507a..b34977d1 100644 --- a/config/initializers/active_admin.rb +++ b/config/initializers/active_admin.rb @@ -5,7 +5,7 @@ ActiveAdmin.setup do |config| # Set the title that is displayed on the main layout # for each of the active admin pages. # - config.site_title = "Agenda Du Libre Rails" + config.site_title = "Agenda Du Libre" # Set the link url for the title. For example, to take # users to your main site. Defaults to no link. diff --git a/config/routes.rb b/config/routes.rb index 93dfd819..7ecf82ef 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,7 +1,10 @@ AgendaDuLibreRails::Application.routes.draw do + resources :cities + resources :regions + resources :users + devise_for :admin_users, ActiveAdmin::Devise.config ActiveAdmin.routes(self) - resources :users root to: 'users#index' diff --git a/test/controllers/cities_controller_test.rb b/test/controllers/cities_controller_test.rb new file mode 100644 index 00000000..a5c7eff5 --- /dev/null +++ b/test/controllers/cities_controller_test.rb @@ -0,0 +1,49 @@ +require 'test_helper' + +class CitiesControllerTest < ActionController::TestCase + setup do + @city = cities(:one) + end + + test "should get index" do + get :index + assert_response :success + assert_not_nil assigns(:cities) + end + + test "should get new" do + get :new + assert_response :success + end + + test "should create city" do + assert_difference('City.count') do + post :create, city: { inseecode: @city.inseecode, latitude: @city.latitude, longitude: @city.longitude, majname: @city.majname, name: @city.name, postalcode: @city.postalcode, regioncode: @city.regioncode } + end + + assert_redirected_to city_path(assigns(:city)) + end + + test "should show city" do + get :show, id: @city + assert_response :success + end + + test "should get edit" do + get :edit, id: @city + assert_response :success + end + + test "should update city" do + patch :update, id: @city, city: { inseecode: @city.inseecode, latitude: @city.latitude, longitude: @city.longitude, majname: @city.majname, name: @city.name, postalcode: @city.postalcode, regioncode: @city.regioncode } + assert_redirected_to city_path(assigns(:city)) + end + + test "should destroy city" do + assert_difference('City.count', -1) do + delete :destroy, id: @city + end + + assert_redirected_to cities_path + end +end diff --git a/test/controllers/regions_controller_test.rb b/test/controllers/regions_controller_test.rb new file mode 100644 index 00000000..18ca106a --- /dev/null +++ b/test/controllers/regions_controller_test.rb @@ -0,0 +1,49 @@ +require 'test_helper' + +class RegionsControllerTest < ActionController::TestCase + setup do + @region = regions(:one) + end + + test "should get index" do + get :index + assert_response :success + assert_not_nil assigns(:regions) + end + + test "should get new" do + get :new + assert_response :success + end + + test "should create region" do + assert_difference('Region.count') do + post :create, region: { name: @region.name } + end + + assert_redirected_to region_path(assigns(:region)) + end + + test "should show region" do + get :show, id: @region + assert_response :success + end + + test "should get edit" do + get :edit, id: @region + assert_response :success + end + + test "should update region" do + patch :update, id: @region, region: { name: @region.name } + assert_redirected_to region_path(assigns(:region)) + end + + test "should destroy region" do + assert_difference('Region.count', -1) do + delete :destroy, id: @region + end + + assert_redirected_to regions_path + end +end diff --git a/test/fixtures/cities.yml b/test/fixtures/cities.yml new file mode 100644 index 00000000..d83063e4 --- /dev/null +++ b/test/fixtures/cities.yml @@ -0,0 +1,19 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + name: MyString + majname: MyString + postalcode: 1 + inseecode: 1 + regioncode: 1 + latitude: 1.5 + longitude: 1.5 + +two: + name: MyString + majname: MyString + postalcode: 1 + inseecode: 1 + regioncode: 1 + latitude: 1.5 + longitude: 1.5 diff --git a/test/fixtures/regions.yml b/test/fixtures/regions.yml new file mode 100644 index 00000000..56066c68 --- /dev/null +++ b/test/fixtures/regions.yml @@ -0,0 +1,7 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + name: MyString + +two: + name: MyString diff --git a/test/helpers/cities_helper_test.rb b/test/helpers/cities_helper_test.rb new file mode 100644 index 00000000..25e00fe0 --- /dev/null +++ b/test/helpers/cities_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class CitiesHelperTest < ActionView::TestCase +end diff --git a/test/helpers/regions_helper_test.rb b/test/helpers/regions_helper_test.rb new file mode 100644 index 00000000..bf822905 --- /dev/null +++ b/test/helpers/regions_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class RegionsHelperTest < ActionView::TestCase +end diff --git a/test/models/city_test.rb b/test/models/city_test.rb new file mode 100644 index 00000000..660f995b --- /dev/null +++ b/test/models/city_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class CityTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/models/region_test.rb b/test/models/region_test.rb new file mode 100644 index 00000000..4fe24098 --- /dev/null +++ b/test/models/region_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class RegionTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end