dynamic_controller 0.0.8 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. data/README.md +80 -80
  2. data/dynamic_controller.gemspec +27 -27
  3. data/lib/dynamic_controller/action_controller_extension.rb +18 -16
  4. data/lib/dynamic_controller/class_methods.rb +41 -41
  5. data/lib/dynamic_controller/helper_methods.rb +103 -91
  6. data/lib/dynamic_controller/instance_methods.rb +139 -139
  7. data/lib/dynamic_controller/resource.rb +21 -21
  8. data/lib/dynamic_controller/responder.rb +70 -70
  9. data/lib/dynamic_controller/version.rb +3 -3
  10. data/lib/dynamic_controller.rb +18 -18
  11. data/spec/controller_factory.rb +22 -22
  12. data/spec/controllers/crud_actions_html_spec.rb +111 -111
  13. data/spec/controllers/crud_actions_json_spec.rb +91 -91
  14. data/spec/controllers/nested_crud_actions_html_spec.rb +125 -125
  15. data/spec/controllers/nested_crud_actions_json_spec.rb +97 -97
  16. data/spec/controllers/ransack_spec.rb +57 -57
  17. data/spec/controllers/redefined_responders_html_spec.rb +111 -111
  18. data/spec/controllers/redefined_responders_json_spec.rb +94 -94
  19. data/spec/controllers/two_level_nested_crud_actions_html_spec.rb +133 -133
  20. data/spec/controllers/two_level_nested_crud_actions_json_spec.rb +97 -97
  21. data/spec/custom_responder_format_spec.rb +12 -12
  22. data/spec/dummy/Gemfile +13 -13
  23. data/spec/dummy/app/controllers/cities_controller.rb +95 -95
  24. data/spec/dummy/app/controllers/languages_controller.rb +95 -95
  25. data/spec/dummy/app/controllers/streets_controller.rb +97 -97
  26. data/spec/dummy/app/models/city.rb +6 -6
  27. data/spec/dummy/app/models/language.rb +4 -4
  28. data/spec/dummy/app/models/street.rb +5 -5
  29. data/spec/dummy/app/views/cities/_form.html.erb +25 -25
  30. data/spec/dummy/app/views/cities/index.html.erb +29 -29
  31. data/spec/dummy/app/views/countries/index.html.erb +25 -25
  32. data/spec/dummy/app/views/languages/_form.html.erb +21 -21
  33. data/spec/dummy/app/views/languages/edit.html.erb +6 -6
  34. data/spec/dummy/app/views/languages/index.html.erb +23 -23
  35. data/spec/dummy/app/views/languages/new.html.erb +5 -5
  36. data/spec/dummy/app/views/languages/show.html.erb +10 -10
  37. data/spec/dummy/app/views/streets/_form.html.erb +25 -25
  38. data/spec/dummy/app/views/streets/edit.html.erb +6 -6
  39. data/spec/dummy/app/views/streets/index.html.erb +27 -27
  40. data/spec/dummy/app/views/streets/new.html.erb +5 -5
  41. data/spec/dummy/app/views/streets/show.html.erb +15 -15
  42. data/spec/dummy/config/routes.rb +8 -8
  43. data/spec/dummy/db/migrate/20120922010743_create_languages.rb +9 -9
  44. data/spec/dummy/db/migrate/20120929185302_create_streets.rb +11 -11
  45. data/spec/dummy/db/schema.rb +46 -46
  46. data/spec/factories.rb +21 -21
  47. data/spec/has_crud_actions_options_spec.rb +48 -48
  48. data/spec/spec_helper.rb +35 -35
  49. metadata +58 -17
