dry_crud 1.7.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/MIT-LICENSE +1 -1
- data/README.rdoc +126 -87
- data/VERSION +1 -1
- data/lib/generators/dry_crud/dry_crud_generator.rb +42 -22
- data/lib/generators/dry_crud/templates/INSTALL +5 -5
- data/lib/generators/dry_crud/templates/app/assets/stylesheets/crud.scss +0 -20
- data/lib/generators/dry_crud/templates/app/assets/stylesheets/sample.scss +24 -4
- data/lib/generators/dry_crud/templates/app/controllers/crud/generic_model.rb +89 -0
- data/lib/generators/dry_crud/templates/app/controllers/crud/nestable.rb +70 -0
- data/lib/generators/dry_crud/templates/app/controllers/crud/rememberable.rb +64 -0
- data/lib/generators/dry_crud/templates/app/controllers/crud/render_callbacks.rb +46 -0
- data/lib/generators/dry_crud/templates/app/controllers/crud/responder.rb +31 -0
- data/lib/generators/dry_crud/templates/app/controllers/crud/searchable.rb +55 -0
- data/lib/generators/dry_crud/templates/app/controllers/crud/sortable.rb +63 -0
- data/lib/generators/dry_crud/templates/app/controllers/crud_controller.rb +66 -69
- data/lib/generators/dry_crud/templates/app/controllers/list_controller.rb +23 -326
- data/lib/generators/dry_crud/templates/app/helpers/actions_helper.rb +64 -0
- data/lib/generators/dry_crud/templates/app/helpers/crud/form_builder.rb +331 -0
- data/lib/generators/dry_crud/templates/app/helpers/crud/table_builder.rb +280 -0
- data/lib/generators/dry_crud/templates/app/helpers/form_helper.rb +52 -0
- data/lib/generators/dry_crud/templates/app/helpers/format_helper.rb +164 -0
- data/lib/generators/dry_crud/templates/app/helpers/i18n_helper.rb +85 -0
- data/lib/generators/dry_crud/templates/app/helpers/table_helper.rb +83 -0
- data/lib/generators/dry_crud/templates/app/helpers/utility_helper.rb +84 -0
- data/lib/generators/dry_crud/templates/app/views/crud/_actions_edit.html.erb +3 -3
- data/lib/generators/dry_crud/templates/app/views/crud/_actions_edit.html.haml +3 -3
- data/lib/generators/dry_crud/templates/app/views/crud/_actions_index.html.erb +1 -1
- data/lib/generators/dry_crud/templates/app/views/crud/_actions_index.html.haml +1 -1
- data/lib/generators/dry_crud/templates/app/views/crud/_actions_show.html.erb +3 -3
- data/lib/generators/dry_crud/templates/app/views/crud/_actions_show.html.haml +3 -3
- data/lib/generators/dry_crud/templates/app/views/crud/_attrs.html.erb +1 -1
- data/lib/generators/dry_crud/templates/app/views/crud/_attrs.html.haml +1 -1
- data/lib/generators/dry_crud/templates/app/views/crud/_form.html.erb +1 -1
- data/lib/generators/dry_crud/templates/app/views/crud/_form.html.haml +1 -1
- data/lib/generators/dry_crud/templates/app/views/crud/edit.html.erb +1 -1
- data/lib/generators/dry_crud/templates/app/views/crud/edit.html.haml +1 -1
- data/lib/generators/dry_crud/templates/app/views/crud/new.html.erb +2 -2
- data/lib/generators/dry_crud/templates/app/views/crud/new.html.haml +2 -2
- data/lib/generators/dry_crud/templates/app/views/crud/show.html.erb +1 -1
- data/lib/generators/dry_crud/templates/app/views/crud/show.html.haml +1 -1
- data/lib/generators/dry_crud/templates/app/views/layouts/_flash.html.haml +1 -1
- data/lib/generators/dry_crud/templates/app/views/layouts/_nav.html.erb +1 -1
- data/lib/generators/dry_crud/templates/app/views/layouts/_nav.html.haml +1 -1
- data/lib/generators/dry_crud/templates/app/views/layouts/crud.html.erb +15 -7
- data/lib/generators/dry_crud/templates/app/views/layouts/crud.html.haml +18 -8
- data/lib/generators/dry_crud/templates/app/views/list/_search.html.erb +3 -3
- data/lib/generators/dry_crud/templates/app/views/list/_search.html.haml +3 -3
- data/lib/generators/dry_crud/templates/app/views/list/index.html.erb +1 -1
- data/lib/generators/dry_crud/templates/app/views/list/index.html.haml +1 -1
- data/lib/generators/dry_crud/templates/app/views/shared/_error_messages.html.erb +1 -1
- data/lib/generators/dry_crud/templates/app/views/shared/_error_messages.html.haml +1 -1
- data/lib/generators/dry_crud/templates/app/views/shared/_labeled.html.erb +2 -4
- data/lib/generators/dry_crud/templates/app/views/shared/_labeled.html.haml +2 -3
- data/lib/generators/dry_crud/templates/config/initializers/field_error_proc.rb +5 -1
- data/lib/generators/dry_crud/templates/config/locales/crud.de.yml +64 -0
- data/lib/generators/dry_crud/templates/config/locales/{en_crud.yml → crud.en.yml} +2 -2
- data/lib/generators/dry_crud/templates/spec/controllers/crud_test_models_controller_spec.rb +241 -231
- data/lib/generators/dry_crud/templates/spec/helpers/crud/form_builder_spec.rb +226 -0
- data/lib/generators/dry_crud/templates/spec/helpers/{standard_table_builder_spec.rb → crud/table_builder_spec.rb} +36 -34
- data/lib/generators/dry_crud/templates/spec/helpers/form_helper_spec.rb +238 -0
- data/lib/generators/dry_crud/templates/spec/helpers/format_helper_spec.rb +244 -0
- data/lib/generators/dry_crud/templates/spec/helpers/i18n_helper_spec.rb +132 -0
- data/lib/generators/dry_crud/templates/spec/helpers/table_helper_spec.rb +265 -0
- data/lib/generators/dry_crud/templates/spec/helpers/utility_helper_spec.rb +74 -0
- data/lib/generators/dry_crud/templates/spec/support/crud_controller_examples.rb +185 -100
- data/lib/generators/dry_crud/templates/spec/support/crud_controller_test_helper.rb +58 -49
- data/lib/generators/dry_crud/templates/test/{functional → controllers}/crud_test_models_controller_test.rb +112 -91
- data/lib/generators/dry_crud/templates/test/{unit/helpers/standard_form_builder_test.rb → helpers/crud/form_builder_test.rb} +79 -62
- data/lib/generators/dry_crud/templates/test/{unit/helpers/standard_table_builder_test.rb → helpers/crud/table_builder_test.rb} +31 -28
- data/lib/generators/dry_crud/templates/test/helpers/custom_assertions_test.rb +85 -0
- data/lib/generators/dry_crud/templates/test/helpers/form_helper_test.rb +129 -0
- data/lib/generators/dry_crud/templates/test/helpers/format_helper_test.rb +163 -0
- data/lib/generators/dry_crud/templates/test/helpers/i18n_helper_test.rb +79 -0
- data/lib/generators/dry_crud/templates/test/helpers/table_helper_test.rb +217 -0
- data/lib/generators/dry_crud/templates/test/helpers/utility_helper_test.rb +63 -0
- data/lib/generators/dry_crud/templates/test/{functional → support}/crud_controller_test_helper.rb +70 -59
- data/lib/generators/dry_crud/templates/test/{crud_test_model.rb → support/crud_test_model.rb} +107 -75
- data/lib/generators/dry_crud/templates/test/support/custom_assertions.rb +83 -0
- metadata +83 -146
- data/Rakefile +0 -211
- data/lib/generators/dry_crud/templates/app/helpers/crud_helper.rb +0 -168
- data/lib/generators/dry_crud/templates/app/helpers/list_helper.rb +0 -27
- data/lib/generators/dry_crud/templates/app/helpers/standard_form_builder.rb +0 -261
- data/lib/generators/dry_crud/templates/app/helpers/standard_helper.rb +0 -304
- data/lib/generators/dry_crud/templates/app/helpers/standard_table_builder.rb +0 -178
- data/lib/generators/dry_crud/templates/spec/helpers/crud_helper_spec.rb +0 -146
- data/lib/generators/dry_crud/templates/spec/helpers/list_helper_spec.rb +0 -154
- data/lib/generators/dry_crud/templates/spec/helpers/standard_form_builder_spec.rb +0 -215
- data/lib/generators/dry_crud/templates/spec/helpers/standard_helper_spec.rb +0 -387
- data/lib/generators/dry_crud/templates/test/custom_assertions.rb +0 -78
- data/lib/generators/dry_crud/templates/test/unit/custom_assertions_test.rb +0 -117
- data/lib/generators/dry_crud/templates/test/unit/helpers/crud_helper_test.rb +0 -111
- data/lib/generators/dry_crud/templates/test/unit/helpers/list_helper_test.rb +0 -123
- data/lib/generators/dry_crud/templates/test/unit/helpers/standard_helper_test.rb +0 -281
- data/test/templates/Gemfile +0 -46
- data/test/templates/app/controllers/admin/cities_controller.rb +0 -7
- data/test/templates/app/controllers/admin/countries_controller.rb +0 -13
- data/test/templates/app/controllers/ajax_controller.rb +0 -9
- data/test/templates/app/controllers/people_controller.rb +0 -13
- data/test/templates/app/controllers/vips_controller.rb +0 -19
- data/test/templates/app/helpers/cities_helper.rb +0 -9
- data/test/templates/app/helpers/people_helper.rb +0 -8
- data/test/templates/app/models/city.rb +0 -28
- data/test/templates/app/models/country.rb +0 -16
- data/test/templates/app/models/person.rb +0 -12
- data/test/templates/app/views/admin/cities/_actions_index.html.erb +0 -2
- data/test/templates/app/views/admin/cities/_actions_index.html.haml +0 -2
- data/test/templates/app/views/admin/cities/_attrs.html.erb +0 -1
- data/test/templates/app/views/admin/cities/_attrs.html.haml +0 -1
- data/test/templates/app/views/admin/cities/_form.html.erb +0 -7
- data/test/templates/app/views/admin/cities/_form.html.haml +0 -5
- data/test/templates/app/views/admin/cities/_hello.html.erb +0 -1
- data/test/templates/app/views/admin/cities/_hello.html.haml +0 -1
- data/test/templates/app/views/admin/cities/_list.html.erb +0 -3
- data/test/templates/app/views/admin/cities/_list.html.haml +0 -3
- data/test/templates/app/views/admin/countries/_list.html.erb +0 -4
- data/test/templates/app/views/admin/countries/_list.html.haml +0 -3
- data/test/templates/app/views/ajax/_actions_index.html.erb +0 -8
- data/test/templates/app/views/ajax/_actions_index.html.haml +0 -8
- data/test/templates/app/views/ajax/_actions_show.html.erb +0 -4
- data/test/templates/app/views/ajax/_actions_show.html.haml +0 -4
- data/test/templates/app/views/ajax/_form.html.erb +0 -2
- data/test/templates/app/views/ajax/_form.html.haml +0 -2
- data/test/templates/app/views/ajax/_hello.html.erb +0 -1
- data/test/templates/app/views/ajax/_hello.html.haml +0 -1
- data/test/templates/app/views/ajax/ajax.js.erb +0 -1
- data/test/templates/app/views/ajax/ajax.js.haml +0 -1
- data/test/templates/app/views/ajax/edit.js.erb +0 -1
- data/test/templates/app/views/ajax/edit.js.haml +0 -1
- data/test/templates/app/views/ajax/show.js.erb +0 -1
- data/test/templates/app/views/ajax/show.js.haml +0 -1
- data/test/templates/app/views/ajax/update.js.erb +0 -5
- data/test/templates/app/views/ajax/update.js.haml +0 -5
- data/test/templates/app/views/layouts/_nav.html.erb +0 -6
- data/test/templates/app/views/layouts/_nav.html.haml +0 -5
- data/test/templates/app/views/layouts/bootstrap.html.erb +0 -68
- data/test/templates/app/views/layouts/bootstrap.html.haml +0 -49
- data/test/templates/app/views/people/_attrs.html.erb +0 -5
- data/test/templates/app/views/people/_attrs.html.haml +0 -4
- data/test/templates/app/views/people/_list.html.erb +0 -1
- data/test/templates/app/views/people/_list.html.haml +0 -1
- data/test/templates/config/database.yml +0 -21
- data/test/templates/config/locales/en_cities.yml +0 -56
- data/test/templates/config/routes.rb +0 -32
- data/test/templates/db/migrate/20100511174904_create_people_and_cities.rb +0 -26
- data/test/templates/db/seeds.rb +0 -74
- data/test/templates/spec/controllers/admin/cities_controller_spec.rb +0 -74
- data/test/templates/spec/controllers/admin/countries_controller_spec.rb +0 -56
- data/test/templates/spec/controllers/people_controller_spec.rb +0 -80
- data/test/templates/spec/routing/cities_routing_spec.rb +0 -11
- data/test/templates/spec/routing/countries_routing_spec.rb +0 -11
- data/test/templates/test/fixtures/cities.yml +0 -11
- data/test/templates/test/fixtures/countries.yml +0 -11
- data/test/templates/test/fixtures/people.yml +0 -14
- data/test/templates/test/functional/admin/cities_controller_test.rb +0 -59
- data/test/templates/test/functional/admin/countries_controller_test.rb +0 -42
- data/test/templates/test/functional/people_controller_test.rb +0 -68
@@ -1 +0,0 @@
|
|
1
|
-
<%= crud_table :name, :city_id, :birthdate, :children, :income %>
|
@@ -1 +0,0 @@
|
|
1
|
-
= crud_table :name, :city_id, :birthdate, :children, :income
|
@@ -1,21 +0,0 @@
|
|
1
|
-
defaults: &defaults
|
2
|
-
adapter: <%= defined?(JRUBY_VERSION) ? 'jdbcsqlite3' : 'sqlite3' %>
|
3
|
-
pool: 5
|
4
|
-
timeout: 5000
|
5
|
-
|
6
|
-
# SQLite version 3.x
|
7
|
-
# gem install sqlite3
|
8
|
-
development:
|
9
|
-
<<: *defaults
|
10
|
-
database: db/development.sqlite3
|
11
|
-
|
12
|
-
# Warning: The database defined as "test" will be erased and
|
13
|
-
# re-generated from your development database when you run "rake".
|
14
|
-
# Do not set this db to the same as development or production.
|
15
|
-
test:
|
16
|
-
<<: *defaults
|
17
|
-
database: db/test.sqlite3
|
18
|
-
|
19
|
-
production:
|
20
|
-
<<: *defaults
|
21
|
-
database: db/production.sqlite3
|
@@ -1,56 +0,0 @@
|
|
1
|
-
en:
|
2
|
-
global:
|
3
|
-
menu:
|
4
|
-
people: People
|
5
|
-
countries: Countries
|
6
|
-
vips: VIPs
|
7
|
-
link:
|
8
|
-
maps: Maps
|
9
|
-
ajax:
|
10
|
-
global:
|
11
|
-
link:
|
12
|
-
ajax: Ajahx
|
13
|
-
# cities controller
|
14
|
-
admin/cities:
|
15
|
-
global:
|
16
|
-
confirm_delete: You kill city?
|
17
|
-
button:
|
18
|
-
save: Save City
|
19
|
-
index:
|
20
|
-
country_title: All cities of %{country}
|
21
|
-
list:
|
22
|
-
no_list_entries: Nada citta
|
23
|
-
new:
|
24
|
-
button:
|
25
|
-
save: Create City
|
26
|
-
update:
|
27
|
-
flash:
|
28
|
-
success: The %{model} got an update
|
29
|
-
|
30
|
-
# people controller
|
31
|
-
people:
|
32
|
-
global:
|
33
|
-
confirm_delete: You delete pipl?
|
34
|
-
attrs:
|
35
|
-
i_think_its: I think it's
|
36
|
-
nice: Nice
|
37
|
-
check_google: Check Google
|
38
|
-
|
39
|
-
# vips controller
|
40
|
-
vips:
|
41
|
-
index:
|
42
|
-
title: Listing VIPs
|
43
|
-
no_list_entries: No VIPs found
|
44
|
-
|
45
|
-
# model associations
|
46
|
-
activerecord:
|
47
|
-
errors:
|
48
|
-
models:
|
49
|
-
city:
|
50
|
-
protect_with_inhabitants: You cannot destroy this city as long as it has any inhabitants.
|
51
|
-
associations:
|
52
|
-
person:
|
53
|
-
no_entry: Nobody
|
54
|
-
none_available: Nobody here
|
55
|
-
city:
|
56
|
-
none_available: No City
|
@@ -1,32 +0,0 @@
|
|
1
|
-
TestApp::Application.routes.draw do
|
2
|
-
|
3
|
-
resources :people do
|
4
|
-
collection do
|
5
|
-
get :ajax
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
match 'vips' => 'vips#index', :as => :vips
|
10
|
-
|
11
|
-
namespace :admin do
|
12
|
-
resources :countries do
|
13
|
-
collection do
|
14
|
-
get :ajax
|
15
|
-
end
|
16
|
-
|
17
|
-
resources :cities do
|
18
|
-
collection do
|
19
|
-
get :ajax
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
root :to => 'people#index'
|
26
|
-
|
27
|
-
# Install the default routes as the lowest priority.
|
28
|
-
# Note: These default routes make all actions in every controller accessible via GET requests. You should
|
29
|
-
# consider removing or commenting them out if you're using named routes and resources.
|
30
|
-
#map.connect ':controller/:action/:id.:format'
|
31
|
-
#map.connect ':controller/:action/:id'
|
32
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
class CreatePeopleAndCities < ActiveRecord::Migration
|
2
|
-
def change
|
3
|
-
create_table :countries do |t|
|
4
|
-
t.string :name, :null => false
|
5
|
-
t.string :code, :null => :false, :limit => 3
|
6
|
-
end
|
7
|
-
|
8
|
-
create_table :cities do |t|
|
9
|
-
t.string :name, :null => false
|
10
|
-
t.integer :country_id, :null => false
|
11
|
-
end
|
12
|
-
|
13
|
-
create_table :people do |t|
|
14
|
-
t.string :name, :null => false
|
15
|
-
t.integer :children
|
16
|
-
t.integer :city_id
|
17
|
-
t.float :rating
|
18
|
-
t.decimal :income, :precision => 14, :scale => 2
|
19
|
-
t.date :birthdate
|
20
|
-
t.time :gets_up_at
|
21
|
-
t.datetime :last_seen
|
22
|
-
t.text :remarks
|
23
|
-
t.boolean :cool, :null => false, :default => false
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
data/test/templates/db/seeds.rb
DELETED
@@ -1,74 +0,0 @@
|
|
1
|
-
if City.count == 0
|
2
|
-
|
3
|
-
ch = Country.create!(:name => 'Switzerland', :code => 'CH')
|
4
|
-
de = Country.create!(:name => 'Germany', :code => 'DE')
|
5
|
-
usa = Country.create!(:name => 'USA', :code => 'USA')
|
6
|
-
gb = Country.create!(:name => 'England', :code => 'GB')
|
7
|
-
jp = Country.create!(:name => 'Japan', :code => 'JP')
|
8
|
-
|
9
|
-
be = City.create!(:name => 'Bern', :country => ch)
|
10
|
-
ny = City.create!(:name => 'New York', :country => usa)
|
11
|
-
sf = City.create!(:name => 'San Francisco', :country => usa)
|
12
|
-
lon = City.create!(:name => 'London', :country => gb)
|
13
|
-
br = City.create!(:name => 'Berlin', :country => de)
|
14
|
-
|
15
|
-
Person.create!(:name => 'Albert Einstein',
|
16
|
-
:city => be,
|
17
|
-
:children => 2,
|
18
|
-
:rating => 9.8,
|
19
|
-
:income => 84000,
|
20
|
-
:birthdate => '1904-10-18',
|
21
|
-
:gets_up_at => '05:43',
|
22
|
-
:remarks => "Great physician\n Good cyclist")
|
23
|
-
Person.create!(:name => 'Adolf Ogi',
|
24
|
-
:city => be,
|
25
|
-
:children => 3,
|
26
|
-
:rating => 4.2,
|
27
|
-
:income => 264000,
|
28
|
-
:birthdate => '1938-01-22',
|
29
|
-
:gets_up_at => '04:30',
|
30
|
-
:remarks => 'Freude herrscht!')
|
31
|
-
Person.create!(:name => 'Jay Z',
|
32
|
-
:city => ny,
|
33
|
-
:children => 0,
|
34
|
-
:rating => 7.2,
|
35
|
-
:income => 868345,
|
36
|
-
:birthdate => '1976-05-02',
|
37
|
-
:gets_up_at => '12:00',
|
38
|
-
:last_seen => '2011-03-10 17:29',
|
39
|
-
:cool => true,
|
40
|
-
:remarks => "If got 99 problems\nbut you *** ain't one\nTschie")
|
41
|
-
Person.create!(:name => 'Queen Elisabeth',
|
42
|
-
:city => lon,
|
43
|
-
:children => 1,
|
44
|
-
:rating => 1.56,
|
45
|
-
:income => 345622,
|
46
|
-
:birthdate => '1927-08-11',
|
47
|
-
:gets_up_at => '17:12',
|
48
|
-
:remarks => '')
|
49
|
-
Person.create!(:name => 'Schopenhauer',
|
50
|
-
:city => br,
|
51
|
-
:children => 7,
|
52
|
-
:rating => 6.9,
|
53
|
-
:income => 14000,
|
54
|
-
:birthdate => '1788-10-18',
|
55
|
-
:last_seen => '1854-09-01 11:01',
|
56
|
-
:remarks => 'Neminem laede, immo omnes, quantum potes, iuva.')
|
57
|
-
Person.create!(:name => 'ZZ Top',
|
58
|
-
:city => ny,
|
59
|
-
:children => 185,
|
60
|
-
:rating => 1.8,
|
61
|
-
:income => 84000,
|
62
|
-
:birthdate => '1948-03-18',
|
63
|
-
:cool => true,
|
64
|
-
:remarks => 'zzz..')
|
65
|
-
Person.create!(:name => 'Andy Warhol',
|
66
|
-
:city => ny,
|
67
|
-
:children => 0,
|
68
|
-
:rating => 7.5,
|
69
|
-
:income => 123000,
|
70
|
-
:birthdate => '1938-09-08',
|
71
|
-
:last_seen => '1984-10-10 23:39',
|
72
|
-
:remarks => 'Tomato Soup')
|
73
|
-
|
74
|
-
end
|
@@ -1,74 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Admin::CitiesController do
|
4
|
-
|
5
|
-
fixtures :all
|
6
|
-
|
7
|
-
include_examples 'crud controller', {}
|
8
|
-
|
9
|
-
let(:test_entry) { cities(:rj) }
|
10
|
-
let(:test_entry_attrs) { {:name => 'Rejkiavik'} }
|
11
|
-
alias_method :new_entry_attrs, :test_entry_attrs
|
12
|
-
alias_method :edit_entry_attrs, :test_entry_attrs
|
13
|
-
|
14
|
-
it "should load fixtures" do
|
15
|
-
City.count.should == 3
|
16
|
-
end
|
17
|
-
|
18
|
-
describe_action :get, :index do
|
19
|
-
it "should be ordered by default scope" do
|
20
|
-
entries == test_entry.country.cities.order('countries.code, cities.name')
|
21
|
-
end
|
22
|
-
|
23
|
-
it "should set parents" do
|
24
|
-
controller.send(:parents).should == [:admin, test_entry.country]
|
25
|
-
end
|
26
|
-
|
27
|
-
it "should set parent variable" do
|
28
|
-
assigns(:country).should == test_entry.country
|
29
|
-
end
|
30
|
-
|
31
|
-
it "should use correct model_scope" do
|
32
|
-
controller.send(:model_scope).should == test_entry.country.cities
|
33
|
-
end
|
34
|
-
|
35
|
-
it "should have correct path args" do
|
36
|
-
controller.send(:path_args, 2).should == [:admin, test_entry.country, 2]
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
describe_action :get, :show, :id => true do
|
41
|
-
it "should set parents" do
|
42
|
-
controller.send(:parents).should == [:admin, test_entry.country]
|
43
|
-
end
|
44
|
-
|
45
|
-
it "should set parent variable" do
|
46
|
-
assigns(:country).should == test_entry.country
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
describe_action :post, :create do
|
51
|
-
it "should set parent" do
|
52
|
-
entry.country.should == test_entry.country
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
describe_action :delete, :destroy, :id => true do
|
57
|
-
context "with inhabitants" do
|
58
|
-
let(:test_entry) { cities(:ny) }
|
59
|
-
|
60
|
-
it "should not remove city from database", :perform_request => false do
|
61
|
-
expect { perform_request }.to change { City.count }.by(0)
|
62
|
-
end
|
63
|
-
|
64
|
-
it "should redirect to referer", :perform_request => false do
|
65
|
-
ref = @request.env["HTTP_REFERER"] = admin_country_city_url(test_entry.country, test_entry)
|
66
|
-
perform_request
|
67
|
-
should redirect_to(ref)
|
68
|
-
end
|
69
|
-
|
70
|
-
it_should_have_flash(:alert)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Admin::CountriesController do
|
4
|
-
|
5
|
-
fixtures :all
|
6
|
-
|
7
|
-
include_examples 'crud controller', :skip => %w(show html plain)
|
8
|
-
|
9
|
-
let(:test_entry) { countries(:usa) }
|
10
|
-
let(:test_entry_attrs) { {:name => 'United States of America', :code => 'US'} }
|
11
|
-
alias_method :new_entry_attrs, :test_entry_attrs
|
12
|
-
alias_method :edit_entry_attrs, :test_entry_attrs
|
13
|
-
|
14
|
-
it "should load fixtures" do
|
15
|
-
Country.count.should == 3
|
16
|
-
end
|
17
|
-
|
18
|
-
describe_action :get, :index do
|
19
|
-
it "should be ordered by default scope" do
|
20
|
-
entries == Country.order(:name)
|
21
|
-
end
|
22
|
-
|
23
|
-
it "should set parents" do
|
24
|
-
controller.send(:parents).should == [:admin]
|
25
|
-
end
|
26
|
-
|
27
|
-
it "should set nil parent" do
|
28
|
-
controller.send(:parent).should be_nil
|
29
|
-
end
|
30
|
-
|
31
|
-
it "should use correct model_scope" do
|
32
|
-
controller.send(:model_scope).should == Country.scoped
|
33
|
-
end
|
34
|
-
|
35
|
-
it "should have correct path args" do
|
36
|
-
controller.send(:path_args, 2).should == [:admin, 2]
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
describe_action :get, :show do
|
41
|
-
let(:params) { {:id => test_entry.id} }
|
42
|
-
it_should_redirect_to_index
|
43
|
-
end
|
44
|
-
|
45
|
-
end
|
46
|
-
|
47
|
-
class Admin::CountriesControllerTest < ActionController::TestCase
|
48
|
-
|
49
|
-
include CrudControllerTestHelper
|
50
|
-
|
51
|
-
def test_show
|
52
|
-
get :show, test_params(:id => test_entry.id)
|
53
|
-
assert_redirected_to_index
|
54
|
-
end
|
55
|
-
|
56
|
-
end
|
@@ -1,80 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe PeopleController do
|
4
|
-
|
5
|
-
fixtures :all
|
6
|
-
|
7
|
-
render_views
|
8
|
-
|
9
|
-
include_examples 'crud controller', {}
|
10
|
-
|
11
|
-
let(:test_entry) { people(:john) }
|
12
|
-
let(:test_entry_attrs) { {:name => 'Fischers Fritz',
|
13
|
-
:children => 2,
|
14
|
-
:income => 120,
|
15
|
-
:city_id => cities(:rj).id} }
|
16
|
-
alias_method :new_entry_attrs, :test_entry_attrs
|
17
|
-
alias_method :edit_entry_attrs, :test_entry_attrs
|
18
|
-
|
19
|
-
it "should load fixtures" do
|
20
|
-
Person.count.should == 2
|
21
|
-
end
|
22
|
-
|
23
|
-
describe_action :get, :index do
|
24
|
-
it "should be ordered by default scope" do
|
25
|
-
entries == Person.includes(:city => :country).order('people.name, countries.code, cities.name')
|
26
|
-
end
|
27
|
-
|
28
|
-
it "should set parents" do
|
29
|
-
controller.send(:parents).should == []
|
30
|
-
end
|
31
|
-
|
32
|
-
it "should set nil parent" do
|
33
|
-
controller.send(:parent).should be_nil
|
34
|
-
end
|
35
|
-
|
36
|
-
it "should use correct model_scope" do
|
37
|
-
controller.send(:model_scope).should == Person.scoped
|
38
|
-
end
|
39
|
-
|
40
|
-
it "should have correct path args" do
|
41
|
-
controller.send(:path_args, 2).should == [2]
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
describe_action :get, :show, :id => true do
|
46
|
-
context ".js", :format => :js do
|
47
|
-
it_should_respond
|
48
|
-
it_should_render
|
49
|
-
its(:body) { should match(/\$\('#content'\)/) }
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
describe_action :get, :edit, :id => true do
|
54
|
-
context ".js", :format => :js do
|
55
|
-
it_should_respond
|
56
|
-
it_should_render
|
57
|
-
its(:body) { should match(/\$\('#content'\)/) }
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
describe_action :put, :update, :id => true do
|
62
|
-
context ".js", :format => :js do
|
63
|
-
context 'with valid params' do
|
64
|
-
let(:params) { {:person => {:name => 'New Name'} } }
|
65
|
-
|
66
|
-
it_should_respond
|
67
|
-
it_should_render
|
68
|
-
its(:body) { should match(/\$\('#content'\)/) }
|
69
|
-
end
|
70
|
-
|
71
|
-
context "with invalid params" do
|
72
|
-
let(:params) { {:person => {:name => ' '} } }
|
73
|
-
|
74
|
-
it_should_respond
|
75
|
-
it_should_render
|
76
|
-
its(:body) { should match(/alert/) }
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|