ecm_sliders2 0.0.1
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.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +35 -0
- data/Rakefile +27 -0
- data/app/helpers/ecm/sliders_helper.rb +10 -0
- data/app/helpers/markup_helper.rb +7 -0
- data/app/models/ecm/sliders/item.rb +36 -0
- data/app/models/ecm/sliders/slider.rb +40 -0
- data/app/views/ecm/sliders/sliders/_slider.haml +3 -0
- data/config/locales/de.yml +52 -0
- data/config/locales/en.yml +52 -0
- data/config/routes.rb +6 -0
- data/db/migrate/001_create_ecm_sliders_sliders.rb +14 -0
- data/db/migrate/002_create_ecm_sliders_items.rb +14 -0
- data/lib/ecm/sliders/configuration.rb +23 -0
- data/lib/ecm/sliders/engine.rb +7 -0
- data/lib/ecm/sliders/routing.rb +14 -0
- data/lib/ecm/sliders/version.rb +6 -0
- data/lib/ecm_sliders2.rb +17 -0
- data/lib/generators/ecm/sliders/install/install_generator.rb +21 -0
- data/lib/generators/ecm/sliders/install/templates/initializer.rb +39 -0
- data/lib/generators/ecm/sliders/install/templates/routes.source +5 -0
- data/lib/tasks/ecm_sliders_tasks.rake +67 -0
- data/spec/controllers/ecm/sliders/sliders_controller_spec.rb +23 -0
- data/spec/dummy/README.rdoc +261 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/admin/admin_users.rb +20 -0
- data/spec/dummy/app/admin/dashboards.rb +33 -0
- data/spec/dummy/app/assets/javascripts/active_admin.js +1 -0
- data/spec/dummy/app/assets/javascripts/application.js +15 -0
- data/spec/dummy/app/assets/javascripts/bootstrap.min.js +6 -0
- data/spec/dummy/app/assets/stylesheets/active_admin.css.scss +29 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/assets/stylesheets/bootstrap.min.css +727 -0
- data/spec/dummy/app/assets/stylesheets/ecm.sliders.css +9 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +7 -0
- data/spec/dummy/app/models/admin_user.rb +11 -0
- data/spec/dummy/app/views/layouts/application.html.erb +37 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +69 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +37 -0
- data/spec/dummy/config/environments/production.rb +67 -0
- data/spec/dummy/config/environments/test.rb +37 -0
- data/spec/dummy/config/initializers/active_admin.rb +154 -0
- data/spec/dummy/config/initializers/active_admin_footer_patch.rb +12 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/devise.rb +232 -0
- data/spec/dummy/config/initializers/ecm_sliders.rb +39 -0
- data/spec/dummy/config/initializers/inflections.rb +15 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/de.yml +163 -0
- data/spec/dummy/config/locales/devise.en.yml +58 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +65 -0
- data/spec/dummy/db/migrate/20120922100801_create_ecm_sliders_sliders.ecm_sliders_engine.rb +20 -0
- data/spec/dummy/db/migrate/20120922100802_create_ecm_sliders_items.ecm_sliders_engine.rb +25 -0
- data/spec/dummy/db/migrate/20120922105221_devise_create_admin_users.rb +52 -0
- data/spec/dummy/db/migrate/20120922105247_create_admin_notes.rb +17 -0
- data/spec/dummy/db/migrate/20120922105248_move_admin_notes_to_comments.rb +25 -0
- data/spec/dummy/db/schema.rb +75 -0
- data/spec/dummy/lib/locale_generator.rb +194 -0
- data/spec/dummy/lib/tasks/stub_locales.rake +32 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +25 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/factories/ecm/sliders/items.rb +14 -0
- data/spec/factories/ecm/sliders/sliders.rb +10 -0
- data/spec/features/ecm/sliders/slider_items_admin_spec.rb +172 -0
- data/spec/features/ecm/sliders/sliders_admin_spec.rb +170 -0
- data/spec/files/ecm/sliders/items/example.png +0 -0
- data/spec/helpers/ecm/sliders_helper_spec.rb +36 -0
- data/spec/models/ecm/sliders/item_spec.rb +49 -0
- data/spec/models/ecm/sliders/slider_spec.rb +97 -0
- data/spec/models/generic_spec.rb +34 -0
- data/spec/requests/ecm/sliders/sliders_spec.rb +28 -0
- data/spec/routing/ecm/sliders/routes_spec.rb +11 -0
- data/spec/spec_helper.rb +38 -0
- data/spec/support/active_admin/sign_in_helper.rb +18 -0
- data/spec/support/capybara.rb +1 -0
- data/spec/support/factory_girl.rb +6 -0
- data/spec/support/ffaker.rb +1 -0
- data/spec/support/shoulda.rb +1 -0
- data/spec/views/ecm/sliders/sliders/index_spec.rb +20 -0
- metadata +344 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
require 'pp'
|
|
2
|
+
require 'locale_generator'
|
|
3
|
+
|
|
4
|
+
namespace :locales do
|
|
5
|
+
desc "Stubs out locale files for all active record descendants."
|
|
6
|
+
task :stub, [] => [:environment] do |t, args|
|
|
7
|
+
Rails.application.eager_load!
|
|
8
|
+
|
|
9
|
+
# Loop over all AR models
|
|
10
|
+
ActiveRecord::Base.descendants.each do |model|
|
|
11
|
+
# Loop over available locales
|
|
12
|
+
I18n.available_locales.each do |locale|
|
|
13
|
+
p "Generating locale files for #{locale}"
|
|
14
|
+
g = LocaleGenerator.new(model, locale)
|
|
15
|
+
if g.load_file
|
|
16
|
+
p " -> Loaded locale file for #{model}:#{locale.to_s}"
|
|
17
|
+
if g.has_new_attribute_keys
|
|
18
|
+
p " -> Adding keys: #{g.new_keys.join(", ")}"
|
|
19
|
+
end
|
|
20
|
+
else
|
|
21
|
+
p " -> Creating new locale file for #{model}:#{locale.to_s}"
|
|
22
|
+
end
|
|
23
|
+
if g.save_file
|
|
24
|
+
p " -> Saved #{g.filename}"
|
|
25
|
+
else
|
|
26
|
+
p " -> Error saving #{g.filename}"
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
@@ -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,14 @@
|
|
|
1
|
+
FactoryGirl.define do
|
|
2
|
+
factory :ecm_sliders_item, class: Ecm::Sliders::Item do
|
|
3
|
+
association :slider, factory: :ecm_sliders_slider
|
|
4
|
+
markup_language 'textile'
|
|
5
|
+
after(:build) { |f|
|
|
6
|
+
f.image.attach(
|
|
7
|
+
io: File.open(File.join(Ecm::Sliders::Engine.root.join(*%w( spec files ecm sliders items example.png)))),
|
|
8
|
+
filename: 'example.png',
|
|
9
|
+
content_type: 'image/png'
|
|
10
|
+
)
|
|
11
|
+
}
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
FactoryGirl.define do
|
|
2
|
+
factory :ecm_sliders_slider, :class => Ecm::Sliders::Slider do
|
|
3
|
+
sequence(:name) { |i| "Slider ##{i}" }
|
|
4
|
+
|
|
5
|
+
factory :ecm_sliders_slider_with_items do |slider|
|
|
6
|
+
slider.after_create { |s| FactoryGirl.create_list(:ecm_sliders_item, 5, ecm_sliders_slider: s) }
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
feature 'Ecm::Sliders::Item admin' do
|
|
4
|
+
include ActiveAdmin::SignInHelper
|
|
5
|
+
|
|
6
|
+
def set_locale
|
|
7
|
+
I18n.locale = :de
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def set_admin_area_path
|
|
11
|
+
@admin_area_path = "/admin"
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def set_resource_path
|
|
15
|
+
@resource_path = "ecm_sliders_items"
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def set_resource_class
|
|
19
|
+
@resource_class = Ecm::Sliders::Item
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def set_resource_factory_name
|
|
23
|
+
@resource_factory_name = @resource_class.to_s.underscore.gsub('/', '_').to_sym
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def set_index_check_column
|
|
27
|
+
@index_check_column = :body
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def prepare_for_new
|
|
31
|
+
@slider = FactoryGirl.create(:ecm_sliders_slider)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def fill_new_form
|
|
35
|
+
select @slider.name, :from => 'ecm_sliders_item[ecm_sliders_slider_id]'
|
|
36
|
+
select 'textile', :from => 'ecm_sliders_item[markup_language]'
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def fill_edit_form
|
|
40
|
+
fill_in "ecm_sliders_item[body]", :with => "An updated slider"
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
background do
|
|
44
|
+
admin_user = FactoryGirl.create(:admin_user)
|
|
45
|
+
sign_in_with(admin_user.email, admin_user.password)
|
|
46
|
+
|
|
47
|
+
set_locale
|
|
48
|
+
set_admin_area_path
|
|
49
|
+
set_resource_class
|
|
50
|
+
set_resource_path
|
|
51
|
+
set_resource_factory_name
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
describe 'new' do
|
|
55
|
+
background do
|
|
56
|
+
@resource_count = @resource_class.count
|
|
57
|
+
prepare_for_new
|
|
58
|
+
visit "#{@admin_area_path}/#{@resource_path}/new"
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
scenario 'should be visitable' do
|
|
62
|
+
page.current_path.should eq("#{@admin_area_path}/#{@resource_path}/new")
|
|
63
|
+
end # scenario
|
|
64
|
+
|
|
65
|
+
scenario 'should have the status code 200' do
|
|
66
|
+
page.status_code.should eq(200)
|
|
67
|
+
end # scenario
|
|
68
|
+
|
|
69
|
+
describe 'when filling the form correctly' do
|
|
70
|
+
background do
|
|
71
|
+
fill_new_form
|
|
72
|
+
find(:xpath, '//input[@type="submit"]').click
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
scenario 'should have created a record' do
|
|
76
|
+
@resource_class.count.should eq(@resource_count + 1)
|
|
77
|
+
end # scenario
|
|
78
|
+
|
|
79
|
+
scenario 'should have the status code 200' do
|
|
80
|
+
page.status_code.should eq(200)
|
|
81
|
+
end # scenario
|
|
82
|
+
end # describe 'when filling the form correctly'
|
|
83
|
+
end # describe 'new'
|
|
84
|
+
|
|
85
|
+
describe 'show' do
|
|
86
|
+
background do
|
|
87
|
+
@resource = FactoryGirl.create(@resource_factory_name)
|
|
88
|
+
visit "#{@admin_area_path}/#{@resource_path}/#{@resource.to_param}"
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
scenario 'should have the status code 200' do
|
|
92
|
+
page.status_code.should eq(200)
|
|
93
|
+
end # scenario
|
|
94
|
+
end # describe 'show'
|
|
95
|
+
|
|
96
|
+
describe 'edit' do
|
|
97
|
+
background do
|
|
98
|
+
@resource = FactoryGirl.create(@resource_factory_name)
|
|
99
|
+
visit "#{@admin_area_path}/#{@resource_path}/#{@resource.to_param}/edit"
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
scenario 'should be visitable' do
|
|
103
|
+
page.current_path.should eq("#{@admin_area_path}/#{@resource_path}/#{@resource.to_param}/edit")
|
|
104
|
+
end # scenario
|
|
105
|
+
|
|
106
|
+
scenario 'should have the status code 200' do
|
|
107
|
+
page.status_code.should eq(200)
|
|
108
|
+
end # scenario
|
|
109
|
+
|
|
110
|
+
describe 'when filling the form correctly' do
|
|
111
|
+
background do
|
|
112
|
+
@resource_count = @resource_class.count
|
|
113
|
+
fill_edit_form
|
|
114
|
+
find(:xpath, '//input[@type="submit"]').click
|
|
115
|
+
@resource.reload
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
scenario 'should not have created a record' do
|
|
119
|
+
@resource_class.count.should eq(@resource_count)
|
|
120
|
+
end # scenario
|
|
121
|
+
|
|
122
|
+
scenario 'should have the status code 200' do
|
|
123
|
+
page.status_code.should eq(200)
|
|
124
|
+
end # scenario
|
|
125
|
+
|
|
126
|
+
scenario 'should redirect to the resource show page' do
|
|
127
|
+
page.current_path.should eq("#{@admin_area_path}/#{@resource_path}/#{@resource.to_param}")
|
|
128
|
+
end # scenario
|
|
129
|
+
end # describe 'when filling the form correctly'
|
|
130
|
+
|
|
131
|
+
end # describe 'edit'
|
|
132
|
+
|
|
133
|
+
describe 'delete' do
|
|
134
|
+
background do
|
|
135
|
+
@resource = FactoryGirl.create(@resource_factory_name)
|
|
136
|
+
@resource_count = @resource_class.count
|
|
137
|
+
visit "#{@admin_area_path}/#{@resource_path}/#{@resource.to_param}"
|
|
138
|
+
find(:xpath, "//a[@href='#{@admin_area_path}/#{@resource_path}/#{@resource.to_param}' and @data-method='delete']").click
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
scenario 'should delete the resource' do
|
|
142
|
+
@resource_class.count.should eq(@resource_count - 1)
|
|
143
|
+
end # scenario
|
|
144
|
+
|
|
145
|
+
scenario 'should redirect to the resource index page' do
|
|
146
|
+
page.current_path.should eq("#{@admin_area_path}/#{@resource_path}")
|
|
147
|
+
end # scenario
|
|
148
|
+
end # describe 'delete'
|
|
149
|
+
|
|
150
|
+
describe 'index' do
|
|
151
|
+
background do
|
|
152
|
+
set_index_check_column
|
|
153
|
+
@resources = FactoryGirl.create_list(@resource_factory_name, 3)
|
|
154
|
+
visit "#{@admin_area_path}/#{@resource_path}"
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
scenario 'should be visitable' do
|
|
158
|
+
page.current_path.should eq("#{@admin_area_path}/#{@resource_path}")
|
|
159
|
+
end # scenario
|
|
160
|
+
|
|
161
|
+
scenario 'should have the status code 200' do
|
|
162
|
+
page.status_code.should eq(200)
|
|
163
|
+
end # scenario
|
|
164
|
+
|
|
165
|
+
scenario "should show the resources" do
|
|
166
|
+
@resources.each do |resource|
|
|
167
|
+
page.body.should include(resource.send(@index_check_column.to_sym))
|
|
168
|
+
end
|
|
169
|
+
end # scenario
|
|
170
|
+
end # describe 'index'
|
|
171
|
+
end # feature
|
|
172
|
+
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
feature 'Ecm::Sliders::Slider admin' do
|
|
4
|
+
include ActiveAdmin::SignInHelper
|
|
5
|
+
|
|
6
|
+
def set_locale
|
|
7
|
+
I18n.locale = :de
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def set_admin_area_path
|
|
11
|
+
@admin_area_path = "/admin"
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def set_resource_path
|
|
15
|
+
@resource_path = "ecm_sliders_sliders"
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def set_resource_class
|
|
19
|
+
@resource_class = Ecm::Sliders::Slider
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def set_resource_factory_name
|
|
23
|
+
@resource_factory_name = @resource_class.to_s.underscore.gsub('/', '_').to_sym
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def set_index_check_column
|
|
27
|
+
@index_check_column = :name
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def prepare_for_new
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def fill_new_form
|
|
34
|
+
fill_in "ecm_sliders_slider[name]", :with => "Example slider"
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def fill_edit_form
|
|
38
|
+
fill_in "ecm_sliders_slider[name]", :with => "An updated slider"
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
background do
|
|
42
|
+
admin_user = FactoryGirl.create(:admin_user)
|
|
43
|
+
sign_in_with(admin_user.email, admin_user.password)
|
|
44
|
+
|
|
45
|
+
set_locale
|
|
46
|
+
set_admin_area_path
|
|
47
|
+
set_resource_class
|
|
48
|
+
set_resource_path
|
|
49
|
+
set_resource_factory_name
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
describe 'new' do
|
|
53
|
+
background do
|
|
54
|
+
@resource_count = @resource_class.count
|
|
55
|
+
prepare_for_new
|
|
56
|
+
visit "#{@admin_area_path}/#{@resource_path}/new"
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
scenario 'should be visitable' do
|
|
60
|
+
page.current_path.should eq("#{@admin_area_path}/#{@resource_path}/new")
|
|
61
|
+
end # scenario
|
|
62
|
+
|
|
63
|
+
scenario 'should have the status code 200' do
|
|
64
|
+
page.status_code.should eq(200)
|
|
65
|
+
end # scenario
|
|
66
|
+
|
|
67
|
+
describe 'when filling the form correctly' do
|
|
68
|
+
background do
|
|
69
|
+
fill_new_form
|
|
70
|
+
find(:xpath, '//input[@type="submit"]').click
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
scenario 'should have created a record' do
|
|
74
|
+
@resource_class.count.should eq(@resource_count + 1)
|
|
75
|
+
end # scenario
|
|
76
|
+
|
|
77
|
+
scenario 'should have the status code 200' do
|
|
78
|
+
page.status_code.should eq(200)
|
|
79
|
+
end # scenario
|
|
80
|
+
end # describe 'when filling the form correctly'
|
|
81
|
+
end # describe 'new'
|
|
82
|
+
|
|
83
|
+
describe 'show' do
|
|
84
|
+
background do
|
|
85
|
+
@resource = FactoryGirl.create(@resource_factory_name)
|
|
86
|
+
visit "#{@admin_area_path}/#{@resource_path}/#{@resource.to_param}"
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
scenario 'should have the status code 200' do
|
|
90
|
+
page.status_code.should eq(200)
|
|
91
|
+
end # scenario
|
|
92
|
+
end # describe 'show'
|
|
93
|
+
|
|
94
|
+
describe 'edit' do
|
|
95
|
+
background do
|
|
96
|
+
@resource = FactoryGirl.create(@resource_factory_name)
|
|
97
|
+
visit "#{@admin_area_path}/#{@resource_path}/#{@resource.to_param}/edit"
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
scenario 'should be visitable' do
|
|
101
|
+
page.current_path.should eq("#{@admin_area_path}/#{@resource_path}/#{@resource.to_param}/edit")
|
|
102
|
+
end # scenario
|
|
103
|
+
|
|
104
|
+
scenario 'should have the status code 200' do
|
|
105
|
+
page.status_code.should eq(200)
|
|
106
|
+
end # scenario
|
|
107
|
+
|
|
108
|
+
describe 'when filling the form correctly' do
|
|
109
|
+
background do
|
|
110
|
+
@resource_count = @resource_class.count
|
|
111
|
+
fill_edit_form
|
|
112
|
+
find(:xpath, '//input[@type="submit"]').click
|
|
113
|
+
@resource.reload
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
scenario 'should not have created a record' do
|
|
117
|
+
@resource_class.count.should eq(@resource_count)
|
|
118
|
+
end # scenario
|
|
119
|
+
|
|
120
|
+
scenario 'should have the status code 200' do
|
|
121
|
+
page.status_code.should eq(200)
|
|
122
|
+
end # scenario
|
|
123
|
+
|
|
124
|
+
scenario 'should redirect to the resource show page' do
|
|
125
|
+
page.current_path.should eq("#{@admin_area_path}/#{@resource_path}/#{@resource.to_param}")
|
|
126
|
+
end # scenario
|
|
127
|
+
end # describe 'when filling the form correctly'
|
|
128
|
+
|
|
129
|
+
end # describe 'edit'
|
|
130
|
+
|
|
131
|
+
describe 'delete' do
|
|
132
|
+
background do
|
|
133
|
+
@resource = FactoryGirl.create(@resource_factory_name)
|
|
134
|
+
@resource_count = @resource_class.count
|
|
135
|
+
visit "#{@admin_area_path}/#{@resource_path}/#{@resource.to_param}"
|
|
136
|
+
find(:xpath, "//a[@href='#{@admin_area_path}/#{@resource_path}/#{@resource.to_param}' and @data-method='delete']").click
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
scenario 'should delete the resource' do
|
|
140
|
+
@resource_class.count.should eq(@resource_count - 1)
|
|
141
|
+
end # scenario
|
|
142
|
+
|
|
143
|
+
scenario 'should redirect to the resource index page' do
|
|
144
|
+
page.current_path.should eq("#{@admin_area_path}/#{@resource_path}")
|
|
145
|
+
end # scenario
|
|
146
|
+
end # describe 'delete'
|
|
147
|
+
|
|
148
|
+
describe 'index' do
|
|
149
|
+
background do
|
|
150
|
+
set_index_check_column
|
|
151
|
+
@resources = FactoryGirl.create_list(@resource_factory_name, 3)
|
|
152
|
+
visit "#{@admin_area_path}/#{@resource_path}"
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
scenario 'should be visitable' do
|
|
156
|
+
page.current_path.should eq("#{@admin_area_path}/#{@resource_path}")
|
|
157
|
+
end # scenario
|
|
158
|
+
|
|
159
|
+
scenario 'should have the status code 200' do
|
|
160
|
+
page.status_code.should eq(200)
|
|
161
|
+
end # scenario
|
|
162
|
+
|
|
163
|
+
scenario "should show the resources" do
|
|
164
|
+
@resources.each do |resource|
|
|
165
|
+
page.body.should include(resource.send(@index_check_column.to_sym))
|
|
166
|
+
end
|
|
167
|
+
end # scenario
|
|
168
|
+
end # describe 'index'
|
|
169
|
+
end # feature
|
|
170
|
+
|