@@ -1,25 +1,25 @@
1
- <%= form_for([@country, @city]) do |f| %>
2
- <% if @city.errors.any? %>
3
- <div id="error_explanation">
4
- <h2><%= pluralize(@city.errors.count, "error") %> prohibited this city from being saved:</h2>
5
-
6
- <ul>
7
- <% @city.errors.full_messages.each do |msg| %>
8
- <li><%= msg %></li>
9
- <% end %>
10
- </ul>
11
- </div>
12
- <% end %>
13
-
14
- <div class="field">
15
- <%= f.label :name %><br />
16
- <%= f.text_field :name %>
17
- </div>
18
- <div class="field">
19
- <%= f.label :country %><br />
20
- <%= @country.name %>
21
- </div>
22
- <div class="actions">
23
- <%= f.submit %>
24
- </div>
25
- <% end %>
1
+ <%= form_for([@country, @city]) do |f| %>
2
+ <% if @city.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%= pluralize(@city.errors.count, "error") %> prohibited this city from being saved:</h2>
5
+
6
+ <ul>
7
+ <% @city.errors.full_messages.each do |msg| %>
8
+ <li><%= msg %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div class="field">
15
+ <%= f.label :name %><br />
16
+ <%= f.text_field :name %>
17
+ </div>
18
+ <div class="field">
19
+ <%= f.label :country %><br />
20
+ <%= @country.name %>
21
+ </div>
22
+ <div class="actions">
23
+ <%= f.submit %>
24
+ </div>
25
+ <% end %>
@@ -1,29 +1,29 @@
1
- <h1>Listing cities</h1>
2
-
3
- <table>
4
- <tr>
5
- <th>Name</th>
6
- <th>Country</th>
7
- <th></th>
8
- <th></th>
9
- <th></th>
10
- <th></th>
11
- </tr>
12
-
13
- <% @cities.each do |city| %>
14
- <tr>
15
- <td><%= city.name %></td>
16
- <td><%= city.country.name %></td>
17
- <td><%= link_to 'Show', [@country, city] %></td>
18
- <td><%= link_to 'Edit', edit_country_city_path(@country, city) %></td>
19
- <td><%= link_to 'Destroy', [@country, city], method: :delete, data: { confirm: 'Are you sure?' } %></td>
20
- <td><%= link_to 'Streets', country_city_streets_path(@country, city) %></td>
21
- </tr>
22
- <% end %>
23
- </table>
24
-
25
- <br />
26
-
27
- <%= link_to 'New City', new_country_city_path(@country) %>
28
- <br>
29
- <%= link_to 'Back to Countries', countries_path %>
1
+ <h1>Listing cities</h1>
2
+
3
+ <table>
4
+ <tr>
5
+ <th>Name</th>
6
+ <th>Country</th>
7
+ <th></th>
8
+ <th></th>
9
+ <th></th>
10
+ <th></th>
11
+ </tr>
12
+
13
+ <% @cities.each do |city| %>
14
+ <tr>
15
+ <td><%= city.name %></td>
16
+ <td><%= city.country.name %></td>
17
+ <td><%= link_to 'Show', [@country, city] %></td>
18
+ <td><%= link_to 'Edit', edit_country_city_path(@country, city) %></td>
19
+ <td><%= link_to 'Destroy', [@country, city], method: :delete, data: { confirm: 'Are you sure?' } %></td>
20
+ <td><%= link_to 'Streets', country_city_streets_path(@country, city) %></td>
21
+ </tr>
22
+ <% end %>
23
+ </table>
24
+
25
+ <br />
26
+
27
+ <%= link_to 'New City', new_country_city_path(@country) %>
28
+ <br>
29
+ <%= link_to 'Back to Countries', countries_path %>
@@ -1,25 +1,25 @@
1
- <h1>Listing countries</h1>
2
-
3
- <table>
4
- <tr>
5
- <th>Name</th>
6
- <th></th>
7
- <th></th>
8
- <th></th>
9
- <th></th>
10
- </tr>
11
-
12
- <% @countries.each do |country| %>
13
- <tr>
14
- <td><%= country.name %></td>
15
- <td><%= link_to 'Show', country %></td>
16
- <td><%= link_to 'Edit', edit_country_path(country) %></td>
17
- <td><%= link_to 'Destroy', country, method: :delete, data: { confirm: 'Are you sure?' } %></td>
18
- <td><%= link_to 'Cities', country_cities_path(country) %></td>
19
- </tr>
20
- <% end %>
21
- </table>
22
-
23
- <br />
24
-
25
- <%= link_to 'New Country', new_country_path %>
1
+ <h1>Listing countries</h1>
2
+
3
+ <table>
4
+ <tr>
5
+ <th>Name</th>
6
+ <th></th>
7
+ <th></th>
8
+ <th></th>
9
+ <th></th>
10
+ </tr>
11
+
12
+ <% @countries.each do |country| %>
13
+ <tr>
14
+ <td><%= country.name %></td>
15
+ <td><%= link_to 'Show', country %></td>
16
+ <td><%= link_to 'Edit', edit_country_path(country) %></td>
17
+ <td><%= link_to 'Destroy', country, method: :delete, data: { confirm: 'Are you sure?' } %></td>
18
+ <td><%= link_to 'Cities', country_cities_path(country) %></td>
19
+ </tr>
20
+ <% end %>
21
+ </table>
22
+
23
+ <br />
24
+
25
+ <%= link_to 'New Country', new_country_path %>
@@ -1,21 +1,21 @@
1
- <%= form_for(@language) do |f| %>
2
- <% if @language.errors.any? %>
3
- <div id="error_explanation">
4
- <h2><%= pluralize(@language.errors.count, "error") %> prohibited this language from being saved:</h2>
5
-
6
- <ul>
7
- <% @language.errors.full_messages.each do |msg| %>
8
- <li><%= msg %></li>
9
- <% end %>
10
- </ul>
11
- </div>
12
- <% end %>
13
-
14
- <div class="field">
15
- <%= f.label :name %><br />
16
- <%= f.text_field :name %>
17
- </div>
18
- <div class="actions">
19
- <%= f.submit %>
20
- </div>
21
- <% end %>
1
+ <%= form_for(@language) do |f| %>
2
+ <% if @language.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%= pluralize(@language.errors.count, "error") %> prohibited this language from being saved:</h2>
5
+
6
+ <ul>
7
+ <% @language.errors.full_messages.each do |msg| %>
8
+ <li><%= msg %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div class="field">
15
+ <%= f.label :name %><br />
16
+ <%= f.text_field :name %>
17
+ </div>
18
+ <div class="actions">
19
+ <%= f.submit %>
20
+ </div>
21
+ <% end %>
@@ -1,6 +1,6 @@
1
- <h1>Editing language</h1>
2
-
3
- <%= render 'form' %>
4
-
5
- <%= link_to 'Show', @language %> |
6
- <%= link_to 'Back', languages_path %>
1
+ <h1>Editing language</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Show', @language %> |
6
+ <%= link_to 'Back', languages_path %>
@@ -1,23 +1,23 @@
1
- <h1>Listing languages</h1>
2
-
3
- <table>
4
- <tr>
5
- <th>Name</th>
6
- <th></th>
7
- <th></th>
8
- <th></th>
9
- </tr>
10
-
11
- <% @languages.each do |language| %>
12
- <tr>
13
- <td><%= language.name %></td>
14
- <td><%= link_to 'Show', language %></td>
15
- <td><%= link_to 'Edit', edit_language_path(language) %></td>
16
- <td><%= link_to 'Destroy', language, method: :delete, data: { confirm: 'Are you sure?' } %></td>
17
- </tr>
18
- <% end %>
19
- </table>
20
-
21
- <br />
22
-
23
- <%= link_to 'New Country', new_language_path %>
1
+ <h1>Listing languages</h1>
2
+
3
+ <table>
4
+ <tr>
5
+ <th>Name</th>
6
+ <th></th>
7
+ <th></th>
8
+ <th></th>
9
+ </tr>
10
+
11
+ <% @languages.each do |language| %>
12
+ <tr>
13
+ <td><%= language.name %></td>
14
+ <td><%= link_to 'Show', language %></td>
15
+ <td><%= link_to 'Edit', edit_language_path(language) %></td>
16
+ <td><%= link_to 'Destroy', language, method: :delete, data: { confirm: 'Are you sure?' } %></td>
17
+ </tr>
18
+ <% end %>
19
+ </table>
20
+
21
+ <br />
22
+
23
+ <%= link_to 'New Country', new_language_path %>
@@ -1,5 +1,5 @@
1
- <h1>New language</h1>
2
-
3
- <%= render 'form' %>
4
-
5
- <%= link_to 'Back', languages_path %>
1
+ <h1>New language</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Back', languages_path %>
@@ -1,10 +1,10 @@
1
- <p id="notice"><%= notice %></p>
2
-
3
- <p>
4
- <b>Name:</b>
5
- <%= @language.name %>
6
- </p>
7
-
8
-
9
- <%= link_to 'Edit', edit_language_path(@language) %> |
10
- <%= link_to 'Back', languages_path %>
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <p>
4
+ <b>Name:</b>
5
+ <%= @language.name %>
6
+ </p>
7
+
8
+
9
+ <%= link_to 'Edit', edit_language_path(@language) %> |
10
+ <%= link_to 'Back', languages_path %>
@@ -1,25 +1,25 @@
1
- <%= form_for([@country, @city, @street]) do |f| %>
2
- <% if @street.errors.any? %>
3
- <div id="error_explanation">
4
- <h2><%= pluralize(@street.errors.count, "error") %> prohibited this street from being saved:</h2>
5
-
6
- <ul>
7
- <% @street.errors.full_messages.each do |msg| %>
8
- <li><%= msg %></li>
9
- <% end %>
10
- </ul>
11
- </div>
12
- <% end %>
13
-
14
- <div class="field">
15
- <%= f.label :name %><br />
16
- <%= f.text_field :name %>
17
- </div>
18
- <div class="field">
19
- <%= f.label :city %><br />
20
- <%= @city.name %>
21
- </div>
22
- <div class="actions">
23
- <%= f.submit %>
24
- </div>
25
- <% end %>
1
+ <%= form_for([@country, @city, @street]) do |f| %>
2
+ <% if @street.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%= pluralize(@street.errors.count, "error") %> prohibited this street from being saved:</h2>
5
+
6
+ <ul>
7
+ <% @street.errors.full_messages.each do |msg| %>
8
+ <li><%= msg %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div class="field">
15
+ <%= f.label :name %><br />
16
+ <%= f.text_field :name %>
17
+ </div>
18
+ <div class="field">
19
+ <%= f.label :city %><br />
20
+ <%= @city.name %>
21
+ </div>
22
+ <div class="actions">
23
+ <%= f.submit %>
24
+ </div>
25
+ <% end %>
@@ -1,6 +1,6 @@
1
- <h1>Editing street</h1>
2
-
3
- <%= render 'form' %>
4
-
5
- <%= link_to 'Show', [@country, @city, @street] %> |
6
- <%= link_to 'Back', country_city_streets_path(@country, @city) %>
1
+ <h1>Editing street</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Show', [@country, @city, @street] %> |
6
+ <%= link_to 'Back', country_city_streets_path(@country, @city) %>
@@ -1,27 +1,27 @@
1
- <h1>Listing streets</h1>
2
-
3
- <table>
4
- <tr>
5
- <th>Name</th>
6
- <th>City</th>
7
- <th></th>
8
- <th></th>
9
- <th></th>
10
- </tr>
11
-
12
- <% @streets.each do |street| %>
13
- <tr>
14
- <td><%= street.name %></td>
15
- <td><%= street.city.name %></td>
16
- <td><%= link_to 'Show', [@country, @city, street] %></td>
17
- <td><%= link_to 'Edit', edit_country_city_street_path(@country, @city, street) %></td>
18
- <td><%= link_to 'Destroy', [@country, @city, street], method: :delete, data: { confirm: 'Are you sure?' } %></td>
19
- </tr>
20
- <% end %>
21
- </table>
22
-
23
- <br />
24
-
25
- <%= link_to 'New Street', new_country_city_street_path(@country, @city) %>
26
- <br>
27
- <%= link_to 'Back to Cities', country_cities_path(@country) %>
1
+ <h1>Listing streets</h1>
2
+
3
+ <table>
4
+ <tr>
5
+ <th>Name</th>
6
+ <th>City</th>
7
+ <th></th>
8
+ <th></th>
9
+ <th></th>
10
+ </tr>
11
+
12
+ <% @streets.each do |street| %>
13
+ <tr>
14
+ <td><%= street.name %></td>
15
+ <td><%= street.city.name %></td>
16
+ <td><%= link_to 'Show', [@country, @city, street] %></td>
17
+ <td><%= link_to 'Edit', edit_country_city_street_path(@country, @city, street) %></td>
18
+ <td><%= link_to 'Destroy', [@country, @city, street], method: :delete, data: { confirm: 'Are you sure?' } %></td>
19
+ </tr>
20
+ <% end %>
21
+ </table>
22
+
23
+ <br />
24
+
25
+ <%= link_to 'New Street', new_country_city_street_path(@country, @city) %>
26
+ <br>
27
+ <%= link_to 'Back to Cities', country_cities_path(@country) %>
@@ -1,5 +1,5 @@
1
- <h1>New street</h1>
2
-
3
- <%= render 'form' %>
4
-
5
- <%= link_to 'Back', country_city_streets_path(@country, @city) %>
1
+ <h1>New street</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Back', country_city_streets_path(@country, @city) %>
@@ -1,15 +1,15 @@
1
- <p id="notice"><%= notice %></p>
2
-
3
- <p>
4
- <b>Name:</b>
5
- <%= @street.name %>
6
- </p>
7
-
8
- <p>
9
- <b>City:</b>
10
- <%= @street.city.name %>
11
- </p>
12
-
13
-
14
- <%= link_to 'Edit', edit_country_city_street_path(@country, @city, @street) %> |
15
- <%= link_to 'Back', country_city_streets_path(@country, @city) %>
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <p>
4
+ <b>Name:</b>
5
+ <%= @street.name %>
6
+ </p>
7
+
8
+ <p>
9
+ <b>City:</b>
10
+ <%= @street.city.name %>
11
+ </p>
12
+
13
+
14
+ <%= link_to 'Edit', edit_country_city_street_path(@country, @city, @street) %> |
15
+ <%= link_to 'Back', country_city_streets_path(@country, @city) %>
@@ -1,8 +1,8 @@
1
- Dummy::Application.routes.draw do
2
- resources :languages
3
- resources :countries do
4
- resources :cities do
5
- resources :streets
6
- end
7
- end
8
- end
1
+ Dummy::Application.routes.draw do
2
+ resources :languages
3
+ resources :countries do
4
+ resources :cities do
5
+ resources :streets
6
+ end
7
+ end
8
+ end
@@ -1,9 +1,9 @@
1
- class CreateLanguages < ActiveRecord::Migration
2
- def change
3
- create_table :languages do |t|
4
- t.string :name
5
-
6
- t.timestamps
7
- end
8
- end
9
- end
1
+ class CreateLanguages < ActiveRecord::Migration
2
+ def change
3
+ create_table :languages do |t|
4
+ t.string :name
5
+
6
+ t.timestamps
7
+ end
8
+ end
9
+ end
@@ -1,11 +1,11 @@
1
- class CreateStreets < ActiveRecord::Migration
2
- def change
3
- create_table :streets do |t|
4
- t.string :name
5
- t.references :city
6
-
7
- t.timestamps
8
- end
9
- add_index :streets, :city_id
10
- end
11
- end
1
+ class CreateStreets < ActiveRecord::Migration
2
+ def change
3
+ create_table :streets do |t|
4
+ t.string :name
5
+ t.references :city
6
+
7
+ t.timestamps
8
+ end
9
+ add_index :streets, :city_id
10
+ end
11
+ end
@@ -1,46 +1,46 @@
1
- # encoding: UTF-8
2
- # This file is auto-generated from the current state of the database. Instead
3
- # of editing this file, please use the migrations feature of Active Record to
4
- # incrementally modify your database, and then regenerate this schema definition.
5
- #
6
- # Note that this schema.rb definition is the authoritative source for your
7
- # database schema. If you need to create the application database on another
8
- # system, you should be using db:schema:load, not running all the migrations
9
- # from scratch. The latter is a flawed and unsustainable approach (the more migrations
10
- # you'll amass, the slower it'll run and the greater likelihood for issues).
11
- #
12
- # It's strongly recommended to check this file into your version control system.
13
-
14
- ActiveRecord::Schema.define(:version => 20120929185302) do
15
-
16
- create_table "cities", :force => true do |t|
17
- t.string "name"
18
- t.integer "country_id"
19
- t.datetime "created_at", :null => false
20
- t.datetime "updated_at", :null => false
21
- end
22
-
23
- add_index "cities", ["country_id"], :name => "index_cities_on_country_id"
24
-
25
- create_table "countries", :force => true do |t|
26
- t.string "name"
27
- t.datetime "created_at", :null => false
28
- t.datetime "updated_at", :null => false
29
- end
30
-
31
- create_table "languages", :force => true do |t|
32
- t.string "name"
33
- t.datetime "created_at", :null => false
34
- t.datetime "updated_at", :null => false
35
- end
36
-
37
- create_table "streets", :force => true do |t|
38
- t.string "name"
39
- t.integer "city_id"
40
- t.datetime "created_at", :null => false
41
- t.datetime "updated_at", :null => false
42
- end
43
-
44
- add_index "streets", ["city_id"], :name => "index_streets_on_city_id"
45
-
46
- end
1
+ # encoding: UTF-8
2
+ # This file is auto-generated from the current state of the database. Instead
3
+ # of editing this file, please use the migrations feature of Active Record to
4
+ # incrementally modify your database, and then regenerate this schema definition.
5
+ #
6
+ # Note that this schema.rb definition is the authoritative source for your
7
+ # database schema. If you need to create the application database on another
8
+ # system, you should be using db:schema:load, not running all the migrations
9
+ # from scratch. The latter is a flawed and unsustainable approach (the more migrations
10
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
11
+ #
12
+ # It's strongly recommended to check this file into your version control system.
13
+
14
+ ActiveRecord::Schema.define(:version => 20120929185302) do
15
+
16
+ create_table "cities", :force => true do |t|
17
+ t.string "name"
18
+ t.integer "country_id"
19
+ t.datetime "created_at", :null => false
20
+ t.datetime "updated_at", :null => false
21
+ end
22
+
23
+ add_index "cities", ["country_id"], :name => "index_cities_on_country_id"
24
+
25
+ create_table "countries", :force => true do |t|
26
+ t.string "name"
27
+ t.datetime "created_at", :null => false
28
+ t.datetime "updated_at", :null => false
29
+ end
30
+
31
+ create_table "languages", :force => true do |t|
32
+ t.string "name"
33
+ t.datetime "created_at", :null => false
34
+ t.datetime "updated_at", :null => false
35
+ end
36
+
37
+ create_table "streets", :force => true do |t|
38
+ t.string "name"
39
+ t.integer "city_id"
40
+ t.datetime "created_at", :null => false
41
+ t.datetime "updated_at", :null => false
42
+ end
43
+
44
+ add_index "streets", ["city_id"], :name => "index_streets_on_city_id"
45
+
46
+ end