engine_room 0.5.0
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.
- data/.gitignore +10 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +159 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +44 -0
- data/Rakefile +30 -0
- data/TODO +3 -0
- data/app/controllers/engine_room/content_controller.rb +117 -0
- data/app/controllers/engine_room/fields_controller.rb +119 -0
- data/app/controllers/engine_room/models_controller.rb +89 -0
- data/app/controllers/engine_room/pages_controller.rb +17 -0
- data/app/controllers/engine_room/sections_controller.rb +74 -0
- data/app/controllers/engine_room/users_controller.rb +84 -0
- data/app/controllers/er_devise/passwords_controller.rb +6 -0
- data/app/controllers/er_devise/registrations_controller.rb +8 -0
- data/app/controllers/er_devise/sessions_controller.rb +6 -0
- data/app/helpers/engine_room/content_helper.rb +103 -0
- data/app/helpers/engine_room/models_helper.rb +21 -0
- data/app/models/field.rb +89 -0
- data/app/models/section.rb +68 -0
- data/app/models/user.rb +31 -0
- data/app/views/engine_room/content/_form.html.erb +13 -0
- data/app/views/engine_room/content/_overview.html.erb +28 -0
- data/app/views/engine_room/content/_sidebar.html.erb +14 -0
- data/app/views/engine_room/content/edit.html.erb +38 -0
- data/app/views/engine_room/content/index.html.erb +1 -0
- data/app/views/engine_room/content/new.html.erb +1 -0
- data/app/views/engine_room/content/overview.html.erb +3 -0
- data/app/views/engine_room/fields/_form.html.erb +57 -0
- data/app/views/engine_room/fields/edit.html.erb +1 -0
- data/app/views/engine_room/fields/new.html.erb +1 -0
- data/app/views/engine_room/models/_form.html.erb +0 -0
- data/app/views/engine_room/models/edit.html.erb +14 -0
- data/app/views/engine_room/models/index.html.erb +16 -0
- data/app/views/engine_room/models/new.html.erb +14 -0
- data/app/views/engine_room/models/overview.html.erb +14 -0
- data/app/views/engine_room/pages/dashboard.html.erb +1 -0
- data/app/views/engine_room/pages/settings.html.erb +1 -0
- data/app/views/engine_room/sections/_form.html.erb +34 -0
- data/app/views/engine_room/sections/_sidebar.html.erb +11 -0
- data/app/views/engine_room/sections/edit.html.erb +81 -0
- data/app/views/engine_room/sections/index.html.erb +3 -0
- data/app/views/engine_room/sections/new.html.erb +1 -0
- data/app/views/engine_room/users/_form.html.erb +47 -0
- data/app/views/engine_room/users/edit.html.erb +11 -0
- data/app/views/engine_room/users/index.html.erb +24 -0
- data/app/views/engine_room/users/new.html.erb +1 -0
- data/app/views/er_devise/mailer/confirmation_instructions.html.erb +5 -0
- data/app/views/er_devise/mailer/reset_password_instructions.html.erb +8 -0
- data/app/views/er_devise/mailer/unlock_instructions.html.erb +7 -0
- data/app/views/er_devise/passwords/edit.html.erb +16 -0
- data/app/views/er_devise/passwords/new.html.erb +13 -0
- data/app/views/er_devise/registrations/edit.html.erb +42 -0
- data/app/views/er_devise/registrations/new.html.erb +21 -0
- data/app/views/er_devise/sessions/new.html.erb +23 -0
- data/app/views/er_devise/shared/_links.erb +19 -0
- data/app/views/layouts/engine_room.html.erb +103 -0
- data/app/views/layouts/login.html.erb +71 -0
- data/app/views/shared/_content_layout_selector.html.erb +45 -0
- data/app/views/shared/_error_messages.html.erb +17 -0
- data/config/initializers/devise.rb +146 -0
- data/config/initializers/locale.rb +5 -0
- data/config/locales/devise.de.yml +42 -0
- data/config/locales/devise.en.yml +39 -0
- data/config/locales/engine_room.de.yml +33 -0
- data/config/locales/engine_room.en.yml +42 -0
- data/config/routes.rb +62 -0
- data/engine_room.gemspec +35 -0
- data/lib/engine_room.rb +17 -0
- data/lib/engine_room/action_controller/controller_methods.rb +21 -0
- data/lib/engine_room/action_view/view_methods.rb +8 -0
- data/lib/engine_room/active_record/record_methods.rb +18 -0
- data/lib/engine_room/crummy/custom_renderer.rb +63 -0
- data/lib/engine_room/engine.rb +40 -0
- data/lib/engine_room/railties/tasks.rake +6 -0
- data/lib/engine_room/version.rb +3 -0
- data/lib/generators/engine_room/create_image_generator.rb +26 -0
- data/lib/generators/engine_room/setup_generator.rb +30 -0
- data/lib/generators/engine_room/templates/001_devise_create_users.rb +28 -0
- data/lib/generators/engine_room/templates/002_create_sections.rb +16 -0
- data/lib/generators/engine_room/templates/003_create_fields.rb +18 -0
- data/lib/generators/engine_room/templates/004_create_images.rb +19 -0
- data/lib/generators/engine_room/templates/image.rb +4 -0
- data/lib/tasks/dummy.rake +45 -0
- data/lib/tasks/templates/migrate/050_create_dogs.rb +18 -0
- data/lib/tasks/templates/models/dog.rb +3 -0
- data/public/images/er/accept.png +0 -0
- data/public/images/er/add.png +0 -0
- data/public/images/er/add_small.png +0 -0
- data/public/images/er/ajax-loader.gif +0 -0
- data/public/images/er/attach.png +0 -0
- data/public/images/er/back_disabled.jpg +0 -0
- data/public/images/er/back_enabled.jpg +0 -0
- data/public/images/er/bg/header_gradient_center.jpg +0 -0
- data/public/images/er/bg/header_gradient_left.jpg +0 -0
- data/public/images/er/bg/header_gradient_right.jpg +0 -0
- data/public/images/er/cancel.png +0 -0
- data/public/images/er/cog.png +0 -0
- data/public/images/er/database_add.png +0 -0
- data/public/images/er/delete.png +0 -0
- data/public/images/er/delete_small.png +0 -0
- data/public/images/er/down_arrow.gif +0 -0
- data/public/images/er/down_arrow.png +0 -0
- data/public/images/er/email.png +0 -0
- data/public/images/er/exclamation.png +0 -0
- data/public/images/er/forward_disabled.jpg +0 -0
- data/public/images/er/forward_enabled.jpg +0 -0
- data/public/images/er/help.png +0 -0
- data/public/images/er/image_add.png +0 -0
- data/public/images/er/information.png +0 -0
- data/public/images/er/link.png +0 -0
- data/public/images/er/loader.gif +0 -0
- data/public/images/er/telephone.png +0 -0
- data/public/images/er/up_arrow.gif +0 -0
- data/public/images/er/up_arrow.png +0 -0
- data/public/images/er/user.png +0 -0
- data/public/images/er/wrench.png +0 -0
- data/public/images/er/zoom.png +0 -0
- data/public/javascripts/er/dd_belatedpng.js +328 -0
- data/public/javascripts/er/fancybox/blank.gif +0 -0
- data/public/javascripts/er/fancybox/fancy_close.png +0 -0
- data/public/javascripts/er/fancybox/fancy_loading.png +0 -0
- data/public/javascripts/er/fancybox/fancy_nav_left.png +0 -0
- data/public/javascripts/er/fancybox/fancy_nav_right.png +0 -0
- data/public/javascripts/er/fancybox/fancy_shadow_e.png +0 -0
- data/public/javascripts/er/fancybox/fancy_shadow_n.png +0 -0
- data/public/javascripts/er/fancybox/fancy_shadow_ne.png +0 -0
- data/public/javascripts/er/fancybox/fancy_shadow_nw.png +0 -0
- data/public/javascripts/er/fancybox/fancy_shadow_s.png +0 -0
- data/public/javascripts/er/fancybox/fancy_shadow_se.png +0 -0
- data/public/javascripts/er/fancybox/fancy_shadow_sw.png +0 -0
- data/public/javascripts/er/fancybox/fancy_shadow_w.png +0 -0
- data/public/javascripts/er/fancybox/fancy_title_left.png +0 -0
- data/public/javascripts/er/fancybox/fancy_title_main.png +0 -0
- data/public/javascripts/er/fancybox/fancy_title_over.png +0 -0
- data/public/javascripts/er/fancybox/fancy_title_right.png +0 -0
- data/public/javascripts/er/fancybox/fancybox-x.png +0 -0
- data/public/javascripts/er/fancybox/fancybox-y.png +0 -0
- data/public/javascripts/er/fancybox/fancybox.png +0 -0
- data/public/javascripts/er/fancybox/jquery.fancybox-1.3.4.css +359 -0
- data/public/javascripts/er/fancybox/jquery.fancybox-1.3.4.pack.js +46 -0
- data/public/javascripts/er/jquery-1.4.4.min.js +167 -0
- data/public/javascripts/er/jquery-ui-1.8.6.custom.min.js +477 -0
- data/public/javascripts/er/modernizr-1.5.min.js +28 -0
- data/public/javascripts/er/plugins.js +48 -0
- data/public/javascripts/er/rails.js +156 -0
- data/public/javascripts/er/script.js +50 -0
- data/public/stylesheets/.gitkeep +0 -0
- data/public/stylesheets/admin.css +417 -0
- data/public/stylesheets/boilerplate.css +264 -0
- data/public/stylesheets/handheld.css +7 -0
- data/public/stylesheets/login.css +125 -0
- data/public/stylesheets/skin.css +2 -0
- data/public/stylesheets/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/public/stylesheets/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/public/stylesheets/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/public/stylesheets/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/public/stylesheets/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/public/stylesheets/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/public/stylesheets/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/public/stylesheets/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/public/stylesheets/smoothness/images/ui-icons_222222_256x240.png +0 -0
- data/public/stylesheets/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- data/public/stylesheets/smoothness/images/ui-icons_454545_256x240.png +0 -0
- data/public/stylesheets/smoothness/images/ui-icons_888888_256x240.png +0 -0
- data/public/stylesheets/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/public/stylesheets/smoothness/jquery-ui-1.8.6.custom.css +479 -0
- data/spec/controllers/content_controller_spec.rb +132 -0
- data/spec/controllers/fields_controller_spec.rb +103 -0
- data/spec/controllers/models_controller_spec.rb +65 -0
- data/spec/controllers/pages_controller_spec.rb +40 -0
- data/spec/controllers/sections_controller_spec.rb +124 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +45 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +22 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +26 -0
- data/spec/dummy/config/environments/production.rb +49 -0
- data/spec/dummy/config/environments/test.rb +35 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +10 -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/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +58 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +26 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/javascripts/application.js +2 -0
- data/spec/dummy/public/javascripts/controls.js +965 -0
- data/spec/dummy/public/javascripts/dragdrop.js +974 -0
- data/spec/dummy/public/javascripts/effects.js +1123 -0
- data/spec/dummy/public/javascripts/prototype.js +6001 -0
- data/spec/dummy/public/javascripts/rails.js +175 -0
- data/spec/dummy/public/stylesheets/.gitkeep +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/engine_room_spec.rb +7 -0
- data/spec/factories.rb +32 -0
- data/spec/integration/navigation_spec.rb +9 -0
- data/spec/models/dog_spec.rb +14 -0
- data/spec/models/field_spec.rb +74 -0
- data/spec/models/section_spec.rb +70 -0
- data/spec/models/user_spec.rb +77 -0
- data/spec/routing/models_routing_spec.rb +66 -0
- data/spec/spec_helper.rb +39 -0
- data/spec/support/devise.rb +3 -0
- metadata +492 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'factories'
|
|
3
|
+
|
|
4
|
+
describe EngineRoom::ContentController do
|
|
5
|
+
render_views
|
|
6
|
+
|
|
7
|
+
describe "access control when not signed in" do
|
|
8
|
+
|
|
9
|
+
before(:each) do
|
|
10
|
+
@section = Factory(:section)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it "should deny access to 'index'" do
|
|
14
|
+
get :index, :section_name => @section.name
|
|
15
|
+
response.should redirect_to(new_er_devise_user_session_path)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "should deny access to 'create'" do
|
|
19
|
+
@attr = { :name => "Fifi" }
|
|
20
|
+
post :create, :section_name => @section.name, :dog => @attr
|
|
21
|
+
response.should redirect_to(new_er_devise_user_session_path)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it "should deny access to 'delete'" do
|
|
25
|
+
dog = Factory(:dog)
|
|
26
|
+
delete :destroy, :section_name => @section.name, :id => dog
|
|
27
|
+
response.should redirect_to(new_er_devise_user_session_path)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
describe "GET 'index'" do
|
|
32
|
+
|
|
33
|
+
before(:each) do
|
|
34
|
+
sign_in Factory(:user)
|
|
35
|
+
@section = Factory(:section)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it "should be successful" do
|
|
39
|
+
get :index, :section_name => @section.name
|
|
40
|
+
response.should be_success
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
it "should redirect to overview for invalid section name" do
|
|
44
|
+
get :index, :section_name => "NoName"
|
|
45
|
+
response.should redirect_to({:controller => "content", :action => :overview})
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
describe "GET 'edit'" do
|
|
50
|
+
|
|
51
|
+
before(:each) do
|
|
52
|
+
sign_in Factory(:user)
|
|
53
|
+
@section = Factory(:section)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
it "should render the edit page" do
|
|
57
|
+
dog = Factory(:dog)
|
|
58
|
+
get :edit, :section_name => @section.name, :id => dog.id
|
|
59
|
+
response.should render_template('engine_room/content/edit')
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
describe "POST 'create'" do
|
|
64
|
+
|
|
65
|
+
before(:each) do
|
|
66
|
+
sign_in Factory(:user)
|
|
67
|
+
@section = Factory(:section)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
describe "failure" do
|
|
71
|
+
|
|
72
|
+
before(:each) do
|
|
73
|
+
@attr = { :name => "" }
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
it "should not create a dog with invalid attributes" do
|
|
77
|
+
lambda do
|
|
78
|
+
post :create, :section_name => @section.name, :dog => @attr
|
|
79
|
+
end.should_not change(Dog, :count)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
it "should render the new page" do
|
|
83
|
+
post :create, :section_name => @section.name, :dog => @attr
|
|
84
|
+
response.should render_template('engine_room/content/new')
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
describe "success" do
|
|
89
|
+
|
|
90
|
+
before(:each) do
|
|
91
|
+
@attr = { :name => "Fifi", :color => "black", :fleas => 2 }
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
it "should create a dog" do
|
|
95
|
+
lambda do
|
|
96
|
+
post :create, :section_name => @section.name, :dog => @attr
|
|
97
|
+
end.should change(Dog, :count).by(1)
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
it "should redirect to the index page" do
|
|
101
|
+
post :create, :section_name => @section.name, :dog => @attr
|
|
102
|
+
response.should redirect_to({:controller => "content", :action => :index, :section_name => @section.name})
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
it "should have a flash message" do
|
|
106
|
+
post :create, :section_name => @section.name, :dog => @attr
|
|
107
|
+
flash[:notice].should =~ /successfully created/i
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
describe "DELETE 'destroy'" do
|
|
113
|
+
|
|
114
|
+
before(:each) do
|
|
115
|
+
sign_in(Factory(:user))
|
|
116
|
+
@section = Factory(:section)
|
|
117
|
+
@dog = Factory(:dog)
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
it "should destroy the dog" do
|
|
121
|
+
lambda do
|
|
122
|
+
delete :destroy, :section_name => @section.name, :id => @dog
|
|
123
|
+
end.should change(Dog, :count).by(-1)
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
it "should redirect to the index page" do
|
|
127
|
+
post :destroy, :section_name => @section.name, :id => @dog
|
|
128
|
+
response.should redirect_to({:controller => "content", :action => :index, :section_name => @section.name})
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'factories'
|
|
3
|
+
|
|
4
|
+
describe EngineRoom::FieldsController do
|
|
5
|
+
render_views
|
|
6
|
+
|
|
7
|
+
describe "access control when not signed in" do
|
|
8
|
+
|
|
9
|
+
it "should deny access to 'index'" do
|
|
10
|
+
get :index, :section_id => 1
|
|
11
|
+
response.should redirect_to(new_er_devise_user_session_path)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it "should deny access to 'create'" do
|
|
15
|
+
@section = Factory(:section)
|
|
16
|
+
@attr = { :column => "name", :field_type => "text_field", :section_id => @section.id }
|
|
17
|
+
post :create, :section_id => @section, :field => @attr
|
|
18
|
+
response.should redirect_to(new_er_devise_user_session_path)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it "should deny access to 'delete'" do
|
|
22
|
+
@field = Factory(:field)
|
|
23
|
+
delete :destroy, :section_id => 1, :id => @field
|
|
24
|
+
response.should redirect_to(new_er_devise_user_session_path)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
describe "POST 'create'" do
|
|
29
|
+
|
|
30
|
+
before(:each) do
|
|
31
|
+
sign_in Factory(:user)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
describe "failure" do
|
|
35
|
+
|
|
36
|
+
before(:each) do
|
|
37
|
+
@section = Factory(:section)
|
|
38
|
+
@attr = { :column => "", :field_type => "" }
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it "should not create a field" do
|
|
42
|
+
lambda do
|
|
43
|
+
post :create, :section_id => @section, :field => @attr
|
|
44
|
+
end.should_not change(Field, :count)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it "should not create field for empty column" do
|
|
48
|
+
lambda do
|
|
49
|
+
post :create, :section_id => @section, :field => @attr.merge(:field_type => "boolean")
|
|
50
|
+
end.should_not change(Field, :count)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it "should render the new page" do
|
|
54
|
+
post :create, :section_id => @section, :field => @attr
|
|
55
|
+
response.should render_template('engine_room/fields/new')
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
describe "success" do
|
|
60
|
+
|
|
61
|
+
before(:each) do
|
|
62
|
+
@section = Factory(:section)
|
|
63
|
+
@attr = { :column => "name", :field_type => "text_field", :display_type => "detail", :section_id => @section.id }
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
it "should create a field" do
|
|
67
|
+
lambda do
|
|
68
|
+
post :create, :section_id => @section, :field => @attr
|
|
69
|
+
end.should change(Field, :count).by(1)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
it "should redirect to the index page" do
|
|
73
|
+
post :create, :section_id => @section, :field => @attr
|
|
74
|
+
response.should redirect_to(edit_engine_room_section_path(@section.id))
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
it "should have a flash message" do
|
|
78
|
+
post :create, :section_id => @section, :field => @attr
|
|
79
|
+
flash[:notice].should =~ /successfully created/i
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
describe "DELETE 'destroy'" do
|
|
85
|
+
|
|
86
|
+
before(:each) do
|
|
87
|
+
sign_in(Factory(:user))
|
|
88
|
+
@section = Factory(:section)
|
|
89
|
+
@field = Factory(:field, :section => @section)
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
it "should destroy the field" do
|
|
93
|
+
lambda do
|
|
94
|
+
delete :destroy, :section_id => @section, :id => @field
|
|
95
|
+
end.should change(Field, :count).by(-1)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
it "should redirect to the index page" do
|
|
99
|
+
post :destroy, :section_id => @section, :id => @field
|
|
100
|
+
response.should redirect_to(edit_engine_room_section_path(@section.id))
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe EngineRoom::ModelsController do
|
|
4
|
+
render_views
|
|
5
|
+
|
|
6
|
+
describe "GET 'overview'" do
|
|
7
|
+
|
|
8
|
+
describe "when not signed in" do
|
|
9
|
+
|
|
10
|
+
before(:each) do
|
|
11
|
+
get :overview
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it "should not be successful" do
|
|
15
|
+
response.should_not be_success
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "should redirect to login page" do
|
|
19
|
+
response.should redirect_to(new_er_devise_user_session_path)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
describe "when signed in" do
|
|
24
|
+
|
|
25
|
+
before(:each) do
|
|
26
|
+
sign_in Factory(:user)
|
|
27
|
+
get :overview
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it "should be successful" do
|
|
31
|
+
response.should be_success
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it "should have the right heading" do
|
|
35
|
+
response.should have_selector("h1", :content => "Models")
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
describe "GET 'index'" do
|
|
41
|
+
|
|
42
|
+
describe "when not signed in" do
|
|
43
|
+
|
|
44
|
+
before(:each) do
|
|
45
|
+
get :index, :modelname => "milk"
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it "should be successful" do
|
|
49
|
+
response.should_not be_success
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
describe "when signed in" do
|
|
54
|
+
|
|
55
|
+
before(:each) do
|
|
56
|
+
sign_in Factory(:user)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
it "should get redirected to overview when model doesn't exist" do
|
|
60
|
+
get :index, :modelname => "milk"
|
|
61
|
+
response.should redirect_to("/admin/models")
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'factories'
|
|
3
|
+
|
|
4
|
+
describe EngineRoom::PagesController do
|
|
5
|
+
render_views
|
|
6
|
+
|
|
7
|
+
describe "GET 'dashboard'" do
|
|
8
|
+
|
|
9
|
+
describe "when not signed in" do
|
|
10
|
+
|
|
11
|
+
before(:each) do
|
|
12
|
+
get :dashboard
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "should not be successful" do
|
|
16
|
+
response.should_not be_success
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it "should redirect to login page" do
|
|
20
|
+
response.should redirect_to(new_er_devise_user_session_path)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
describe "when signed in" do
|
|
25
|
+
|
|
26
|
+
before(:each) do
|
|
27
|
+
sign_in Factory(:user)
|
|
28
|
+
get :dashboard
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "should be successful" do
|
|
32
|
+
response.should be_success
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it "should have the right heading" do
|
|
36
|
+
response.should have_selector("h1", :content => "Dashboard")
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'factories'
|
|
3
|
+
|
|
4
|
+
describe EngineRoom::SectionsController do
|
|
5
|
+
render_views
|
|
6
|
+
|
|
7
|
+
describe "access control when not signed in" do
|
|
8
|
+
|
|
9
|
+
it "should deny access to 'index'" do
|
|
10
|
+
get :index
|
|
11
|
+
response.should redirect_to(new_er_devise_user_session_path)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it "should deny access to 'create'" do
|
|
15
|
+
@attr = { :name => "Dogs", :model_name => "dog" }
|
|
16
|
+
post :create, :section => @attr
|
|
17
|
+
response.should redirect_to(new_er_devise_user_session_path)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "should deny access to 'delete'" do
|
|
21
|
+
@section = Factory(:section)
|
|
22
|
+
delete :destroy, :id => @section
|
|
23
|
+
response.should redirect_to(new_er_devise_user_session_path)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
describe "GET 'index'" do
|
|
28
|
+
|
|
29
|
+
before(:each) do
|
|
30
|
+
sign_in Factory(:user)
|
|
31
|
+
get :index
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it "should be successful" do
|
|
35
|
+
response.should be_success
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
describe "GET 'edit'" do
|
|
40
|
+
|
|
41
|
+
before(:each) do
|
|
42
|
+
sign_in Factory(:user)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it "should render the edit page" do
|
|
46
|
+
section = Factory(:section)
|
|
47
|
+
get :edit, :id => section
|
|
48
|
+
response.should render_template('engine_room/sections/edit')
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
describe "POST 'create'" do
|
|
53
|
+
|
|
54
|
+
before(:each) do
|
|
55
|
+
sign_in Factory(:user)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
describe "failure" do
|
|
59
|
+
|
|
60
|
+
before(:each) do
|
|
61
|
+
@attr = { :model_name => "" }
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
it "should not create a section" do
|
|
65
|
+
lambda do
|
|
66
|
+
post :create, :section => @attr
|
|
67
|
+
end.should_not change(Section, :count)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
it "should not create section for invalid model_name" do
|
|
71
|
+
lambda do
|
|
72
|
+
post :create, :section => @attr.merge(:model_name => "Cat") # Cat model does not exist
|
|
73
|
+
end.should_not change(Section, :count)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
it "should render the new page" do
|
|
77
|
+
post :create, :section => @attr
|
|
78
|
+
response.should render_template('engine_room/sections/new')
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
describe "success" do
|
|
83
|
+
|
|
84
|
+
before(:each) do
|
|
85
|
+
@attr = { :name => "Dogs", :model_name => "Dog" }
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
it "should create a section" do
|
|
89
|
+
lambda do
|
|
90
|
+
post :create, :section => @attr
|
|
91
|
+
end.should change(Section, :count).by(1)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
it "should redirect to the index page" do
|
|
95
|
+
post :create, :section => @attr
|
|
96
|
+
response.should redirect_to(engine_room_sections_path)
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
it "should have a flash message" do
|
|
100
|
+
post :create, :section => @attr
|
|
101
|
+
flash[:notice].should =~ /successfully created/i
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
describe "DELETE 'destroy'" do
|
|
107
|
+
|
|
108
|
+
before(:each) do
|
|
109
|
+
sign_in(Factory(:user))
|
|
110
|
+
@section = Factory(:section)
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
it "should destroy the section" do
|
|
114
|
+
lambda do
|
|
115
|
+
delete :destroy, :id => @section
|
|
116
|
+
end.should change(Section, :count).by(-1)
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
it "should redirect to the index page" do
|
|
120
|
+
post :destroy, :id => @section
|
|
121
|
+
response.should redirect_to(engine_room_sections_path)
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
end
|