cruddler 1.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/Gemfile +29 -0
- data/Gemfile.lock +141 -0
- data/MIT-LICENSE +20 -0
- data/README.textile +173 -0
- data/Rakefile +40 -0
- data/cruddler.gemspec +23 -0
- data/lib/cruddler.rb +33 -0
- data/lib/cruddler/controller.rb +186 -0
- data/lib/cruddler/crud_actions.rb +118 -0
- data/lib/cruddler/engine.rb +28 -0
- data/lib/cruddler/path_helpers.rb +100 -0
- data/lib/cruddler/version.rb +26 -0
- data/lib/generators/cruddler/install/USAGE +8 -0
- data/lib/generators/cruddler/install/install_generator.rb +40 -0
- data/lib/generators/cruddler/install/templates/application/edit.html.erb +18 -0
- data/lib/generators/cruddler/install/templates/application/index.html.erb +13 -0
- data/lib/generators/cruddler/install/templates/application/new.html.erb +17 -0
- data/lib/generators/cruddler/install/templates/application/show.html.erb +17 -0
- data/lib/generators/cruddler/install/templates/cruddler.yml +21 -0
- data/lib/tasks/cruddler_tasks.rake +4 -0
- data/script/rails +8 -0
- data/test/cruddler_test.rb +7 -0
- data/test/dummy/README.rdoc +261 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js +15 -0
- data/test/dummy/app/assets/javascripts/cats.js +2 -0
- data/test/dummy/app/assets/javascripts/dogs.js +2 -0
- data/test/dummy/app/assets/javascripts/houses.js +2 -0
- data/test/dummy/app/assets/javascripts/parasites.js +2 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/assets/stylesheets/cats.css +4 -0
- data/test/dummy/app/assets/stylesheets/dogs.css +4 -0
- data/test/dummy/app/assets/stylesheets/houses.css +4 -0
- data/test/dummy/app/assets/stylesheets/parasites.css +4 -0
- data/test/dummy/app/assets/stylesheets/scaffold.css +56 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/controllers/cats_controller.rb +7 -0
- data/test/dummy/app/controllers/dogs_controller.rb +11 -0
- data/test/dummy/app/controllers/houses_controller.rb +6 -0
- data/test/dummy/app/controllers/parasites_controller.rb +8 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/helpers/cats_helper.rb +2 -0
- data/test/dummy/app/helpers/dogs_helper.rb +2 -0
- data/test/dummy/app/helpers/houses_helper.rb +2 -0
- data/test/dummy/app/helpers/parasites_helper.rb +2 -0
- data/test/dummy/app/mailers/.gitkeep +0 -0
- data/test/dummy/app/models/.gitkeep +0 -0
- data/test/dummy/app/models/cat.rb +4 -0
- data/test/dummy/app/models/dog.rb +3 -0
- data/test/dummy/app/models/house.rb +5 -0
- data/test/dummy/app/models/parasite.rb +3 -0
- data/test/dummy/app/views/application/edit.html.erb +18 -0
- data/test/dummy/app/views/application/index.html.erb +13 -0
- data/test/dummy/app/views/application/new.html.erb +17 -0
- data/test/dummy/app/views/application/show.html.erb +17 -0
- data/test/dummy/app/views/cats/_form.html.erb +15 -0
- data/test/dummy/app/views/cats/_listing.html.erb +23 -0
- data/test/dummy/app/views/cats/_show_cat.html.erb +10 -0
- data/test/dummy/app/views/dogs/_form.html.erb +21 -0
- data/test/dummy/app/views/dogs/_listing.html.erb +23 -0
- data/test/dummy/app/views/dogs/_show_dog.html.erb +10 -0
- data/test/dummy/app/views/houses/_form.html.erb +25 -0
- data/test/dummy/app/views/houses/_listing.html.erb +23 -0
- data/test/dummy/app/views/houses/_show_house.html.erb +11 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/app/views/parasites/_form.html.erb +25 -0
- data/test/dummy/app/views/parasites/_listing.html.erb +27 -0
- data/test/dummy/app/views/parasites/_show_parasite.html.erb +19 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +23 -0
- data/test/dummy/config/boot.rb +4 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +29 -0
- data/test/dummy/config/environments/production.rb +80 -0
- data/test/dummy/config/environments/test.rb +36 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +12 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +12 -0
- data/test/dummy/db/migrate/20120606105838_create_houses.rb +10 -0
- data/test/dummy/db/migrate/20120606110003_create_cats.rb +11 -0
- data/test/dummy/db/migrate/20120606110348_create_dogs.rb +13 -0
- data/test/dummy/db/migrate/20120606175547_create_parasites.rb +12 -0
- data/test/dummy/db/schema.rb +53 -0
- data/test/dummy/lib/assets/.gitkeep +0 -0
- data/test/dummy/log/.gitkeep +0 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +25 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/integration/cruddler_integration_test.rb +253 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/support/capybara.rb +29 -0
- data/test/test_helper.rb +15 -0
- metadata +253 -0
@@ -0,0 +1,23 @@
|
|
1
|
+
# Files in the config/locales directory are used for internationalization
|
2
|
+
# and are automatically loaded by Rails. If you want to use locales other
|
3
|
+
# than English, add the necessary files in this directory.
|
4
|
+
#
|
5
|
+
# To use the locales, use `I18n.t`:
|
6
|
+
#
|
7
|
+
# I18n.t 'hello'
|
8
|
+
#
|
9
|
+
# In views, this is aliased to just `t`:
|
10
|
+
#
|
11
|
+
# <%= t('hello') %>
|
12
|
+
#
|
13
|
+
# To use a different locale, set it with `I18n.locale`:
|
14
|
+
#
|
15
|
+
# I18n.locale = :es
|
16
|
+
#
|
17
|
+
# This would use the information in config/locales/es.yml.
|
18
|
+
#
|
19
|
+
# To learn more, please read the Rails Internationalization guide
|
20
|
+
# available at http://guides.rubyonrails.org/i18n.html.
|
21
|
+
|
22
|
+
en:
|
23
|
+
hello: "Hello world"
|
@@ -0,0 +1,53 @@
|
|
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 => 20120606175547) do
|
15
|
+
|
16
|
+
create_table "cats", :force => true do |t|
|
17
|
+
t.string "name"
|
18
|
+
t.integer "house_id"
|
19
|
+
t.datetime "created_at", :null => false
|
20
|
+
t.datetime "updated_at", :null => false
|
21
|
+
end
|
22
|
+
|
23
|
+
add_index "cats", ["house_id"], :name => "index_cats_on_house_id"
|
24
|
+
|
25
|
+
create_table "dogs", :force => true do |t|
|
26
|
+
t.string "name"
|
27
|
+
t.integer "ref_id"
|
28
|
+
t.string "ref_type"
|
29
|
+
t.datetime "created_at", :null => false
|
30
|
+
t.datetime "updated_at", :null => false
|
31
|
+
end
|
32
|
+
|
33
|
+
add_index "dogs", ["ref_id"], :name => "index_dogs_on_ref_id"
|
34
|
+
add_index "dogs", ["ref_type"], :name => "index_dogs_on_ref_type"
|
35
|
+
|
36
|
+
create_table "houses", :force => true do |t|
|
37
|
+
t.string "name"
|
38
|
+
t.integer "number"
|
39
|
+
t.datetime "created_at", :null => false
|
40
|
+
t.datetime "updated_at", :null => false
|
41
|
+
end
|
42
|
+
|
43
|
+
create_table "parasites", :force => true do |t|
|
44
|
+
t.string "name"
|
45
|
+
t.integer "legs"
|
46
|
+
t.integer "cat_id"
|
47
|
+
t.datetime "created_at", :null => false
|
48
|
+
t.datetime "updated_at", :null => false
|
49
|
+
end
|
50
|
+
|
51
|
+
add_index "parasites", ["cat_id"], :name => "index_parasites_on_cat_id"
|
52
|
+
|
53
|
+
end
|
File without changes
|
File without changes
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/404.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
23
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/422.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>The change you wanted was rejected.</h1>
|
23
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/500.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>We're sorry, but something went wrong.</h1>
|
23
|
+
</div>
|
24
|
+
</body>
|
25
|
+
</html>
|
File without changes
|
@@ -0,0 +1,6 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
|
+
|
4
|
+
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
5
|
+
require File.expand_path('../../config/boot', __FILE__)
|
6
|
+
require 'rails/commands'
|
@@ -0,0 +1,253 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class CruddlerIntegrationTest < ActionDispatch::IntegrationTest
|
4
|
+
|
5
|
+
test "Basic CRUD" do
|
6
|
+
# INDEX
|
7
|
+
visit '/houses'
|
8
|
+
assert page.has_content?('No Houses')
|
9
|
+
|
10
|
+
# CREATE
|
11
|
+
click_link 'Create'
|
12
|
+
assert_equal '/houses/new', current_path
|
13
|
+
fill_in 'house_name', with: "First House"
|
14
|
+
fill_in 'house_number', with: '1'
|
15
|
+
click_button 'Create House'
|
16
|
+
|
17
|
+
# INDEX, again
|
18
|
+
assert_equal '/houses', current_path
|
19
|
+
assert page.has_content?('First House')
|
20
|
+
assert !page.has_content?('No Houses')
|
21
|
+
|
22
|
+
# SHOW
|
23
|
+
click_link 'Show'
|
24
|
+
assert page.has_content?('First House')
|
25
|
+
click_link 'Abort'
|
26
|
+
assert_equal '/houses', current_path
|
27
|
+
|
28
|
+
# EDIT
|
29
|
+
click_link 'Edit'
|
30
|
+
#assert page.has_content?('FancyGallery')
|
31
|
+
fill_in 'house_name', with: "Another House"
|
32
|
+
click_button 'Update House'
|
33
|
+
|
34
|
+
# INDEX, again
|
35
|
+
assert_equal '/houses', current_path
|
36
|
+
assert !page.has_content?('First House')
|
37
|
+
assert page.has_content?('Another House')
|
38
|
+
|
39
|
+
# DESTROY
|
40
|
+
click_link "Destroy"
|
41
|
+
assert_equal '/houses', current_path
|
42
|
+
assert page.has_content?('No Houses')
|
43
|
+
end
|
44
|
+
|
45
|
+
test "Nested has_many CRUD" do
|
46
|
+
house = House.create!(name: 'Cat House', number: 666)
|
47
|
+
|
48
|
+
# INDEX
|
49
|
+
visit "/houses/#{house.id}/cats"
|
50
|
+
assert page.has_content?('No Cats')
|
51
|
+
|
52
|
+
# CREATE
|
53
|
+
click_link 'Create'
|
54
|
+
assert_equal "/houses/#{house.id}/cats/new", current_path
|
55
|
+
fill_in 'cat_name', with: "Sheldon"
|
56
|
+
click_button 'Create Cat'
|
57
|
+
|
58
|
+
# INDEX, again
|
59
|
+
assert_equal "/houses/#{house.id}/cats", current_path
|
60
|
+
assert page.has_content?('Cat House')
|
61
|
+
assert page.has_content?('Sheldon')
|
62
|
+
|
63
|
+
# SHOW
|
64
|
+
click_link 'Show'
|
65
|
+
assert_equal "/houses/#{house.id}/cats/#{house.cats.first.id}", current_path
|
66
|
+
assert page.has_content?('Sheldon')
|
67
|
+
assert page.has_content?('Cat House')
|
68
|
+
click_link 'Abort'
|
69
|
+
assert_equal "/houses/#{house.id}/cats", current_path
|
70
|
+
|
71
|
+
# EDIT
|
72
|
+
click_link 'Edit'
|
73
|
+
assert_equal "/houses/#{house.id}/cats/#{house.cats.first.id}/edit", current_path
|
74
|
+
fill_in 'cat_name', with: "Lennard"
|
75
|
+
click_button 'Update Cat'
|
76
|
+
|
77
|
+
# INDEX, again
|
78
|
+
assert !page.has_content?('Sheldon')
|
79
|
+
assert page.has_content?('Lennard')
|
80
|
+
|
81
|
+
# DESTROY
|
82
|
+
click_link "Destroy"
|
83
|
+
assert_equal "/houses/#{house.id}/cats", current_path
|
84
|
+
assert page.has_content?('No Cats')
|
85
|
+
|
86
|
+
%w{Moritz Klara Finka Willi}.each do |nam|
|
87
|
+
visit "/houses/#{house.id}/cats"
|
88
|
+
|
89
|
+
# CREATE
|
90
|
+
click_link 'Create'
|
91
|
+
assert_equal "/houses/#{house.id}/cats/new", current_path
|
92
|
+
fill_in 'cat_name', with: nam
|
93
|
+
click_button 'Create Cat'
|
94
|
+
|
95
|
+
# INDEX, again
|
96
|
+
assert_equal "/houses/#{house.id}/cats", current_path
|
97
|
+
assert page.has_content?('Cat House')
|
98
|
+
assert page.has_content?(nam)
|
99
|
+
end
|
100
|
+
|
101
|
+
house.cats.each do |cat|
|
102
|
+
visit "/houses/#{house.id}/cats/#{cat.id}/edit"
|
103
|
+
fill_in 'cat_name', with: "Moo#{cat.name}"
|
104
|
+
click_button 'Update Cat'
|
105
|
+
assert_equal "/houses/#{house.id}/cats", current_path
|
106
|
+
assert page.has_content?("Moo#{cat.name}")
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
test "Nested polymorphic has_many CRUD" do
|
111
|
+
house = House.create!(name: 'Dog House', number: 666)
|
112
|
+
|
113
|
+
# INDEX
|
114
|
+
visit "/houses/#{house.id}/dogs"
|
115
|
+
assert page.has_content?('No Dogs')
|
116
|
+
|
117
|
+
# CREATE
|
118
|
+
click_link 'Create'
|
119
|
+
assert_equal "/houses/#{house.id}/dogs/new", current_path
|
120
|
+
fill_in 'dog_name', with: "Waldi"
|
121
|
+
click_button 'Create Dog'
|
122
|
+
|
123
|
+
# INDEX, again
|
124
|
+
assert_equal "/houses/#{house.id}/dogs", current_path
|
125
|
+
assert page.has_content?('Dog House')
|
126
|
+
assert page.has_content?('Waldi')
|
127
|
+
|
128
|
+
# SHOW
|
129
|
+
click_link 'Show'
|
130
|
+
assert_equal "/houses/#{house.id}/dogs/#{house.dogs.first.id}", current_path
|
131
|
+
assert page.has_content?('Waldi')
|
132
|
+
assert page.has_content?('Dog House')
|
133
|
+
click_link 'Abort'
|
134
|
+
assert_equal "/houses/#{house.id}/edit", current_path
|
135
|
+
|
136
|
+
# EDIT
|
137
|
+
visit "/houses/#{house.id}/dogs"
|
138
|
+
click_link 'Edit'
|
139
|
+
assert_equal "/houses/#{house.id}/dogs/#{house.dogs.first.id}/edit", current_path
|
140
|
+
fill_in 'dog_name', with: "Fifi"
|
141
|
+
click_button 'Update Dog'
|
142
|
+
|
143
|
+
# INDEX, again
|
144
|
+
assert !page.has_content?('Waldi')
|
145
|
+
assert page.has_content?('Fifi')
|
146
|
+
|
147
|
+
# DESTROY
|
148
|
+
click_link "Destroy"
|
149
|
+
assert_equal "/houses/#{house.id}/dogs", current_path
|
150
|
+
assert page.has_content?('No Dogs')
|
151
|
+
|
152
|
+
%w{Wau Bello Hasso Brain}.each do |nam|
|
153
|
+
visit "/houses/#{house.id}/dogs"
|
154
|
+
|
155
|
+
# CREATE
|
156
|
+
click_link 'Create'
|
157
|
+
assert_equal "/houses/#{house.id}/dogs/new", current_path
|
158
|
+
fill_in 'dog_name', with: nam
|
159
|
+
click_button 'Create Dog'
|
160
|
+
|
161
|
+
# INDEX, again
|
162
|
+
assert_equal "/houses/#{house.id}/dogs", current_path
|
163
|
+
assert page.has_content?('Dog House')
|
164
|
+
assert page.has_content?(nam)
|
165
|
+
end
|
166
|
+
|
167
|
+
house.dogs.each do |dog|
|
168
|
+
visit "/houses/#{house.id}/dogs/#{dog.id}/edit"
|
169
|
+
fill_in 'dog_name', with: "Moo#{dog.name}"
|
170
|
+
click_button 'Update Dog'
|
171
|
+
assert_equal "/houses/#{house.id}/dogs", current_path
|
172
|
+
assert page.has_content?("Moo#{dog.name}")
|
173
|
+
end
|
174
|
+
|
175
|
+
# save_and_open_page
|
176
|
+
end
|
177
|
+
|
178
|
+
test "Double Nested has_many CRUD" do
|
179
|
+
house = House.create!(name: 'Cat House', number: 666)
|
180
|
+
cat = Cat.new(name: 'Mouw')
|
181
|
+
cat.house = house
|
182
|
+
cat.save!
|
183
|
+
|
184
|
+
prefix = "/houses/#{house.id}/cats/#{cat.id}"
|
185
|
+
|
186
|
+
# INDEX
|
187
|
+
visit "#{prefix}/parasites"
|
188
|
+
assert page.has_content?('No Parasites')
|
189
|
+
|
190
|
+
# CREATE
|
191
|
+
click_link 'Create'
|
192
|
+
assert_equal "#{prefix}/parasites/new", current_path
|
193
|
+
fill_in 'parasite_name', with: "Sucker"
|
194
|
+
click_button 'Create Parasite'
|
195
|
+
|
196
|
+
# INDEX, again
|
197
|
+
assert_equal "#{prefix}/parasites", current_path
|
198
|
+
assert page.has_content?('Cat House')
|
199
|
+
assert page.has_content?('Mouw')
|
200
|
+
assert page.has_content?('Sucker')
|
201
|
+
|
202
|
+
# SHOW
|
203
|
+
click_link 'Show'
|
204
|
+
assert_equal "#{prefix}/parasites/#{cat.parasites.first.id}", current_path
|
205
|
+
assert page.has_content?('Sucker')
|
206
|
+
assert page.has_content?('Mouw')
|
207
|
+
assert page.has_content?('Cat House')
|
208
|
+
click_link 'Abort'
|
209
|
+
assert_equal "#{prefix}/parasites", current_path
|
210
|
+
|
211
|
+
# EDIT
|
212
|
+
click_link 'Edit'
|
213
|
+
assert_equal "#{prefix}/parasites/#{cat.parasites.first.id}/edit", current_path
|
214
|
+
fill_in 'parasite_name', with: "Vampire"
|
215
|
+
click_button 'Update Parasite'
|
216
|
+
|
217
|
+
# INDEX, again
|
218
|
+
assert !page.has_content?('Sucker')
|
219
|
+
assert page.has_content?('Vampire')
|
220
|
+
|
221
|
+
# DESTROY
|
222
|
+
click_link "Destroy"
|
223
|
+
assert_equal "#{prefix}/parasites", current_path
|
224
|
+
assert page.has_content?('No Parasites')
|
225
|
+
|
226
|
+
%w{Moritz Klara Finka Willi}.each do |nam|
|
227
|
+
visit "#{prefix}/parasites"
|
228
|
+
|
229
|
+
# CREATE
|
230
|
+
click_link 'Create'
|
231
|
+
assert_equal "#{prefix}/parasites/new", current_path
|
232
|
+
fill_in 'parasite_name', with: nam
|
233
|
+
click_button 'Create Parasite'
|
234
|
+
|
235
|
+
# INDEX, again
|
236
|
+
assert_equal "#{prefix}/parasites", current_path
|
237
|
+
assert page.has_content?('Cat House')
|
238
|
+
assert page.has_content?(nam)
|
239
|
+
end
|
240
|
+
|
241
|
+
cat.parasites.each.with_index do |parasite, i|
|
242
|
+
visit "#{prefix}/parasites/#{parasite.id}/edit"
|
243
|
+
fill_in 'parasite_name', with: "Moo#{parasite.name}"
|
244
|
+
fill_in 'parasite_legs', with: 3*i+1
|
245
|
+
click_button 'Update Parasite'
|
246
|
+
assert_equal "#{prefix}/parasites", current_path
|
247
|
+
assert page.has_content?("Moo#{parasite.name}")
|
248
|
+
assert page.has_content?("#{3*i+1}")
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
252
|
+
|
253
|
+
end
|