alchemy_cms 2.6.3 → 2.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.simplecov +14 -0
- data/.travis.yml +1 -1
- data/Gemfile +7 -6
- data/README.md +15 -5
- data/alchemy_cms.gemspec +3 -2
- data/app/assets/javascripts/alchemy/alchemy.base.js.coffee +9 -17
- data/app/assets/javascripts/alchemy/alchemy.dirty.js.coffee +70 -0
- data/app/assets/javascripts/alchemy/alchemy.dragndrop.js.coffee +80 -0
- data/app/assets/javascripts/alchemy/alchemy.element_editors.js.coffee +43 -19
- data/app/assets/javascripts/alchemy/alchemy.gui.js.coffee +3 -1
- data/app/assets/javascripts/alchemy/alchemy.js +4 -2
- data/app/assets/javascripts/alchemy/alchemy.onload.js.coffee +1 -1
- data/app/assets/javascripts/alchemy/alchemy.spinner.js.coffee +14 -0
- data/app/assets/javascripts/alchemy/alchemy.tinymce.js.coffee.erb +96 -0
- data/app/assets/javascripts/alchemy/alchemy.translations.js.coffee +22 -0
- data/app/assets/javascripts/alchemy/alchemy.windows.js.coffee +28 -17
- data/app/assets/stylesheets/alchemy/base.scss +6 -0
- data/app/assets/stylesheets/alchemy/elements.scss +2 -28
- data/app/assets/stylesheets/alchemy/errors.scss +1 -1
- data/app/assets/stylesheets/alchemy/menubar.css.scss +2 -0
- data/app/assets/stylesheets/alchemy/sitemap.scss +21 -34
- data/app/assets/stylesheets/alchemy/tables.scss +13 -3
- data/app/controllers/alchemy/admin/attachments_controller.rb +10 -5
- data/app/controllers/alchemy/admin/base_controller.rb +19 -0
- data/app/controllers/alchemy/admin/contents_controller.rb +1 -4
- data/app/controllers/alchemy/admin/dashboard_controller.rb +2 -1
- data/app/controllers/alchemy/admin/elements_controller.rb +1 -1
- data/app/controllers/alchemy/admin/essence_files_controller.rb +1 -1
- data/app/controllers/alchemy/admin/essence_pictures_controller.rb +70 -56
- data/app/controllers/alchemy/admin/pages_controller.rb +37 -114
- data/app/controllers/alchemy/admin/pictures_controller.rb +5 -12
- data/app/controllers/alchemy/admin/resources_controller.rb +3 -1
- data/app/controllers/alchemy/admin/trash_controller.rb +1 -1
- data/app/controllers/alchemy/attachments_controller.rb +1 -1
- data/app/controllers/alchemy/base_controller.rb +3 -15
- data/app/controllers/alchemy/messages_controller.rb +4 -10
- data/app/controllers/alchemy/pages_controller.rb +6 -6
- data/app/controllers/alchemy/passwords_controller.rb +1 -1
- data/app/controllers/alchemy/user_sessions_controller.rb +1 -1
- data/app/helpers/alchemy/admin/base_helper.rb +49 -230
- data/app/helpers/alchemy/admin/contents_helper.rb +5 -1
- data/app/helpers/alchemy/admin/elements_helper.rb +19 -47
- data/app/helpers/alchemy/admin/essences_helper.rb +59 -17
- data/app/helpers/alchemy/admin/navigation_helper.rb +204 -0
- data/app/helpers/alchemy/admin/pages_helper.rb +22 -79
- data/app/helpers/alchemy/admin/pictures_helper.rb +1 -1
- data/app/helpers/alchemy/admin/tags_helper.rb +42 -0
- data/app/helpers/alchemy/base_helper.rb +0 -11
- data/app/helpers/alchemy/elements_helper.rb +48 -25
- data/app/helpers/alchemy/essences_helper.rb +0 -20
- data/app/helpers/alchemy/pages_helper.rb +18 -14
- data/app/helpers/alchemy/url_helper.rb +1 -0
- data/app/mailers/alchemy/messages.rb +4 -6
- data/app/models/alchemy/attachment.rb +3 -0
- data/app/models/alchemy/cell.rb +33 -35
- data/app/models/alchemy/content.rb +20 -111
- data/app/models/alchemy/content/factory.rb +188 -0
- data/app/models/alchemy/element.rb +51 -200
- data/app/models/alchemy/element/definitions.rb +52 -0
- data/app/models/alchemy/element/presenters.rb +87 -0
- data/app/models/alchemy/essence_date.rb +1 -1
- data/app/models/alchemy/essence_file.rb +6 -7
- data/app/models/alchemy/essence_picture.rb +19 -4
- data/app/models/alchemy/message.rb +18 -14
- data/app/models/alchemy/page.rb +120 -214
- data/app/models/alchemy/page/elements.rb +145 -36
- data/app/models/alchemy/page/natures.rb +90 -0
- data/app/models/alchemy/page/scopes.rb +93 -0
- data/app/models/alchemy/page/users.rb +25 -0
- data/app/models/alchemy/picture.rb +15 -0
- data/app/models/alchemy/site.rb +15 -1
- data/app/models/alchemy/site/layout.rb +38 -0
- data/app/models/alchemy/user.rb +13 -3
- data/app/views/alchemy/admin/attachments/_archive_overlay.html.erb +7 -7
- data/app/views/alchemy/admin/attachments/_file_to_assign.html.erb +8 -8
- data/app/views/alchemy/admin/attachments/_tag_list.html.erb +1 -16
- data/app/views/alchemy/admin/attachments/destroy.js.erb +1 -4
- data/app/views/alchemy/admin/contents/create.js.erb +1 -1
- data/app/views/alchemy/admin/dashboard/index.html.erb +14 -13
- data/app/views/alchemy/admin/elements/_element_head.html.erb +7 -7
- data/app/views/alchemy/admin/elements/_refresh_editor.js.erb +10 -0
- data/app/views/alchemy/admin/elements/create.js.erb +44 -44
- data/app/views/alchemy/admin/elements/fold.js.erb +22 -26
- data/app/views/alchemy/admin/elements/trash.js.erb +1 -1
- data/app/views/alchemy/admin/elements/update.js.erb +22 -25
- data/app/views/alchemy/admin/essence_files/assign.js.erb +8 -3
- data/app/views/alchemy/admin/essence_pictures/crop.html.erb +14 -12
- data/app/views/alchemy/admin/essence_pictures/edit.html.erb +22 -39
- data/app/views/alchemy/admin/pages/_page.html.erb +73 -80
- data/app/views/alchemy/admin/pages/destroy.js.erb +2 -2
- data/app/views/alchemy/admin/pages/edit.html.erb +21 -18
- data/app/views/alchemy/admin/pages/fold.js.erb +1 -0
- data/app/views/alchemy/admin/pages/info.html.erb +32 -0
- data/app/views/alchemy/admin/partials/_main_navigation_entry.html.erb +11 -13
- data/app/views/alchemy/admin/partials/_remote_search_form.html.erb +20 -20
- data/app/views/alchemy/admin/partials/_sub_navigation.html.erb +8 -0
- data/app/views/alchemy/admin/partials/_toolbar_button.html.erb +25 -0
- data/app/views/alchemy/admin/partials/_upload_form.html.erb +15 -15
- data/app/views/alchemy/admin/pictures/_filter_and_size_bar.html.erb +39 -39
- data/app/views/alchemy/admin/pictures/_picture_to_assign.html.erb +10 -10
- data/app/views/alchemy/admin/pictures/_tag_list.html.erb +1 -16
- data/app/views/alchemy/admin/resources/destroy.js.erb +1 -1
- data/app/views/alchemy/base/500.html.erb +1 -1
- data/app/views/alchemy/base/permission_denied.js.erb +1 -1
- data/app/views/alchemy/base/redirect.js.erb +1 -1
- data/app/views/alchemy/essences/_essence_link_editor.html.erb +1 -1
- data/app/views/alchemy/essences/_essence_picture_editor.html.erb +1 -1
- data/app/views/alchemy/essences/_essence_richtext_editor.html.erb +1 -1
- data/app/views/alchemy/essences/_essence_text_editor.html.erb +1 -1
- data/app/views/alchemy/essences/{_essence_picture_tools.html.erb → shared/_essence_picture_tools.html.erb} +5 -5
- data/app/views/alchemy/essences/{_linkable_essence_tools.html.erb → shared/_linkable_essence_tools.html.erb} +0 -0
- data/app/views/alchemy/messages/contact_form_mail.de.text.erb +12 -0
- data/app/views/alchemy/messages/contact_form_mail.en.text.erb +12 -0
- data/app/views/alchemy/notifications/reset_password_instructions.de.text.erb +1 -1
- data/app/views/alchemy/notifications/reset_password_instructions.en.text.erb +2 -2
- data/app/views/alchemy/pages/sitemap.xml.erb +3 -5
- data/app/views/alchemy/user_sessions/leave.html.erb +1 -1
- data/app/views/layouts/alchemy/admin.html.erb +4 -2
- data/app/views/layouts/alchemy/sitemap.xml.erb +1 -1
- data/bin/alchemy +7 -13
- data/config/alchemy/config.yml +1 -0
- data/config/authorization_rules.rb +2 -3
- data/config/initializers/dragonfly.rb +2 -0
- data/config/locales/alchemy.de.yml +8 -9
- data/config/locales/alchemy.en.yml +7 -4
- data/config/routes.rb +3 -0
- data/db/migrate/{20130214233001_alchemy_two_point_five.rb → 20130827094554_alchemy_two_point_six.rb} +29 -6
- data/lib/alchemy/auth/engine.rb +9 -0
- data/lib/alchemy/capistrano.rb +37 -12
- data/lib/alchemy/config.rb +48 -35
- data/lib/alchemy/engine.rb +35 -6
- data/lib/alchemy/essence.rb +25 -29
- data/lib/alchemy/ferret/search.rb +86 -0
- data/lib/alchemy/{scoped_pagination_url_helper.rb → kaminari/scoped_pagination_url_helper.rb} +0 -0
- data/lib/alchemy/logger.rb +3 -4
- data/lib/alchemy/page_layout.rb +124 -55
- data/lib/alchemy/resource.rb +0 -10
- data/lib/alchemy/resources_helper.rb +0 -5
- data/lib/alchemy/seeder.rb +1 -32
- data/lib/alchemy/shell.rb +6 -1
- data/lib/alchemy/tinymce.rb +41 -32
- data/lib/alchemy/upgrader.rb +3 -1
- data/lib/alchemy/upgrader/two_point_five.rb +15 -8
- data/lib/alchemy/upgrader/two_point_one.rb +10 -10
- data/lib/alchemy/upgrader/two_point_two.rb +96 -51
- data/lib/alchemy/version.rb +1 -1
- data/lib/alchemy_cms.rb +5 -46
- data/lib/rails/generators/alchemy/deploy_script/templates/deploy.rb.tt +1 -1
- data/lib/rails/generators/alchemy/devise/devise_generator.rb +9 -4
- data/lib/rails/generators/alchemy/essence/essence_generator.rb +7 -6
- data/lib/rails/generators/alchemy/essence/templates/editor.html.erb +1 -1
- data/lib/rails/generators/alchemy/scaffold/files/_standard.html.erb +1 -0
- data/lib/rails/generators/alchemy/scaffold/scaffold_generator.rb +1 -0
- data/lib/rails/generators/alchemy/site_layouts/site_layouts_generator.rb +23 -0
- data/lib/rails/generators/alchemy/site_layouts/templates/layout.html.erb +1 -0
- data/lib/rails/generators/alchemy/site_layouts/templates/layout.html.haml +1 -0
- data/lib/rails/generators/alchemy/site_layouts/templates/layout.html.slim +1 -0
- data/lib/rails/templates/alchemy.rb +2 -2
- data/lib/tasks/alchemy/db.rake +3 -1
- data/lib/tasks/alchemy/tidy.rake +82 -0
- data/lib/tasks/alchemy/upgrade.rake +2 -1
- data/spec/controllers/admin/attachments_controller_spec.rb +124 -0
- data/spec/controllers/admin/base_controller_spec.rb +35 -0
- data/spec/controllers/admin/clipboard_controller_spec.rb +1 -1
- data/spec/controllers/admin/contents_controller_spec.rb +17 -26
- data/spec/controllers/admin/dashboard_controller_spec.rb +121 -0
- data/spec/controllers/admin/elements_controller_spec.rb +1 -1
- data/spec/controllers/admin/essence_files_controller_spec.rb +67 -0
- data/spec/controllers/admin/essence_pictures_controller_spec.rb +161 -0
- data/spec/controllers/admin/languages_controller_spec.rb +1 -1
- data/spec/controllers/admin/layoutpages_controller_spec.rb +28 -0
- data/spec/controllers/admin/pages_controller_spec.rb +164 -118
- data/spec/controllers/admin/pictures_controller_spec.rb +89 -0
- data/spec/controllers/admin/trash_controller_spec.rb +21 -31
- data/spec/controllers/admin/users_controller_spec.rb +114 -85
- data/spec/controllers/attachments_controller_spec.rb +6 -2
- data/spec/controllers/base_controller_spec.rb +22 -0
- data/spec/controllers/elements_controller_spec.rb +1 -1
- data/spec/controllers/messages_controller_spec.rb +200 -0
- data/spec/controllers/pictures_controller_spec.rb +1 -1
- data/spec/controllers/user_sessions_controller_spec.rb +7 -6
- data/spec/controllers/users_controller_spec.rb +2 -2
- data/spec/dummy/config/alchemy/cells.yml +2 -0
- data/spec/dummy/config/application.rb +19 -8
- data/spec/dummy/db/migrate/{20130214233001_alchemy_two_point_five.rb → 20130827094554_alchemy_two_point_six.rb} +29 -6
- data/spec/dummy/db/schema.rb +1 -1
- data/spec/fast_specs.rb +15 -0
- data/spec/helpers/admin/base_helper_spec.rb +53 -34
- data/spec/helpers/admin/contents_helper_spec.rb +15 -7
- data/spec/helpers/admin/elements_helper_spec.rb +79 -34
- data/spec/helpers/admin/essences_helper_spec.rb +45 -31
- data/spec/helpers/admin/navigation_helper_spec.rb +204 -0
- data/spec/helpers/admin/pages_helper_spec.rb +25 -15
- data/spec/helpers/admin/tags_helper_spec.rb +62 -2
- data/spec/helpers/elements_helper_spec.rb +202 -138
- data/spec/helpers/pages_helper_spec.rb +48 -0
- data/spec/helpers/url_helper_spec.rb +7 -0
- data/spec/libraries/config_spec.rb +110 -3
- data/spec/libraries/essence_spec.rb +29 -9
- data/spec/libraries/page_layout_spec.rb +134 -0
- data/spec/libraries/resource_spec.rb +3 -16
- data/spec/libraries/resources_helper_spec.rb +4 -8
- data/spec/libraries/shell_spec.rb +1 -0
- data/spec/libraries/tinymce_spec.rb +61 -0
- data/spec/mailers/messages_spec.rb +23 -0
- data/spec/models/attachment_spec.rb +45 -0
- data/spec/models/cell_spec.rb +62 -9
- data/spec/models/content_spec.rb +110 -28
- data/spec/models/element_spec.rb +275 -253
- data/spec/models/essence_date_spec.rb +25 -0
- data/spec/models/essence_file_spec.rb +23 -0
- data/spec/models/essence_html_spec.rb +13 -0
- data/spec/models/essence_picture_spec.rb +16 -0
- data/spec/models/essence_text_spec.rb +29 -0
- data/spec/models/language_spec.rb +34 -0
- data/spec/models/message_spec.rb +43 -0
- data/spec/models/page_spec.rb +726 -567
- data/spec/models/picture_spec.rb +98 -0
- data/spec/models/site_spec.rb +60 -2
- data/spec/models/tag_spec.rb +31 -0
- data/spec/models/user_spec.rb +4 -4
- data/spec/spec_helper.rb +49 -58
- data/spec/support/alchemy/controller_helpers.rb +35 -0
- data/spec/support/alchemy/{specs_helpers.rb → integration_helpers.rb} +4 -8
- data/spec/{factories.rb → support/factories.rb} +11 -1
- data/vendor/assets/javascripts/jquery_plugins/jquery.ui.nestedSortable.js +2 -8
- metadata +166 -106
- data/Guardfile +0 -16
- data/app/assets/javascripts/alchemy/alchemy.dirty.js +0 -93
- data/app/assets/javascripts/alchemy/alchemy.dragndrop.js +0 -122
- data/app/models/alchemy/tree_node.rb +0 -4
- data/app/views/alchemy/admin/pages/_page_infos.html.erb +0 -3
- data/app/views/alchemy/admin/partials/_sub_navigation_tab.html.erb +0 -8
- data/app/views/alchemy/messages/contact_form_mail.text.erb +0 -12
- data/config/initializers/kaminari_config.rb +0 -9
- data/db/migrate/20130221200514_migrate_attachments_to_dragonfly.rb +0 -21
- data/db/migrate/20130312205327_change_alchemy_users_role_to_roles.rb +0 -11
- data/lib/alchemy/auth_engine.rb +0 -7
- data/lib/alchemy/authentication_helpers.rb +0 -9
- data/lib/alchemy/ferret_search.rb +0 -84
- data/lib/extensions/array.rb +0 -25
- data/lib/extensions/hash.rb +0 -34
- data/spec/dummy/db/migrate/20130221200514_migrate_attachments_to_dragonfly.rb +0 -21
- data/spec/dummy/db/migrate/20130312205327_change_alchemy_users_role_to_roles.rb +0 -11
- data/spec/models/page_layout_spec.rb +0 -60
@@ -2,23 +2,16 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
module Alchemy
|
4
4
|
module Admin
|
5
|
-
|
6
5
|
describe TrashController do
|
7
|
-
|
8
6
|
render_views
|
9
7
|
|
10
|
-
let(:alchemy_page)
|
11
|
-
|
12
|
-
end
|
8
|
+
let(:alchemy_page) { FactoryGirl.create(:public_page) }
|
9
|
+
let(:element) { FactoryGirl.create(:element, :public => false, :page => alchemy_page) }
|
13
10
|
|
14
|
-
|
15
|
-
|
16
|
-
end
|
17
|
-
|
18
|
-
before do
|
19
|
-
sign_in :user, FactoryGirl.create(:admin_user)
|
11
|
+
before {
|
12
|
+
sign_in(admin_user)
|
20
13
|
element.trash
|
21
|
-
|
14
|
+
}
|
22
15
|
|
23
16
|
it "should hold trashed elements" do
|
24
17
|
get :index, :page_id => alchemy_page.id
|
@@ -32,44 +25,41 @@ module Alchemy
|
|
32
25
|
end
|
33
26
|
|
34
27
|
context "with unique elements inside the trash" do
|
35
|
-
|
36
|
-
before
|
37
|
-
Element.stub!(:all_definitions_for).and_return([
|
38
|
-
{'name' => element.name, 'unique' => true}
|
39
|
-
])
|
40
|
-
end
|
28
|
+
let(:trashed) { FactoryGirl.build_stubbed(:unique_element, position: nil, public: false, folded: true, page: alchemy_page) }
|
29
|
+
before { Element.stub(:trashed).and_return([trashed]) }
|
41
30
|
|
42
31
|
context "and no unique elements on the page" do
|
32
|
+
before { alchemy_page.stub_chain(:elements, :not_trashed, :pluck).and_return([]) }
|
43
33
|
|
44
34
|
it "unique elements should be draggable" do
|
45
|
-
get :index, :
|
46
|
-
response.body.should have_selector("#element_#{
|
35
|
+
get :index, page_id: alchemy_page.id
|
36
|
+
response.body.should have_selector("#element_#{trashed.id}.element_editor.draggable")
|
47
37
|
end
|
48
|
-
|
49
38
|
end
|
50
39
|
|
51
40
|
context "and with an unique element on the page" do
|
41
|
+
let(:unique) { FactoryGirl.build_stubbed(:unique_element) }
|
42
|
+
let(:page) { FactoryGirl.build_stubbed(:public_page) }
|
43
|
+
before {
|
44
|
+
Page.stub(:find).and_return(page)
|
45
|
+
page.stub_chain(:elements, :not_trashed, :pluck).and_return([unique.name])
|
46
|
+
}
|
52
47
|
|
53
48
|
it "unique elements should not be draggable" do
|
54
|
-
|
55
|
-
|
56
|
-
response.body.should have_selector("#element_#{element.id}.element_editor.not-draggable")
|
49
|
+
get :index, page_id: page.id
|
50
|
+
response.body.should have_selector("#element_#{trashed.id}.element_editor.not-draggable")
|
57
51
|
end
|
58
|
-
|
59
52
|
end
|
60
|
-
|
61
53
|
end
|
62
54
|
|
63
|
-
|
64
|
-
|
55
|
+
describe "#clear" do
|
65
56
|
it "should destroy all containing elements" do
|
66
|
-
|
57
|
+
Element.trashed.should_not be_empty
|
58
|
+
xhr :post, :clear, page_id: alchemy_page.id
|
67
59
|
Element.trashed.should be_empty
|
68
60
|
end
|
69
|
-
|
70
61
|
end
|
71
62
|
|
72
63
|
end
|
73
|
-
|
74
64
|
end
|
75
65
|
end
|
@@ -1,103 +1,132 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
before { sign_in :user, admin }
|
3
|
+
module Alchemy
|
4
|
+
describe Admin::UsersController do
|
6
5
|
|
7
|
-
|
8
|
-
render_views
|
6
|
+
let(:admin) { FactoryGirl.build_stubbed(:admin_user) }
|
9
7
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
describe '#edit' do
|
17
|
-
render_views
|
18
|
-
|
19
|
-
it "has send_credentials checkbox deactivated" do
|
20
|
-
get :edit, id: admin.id
|
21
|
-
response.body.should match /<input id="user_send_credentials" name="user\[send_credentials\]" type="checkbox"/
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
describe '#create' do
|
26
|
-
before { ActionMailer::Base.deliveries = [] }
|
27
|
-
|
28
|
-
it "creates an user record" do
|
29
|
-
post :create, user: FactoryGirl.attributes_for(:user).merge(send_credentials: true)
|
30
|
-
Alchemy::User.count.should == 2
|
31
|
-
end
|
32
|
-
|
33
|
-
context "with send_credentials set to true" do
|
34
|
-
it "should send an email notification" do
|
35
|
-
post :create, user: FactoryGirl.attributes_for(:user).merge(send_credentials: true)
|
36
|
-
ActionMailer::Base.deliveries.should_not be_empty
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
context "with send_credentials left blank" do
|
41
|
-
it "should not send an email notification" do
|
42
|
-
post :create, user: FactoryGirl.attributes_for(:user)
|
43
|
-
ActionMailer::Base.deliveries.should be_empty
|
8
|
+
before do
|
9
|
+
controller.stub!(:store_user_request_time)
|
10
|
+
User.stub!(:find).and_return(admin)
|
11
|
+
admin.stub!(:update_without_password).and_return(true)
|
12
|
+
admin.stub!(:update_attributes).and_return(true)
|
13
|
+
sign_in(admin)
|
44
14
|
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
describe '#update' do
|
49
|
-
let(:user) { FactoryGirl.create(:user) }
|
50
|
-
|
51
|
-
before { ActionMailer::Base.deliveries = [] }
|
52
15
|
|
53
|
-
|
54
|
-
|
55
|
-
assigns(:user).should eq(user)
|
56
|
-
end
|
16
|
+
describe '#new' do
|
17
|
+
render_views
|
57
18
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
19
|
+
it "has send_credentials checkbox activated" do
|
20
|
+
get :new
|
21
|
+
response.body.should match /<input checked="checked" id="user_send_credentials" name="user\[send_credentials\]" type="checkbox"/
|
22
|
+
end
|
62
23
|
end
|
63
|
-
end
|
64
24
|
|
65
|
-
|
66
|
-
|
67
|
-
post :update, :id => user.id, :user => {:firstname => 'Johnny', :password => 'newpassword', :password_confirmation => 'newpassword'}, :format => :js
|
68
|
-
assigns(:user).password.should == 'newpassword'
|
69
|
-
end
|
70
|
-
end
|
25
|
+
describe '#edit' do
|
26
|
+
render_views
|
71
27
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
28
|
+
it "has send_credentials checkbox deactivated" do
|
29
|
+
get :edit, id: admin.id
|
30
|
+
response.body.should match /<input id="user_send_credentials" name="user\[send_credentials\]" type="checkbox"/
|
31
|
+
end
|
76
32
|
end
|
77
|
-
end
|
78
33
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
34
|
+
describe '#create' do
|
35
|
+
before { ActionMailer::Base.deliveries = [] }
|
36
|
+
|
37
|
+
it "creates an user record" do
|
38
|
+
post :create, user: FactoryGirl.attributes_for(:user).merge(send_credentials: '1')
|
39
|
+
Alchemy::User.count.should == 1
|
40
|
+
end
|
41
|
+
|
42
|
+
context "with send_credentials set to '1'" do
|
43
|
+
it "should send an email notification" do
|
44
|
+
post :create, user: FactoryGirl.attributes_for(:user).merge(send_credentials: '1')
|
45
|
+
ActionMailer::Base.deliveries.should_not be_empty
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
context "with send_credentials set to true" do
|
50
|
+
it "should not send an email notification" do
|
51
|
+
post :create, user: FactoryGirl.attributes_for(:user).merge(send_credentials: true)
|
52
|
+
ActionMailer::Base.deliveries.should be_empty
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
context "with send_credentials left blank" do
|
57
|
+
it "should not send an email notification" do
|
58
|
+
post :create, user: FactoryGirl.attributes_for(:user)
|
59
|
+
ActionMailer::Base.deliveries.should be_empty
|
60
|
+
end
|
61
|
+
end
|
83
62
|
end
|
84
|
-
end
|
85
63
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
64
|
+
describe '#update' do
|
65
|
+
before do
|
66
|
+
ActionMailer::Base.deliveries = []
|
67
|
+
end
|
68
|
+
|
69
|
+
it "assigns user to @user" do
|
70
|
+
post :update, id: admin.id, user: {}, format: :js
|
71
|
+
assigns(:user).should eq(admin)
|
72
|
+
end
|
73
|
+
|
74
|
+
context "with empty password passed" do
|
75
|
+
it "should update the user" do
|
76
|
+
params_hash = {'firstname' => 'Johnny', 'password' => '', 'password_confirmation' => ''}
|
77
|
+
admin.should_receive(:update_without_password).with(params_hash).and_return(true)
|
78
|
+
post :update, id: admin.id, user: params_hash, format: :js
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
context "with new password passed" do
|
83
|
+
it "should update the user" do
|
84
|
+
params_hash = {'firstname' => 'Johnny', 'password' => 'newpassword', 'password_confirmation' => 'newpassword'}
|
85
|
+
admin.should_receive(:update_attributes).with(params_hash)
|
86
|
+
post :update, id: admin.id, user: params_hash, format: :js
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
context "with send_credentials set to '1'" do
|
91
|
+
let(:user) { FactoryGirl.build(:user) }
|
92
|
+
before { User.stub!(:find).and_return(user) }
|
93
|
+
|
94
|
+
it "should send an email notification" do
|
95
|
+
post :update, id: user.id, user: {send_credentials: '1'}
|
96
|
+
ActionMailer::Base.deliveries.should_not be_empty
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
context "with send_credentials left blank" do
|
101
|
+
it "should not send an email notification" do
|
102
|
+
post :update, id: admin.id, user: {}, format: :js
|
103
|
+
ActionMailer::Base.deliveries.should be_empty
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
context "if user is permitted to update roles" do
|
108
|
+
before do
|
109
|
+
controller.stub!(:permitted_to?).with(:update_roles).and_return(true)
|
110
|
+
end
|
111
|
+
|
112
|
+
it "updates the user including role" do
|
113
|
+
admin.should_receive(:update_without_password).with({'roles' => ['Administrator']})
|
114
|
+
post :update, id: admin.id, user: {roles: ['Administrator']}, format: :js
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
context "if the user is not permitted to update roles" do
|
119
|
+
before do
|
120
|
+
controller.stub!(:permitted_to?).with(:update_roles).and_return(false)
|
121
|
+
end
|
122
|
+
|
123
|
+
it "updates user without role" do
|
124
|
+
admin.should_receive(:update_without_password).with({})
|
125
|
+
post :update, id: admin.id, user: {'roles' => ['Administrator']}, format: :js
|
126
|
+
end
|
127
|
+
end
|
93
128
|
|
94
|
-
context "if the user is not permitted to update roles" do
|
95
|
-
it "updates user without role" do
|
96
|
-
controller.stub(:permitted_to?).with(:update_roles).and_return { false }
|
97
|
-
Alchemy::User.any_instance.should_receive(:update_attributes).with({})
|
98
|
-
post :update, :id => user.id, :user => {'roles' => ['Administrator']}, :format => :js
|
99
129
|
end
|
100
|
-
end
|
101
|
-
end
|
102
130
|
|
131
|
+
end
|
103
132
|
end
|
@@ -24,10 +24,14 @@ module Alchemy
|
|
24
24
|
response.should redirect_to(login_path)
|
25
25
|
end
|
26
26
|
|
27
|
+
it "should raise ActiveRecord::RecordNotFound for requesting not existing attachments" do
|
28
|
+
expect { get :download, id: 0 }.to raise_error(ActiveRecord::RecordNotFound)
|
29
|
+
end
|
30
|
+
|
27
31
|
context "as registered user" do
|
28
32
|
|
29
33
|
before do
|
30
|
-
sign_in
|
34
|
+
sign_in(registered_user)
|
31
35
|
end
|
32
36
|
|
33
37
|
it "should be possible to download attachments from restricted pages" do
|
@@ -46,7 +50,7 @@ module Alchemy
|
|
46
50
|
context "as registered user" do
|
47
51
|
|
48
52
|
before do
|
49
|
-
sign_in
|
53
|
+
sign_in(registered_user)
|
50
54
|
end
|
51
55
|
|
52
56
|
it "should be possible to see attachments from restricted pages" do
|
@@ -119,6 +119,28 @@ module Alchemy
|
|
119
119
|
end
|
120
120
|
|
121
121
|
end
|
122
|
+
|
123
|
+
describe "#layout_for_page" do
|
124
|
+
it "should return false if params[:layout] is set to false" do
|
125
|
+
controller.stub!(:params).and_return(layout: 'false')
|
126
|
+
expect(controller.send(:layout_for_page)).to be_false
|
127
|
+
end
|
128
|
+
|
129
|
+
it "should return false if params[:layout] is set to none" do
|
130
|
+
controller.stub!(:params).and_return(layout: 'none')
|
131
|
+
expect(controller.send(:layout_for_page)).to be_false
|
132
|
+
end
|
133
|
+
|
134
|
+
it "should return the layout name set through params[:layout]" do
|
135
|
+
controller.stub!(:params).and_return(layout: 'my_layout')
|
136
|
+
expect(controller.send(:layout_for_page)).to eq('my_layout')
|
137
|
+
end
|
138
|
+
|
139
|
+
it "should return 'application' if params[:layout] is not set" do
|
140
|
+
controller.stub!(:params).and_return({})
|
141
|
+
expect(controller.send(:layout_for_page)).to eq('application')
|
142
|
+
end
|
143
|
+
end
|
122
144
|
|
123
145
|
end
|
124
146
|
end
|
@@ -0,0 +1,200 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Alchemy
|
4
|
+
describe MessagesController do
|
5
|
+
|
6
|
+
before do
|
7
|
+
controller.instance_variable_set(:@page, page)
|
8
|
+
controller.stub!(:get_page).and_return(page)
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "#index" do
|
12
|
+
|
13
|
+
let(:page) { mock_model('Page', {urlname: 'contact', page_layout: 'contact'}) }
|
14
|
+
|
15
|
+
it "should redirect to @page" do
|
16
|
+
expect(get :index).to redirect_to(show_page_path(urlname: page.urlname))
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "#new" do
|
21
|
+
|
22
|
+
it "should render the alchemy/pages/show template" do
|
23
|
+
get :new
|
24
|
+
expect(get :new).to render_template('alchemy/pages/show')
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should call #layout_for_page to render the correct layout" do
|
28
|
+
controller.should_receive(:layout_for_page)
|
29
|
+
get :new
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "#create" do
|
34
|
+
|
35
|
+
before { controller.stub!(:params).and_return({message: {email: ''}}) }
|
36
|
+
|
37
|
+
let(:page) { mock_model('Page', get_language_root: mock_model('Page')) }
|
38
|
+
let(:element) { mock_model('Element', page: page, ingredient: '') }
|
39
|
+
let(:message) { Message.new }
|
40
|
+
|
41
|
+
it "should raise ActiveRecord::RecordNotFound if element of contactform could not be found" do
|
42
|
+
expect { get :create }.to raise_error(ActiveRecord::RecordNotFound)
|
43
|
+
end
|
44
|
+
|
45
|
+
context "if validation of message" do
|
46
|
+
|
47
|
+
before do
|
48
|
+
Element.stub!(:find_by_id).and_return(element)
|
49
|
+
Message.any_instance.stub(:contact_form_id).and_return(1)
|
50
|
+
end
|
51
|
+
|
52
|
+
context "is false" do
|
53
|
+
before { Message.any_instance.stub(:valid?).and_return(false) }
|
54
|
+
|
55
|
+
it "should render 'alchemy/pages/show' template" do
|
56
|
+
expect(get :create).to render_template('alchemy/pages/show')
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
context "is true" do
|
61
|
+
before do
|
62
|
+
Message.any_instance.stub(:valid?).and_return(true)
|
63
|
+
Messages.stub_chain(:contact_form_mail, :deliver).and_return(true)
|
64
|
+
end
|
65
|
+
|
66
|
+
it "Messages should call Messages#contact_form_mail to send the email" do
|
67
|
+
Messages.should_receive(:contact_form_mail)
|
68
|
+
get :create
|
69
|
+
end
|
70
|
+
|
71
|
+
describe '#mail_to' do
|
72
|
+
context "with element having mail_to ingredient" do
|
73
|
+
before {
|
74
|
+
element.stub(:ingredient).with(:mail_to).and_return('peter@schroeder.de')
|
75
|
+
message
|
76
|
+
Message.stub(:new).and_return(message)
|
77
|
+
}
|
78
|
+
|
79
|
+
it "returns the ingredient" do
|
80
|
+
Messages.should_receive(:contact_form_mail).with(message, 'peter@schroeder.de', '', '')
|
81
|
+
get :create
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
context "with element having no mail_to ingredient" do
|
86
|
+
before {
|
87
|
+
element.stub(:ingredient).with(:mail_to).and_return(nil)
|
88
|
+
message
|
89
|
+
Message.stub(:new).and_return(message)
|
90
|
+
}
|
91
|
+
|
92
|
+
it "returns the config value" do
|
93
|
+
Messages.should_receive(:contact_form_mail).with(message, 'your.mail@your-domain.com', '', '')
|
94
|
+
get :create
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
describe '#mail_from' do
|
100
|
+
context "with element having mail_from ingredient" do
|
101
|
+
before {
|
102
|
+
element.stub(:ingredient).with(:mail_from).and_return('peter@schroeder.de')
|
103
|
+
message
|
104
|
+
Message.stub(:new).and_return(message)
|
105
|
+
}
|
106
|
+
|
107
|
+
it "returns the ingredient" do
|
108
|
+
Messages.should_receive(:contact_form_mail).with(message, '', 'peter@schroeder.de', '')
|
109
|
+
get :create
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
context "with element having no mail_from ingredient" do
|
114
|
+
before {
|
115
|
+
element.stub(:ingredient).with(:mail_from).and_return(nil)
|
116
|
+
message
|
117
|
+
Message.stub(:new).and_return(message)
|
118
|
+
}
|
119
|
+
|
120
|
+
it "returns the config value" do
|
121
|
+
Messages.should_receive(:contact_form_mail).with(message, '', 'your.mail@your-domain.com', '')
|
122
|
+
get :create
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
describe '#subject' do
|
128
|
+
context "with element having subject ingredient" do
|
129
|
+
before {
|
130
|
+
element.stub(:ingredient).with(:subject).and_return('A new message')
|
131
|
+
message
|
132
|
+
Message.stub(:new).and_return(message)
|
133
|
+
}
|
134
|
+
|
135
|
+
it "returns the ingredient" do
|
136
|
+
Messages.should_receive(:contact_form_mail).with(message, '', '', 'A new message')
|
137
|
+
get :create
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
context "with element having no subject ingredient" do
|
142
|
+
before {
|
143
|
+
element.stub(:ingredient).with(:subject).and_return(nil)
|
144
|
+
message
|
145
|
+
Message.stub(:new).and_return(message)
|
146
|
+
}
|
147
|
+
|
148
|
+
it "returns the config value" do
|
149
|
+
Messages.should_receive(:contact_form_mail).with(message, '', '', 'A new contact form message')
|
150
|
+
get :create
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
describe "#redirect_to_success_page" do
|
156
|
+
|
157
|
+
context "if 'success_page' ingredient of element is set with urlname" do
|
158
|
+
before { element.stub!(:ingredient).with('success_page').and_return('success-page') }
|
159
|
+
|
160
|
+
it "should redirect to the given urlname" do
|
161
|
+
expect(get :create).to redirect_to(show_page_path(urlname: 'success-page'))
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
context "if 'success_page' ingredient of element is not set" do
|
166
|
+
before { element.stub!(:ingredient).with('success_page').and_return(nil) }
|
167
|
+
|
168
|
+
context "but mailer_config['forward_to_page'] is true and mailer_config['mail_success_page'] is set" do
|
169
|
+
before do
|
170
|
+
controller.stub!(:mailer_config).and_return({'forward_to_page' => true, 'mail_success_page' => 'mailer-config-success-page'})
|
171
|
+
Page.stub_chain(:find_by_urlname, :urlname).and_return('mailer-config-success-page')
|
172
|
+
end
|
173
|
+
|
174
|
+
it "redirect to the given success page" do
|
175
|
+
expect(get :create).to redirect_to(show_page_path(urlname: 'mailer-config-success-page'))
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
context "and mailer_config has no instructions for success_page" do
|
180
|
+
before do
|
181
|
+
controller.stub!(:mailer_config).and_return({})
|
182
|
+
end
|
183
|
+
|
184
|
+
it "should redirect to the language root page" do
|
185
|
+
Page.stub_chain(:language_root_for, :urlname).and_return('lang-root')
|
186
|
+
expect(get :create).to redirect_to(show_page_path(urlname: 'lang-root'))
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
end
|
191
|
+
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
end
|
196
|
+
|
197
|
+
end
|
198
|
+
|
199
|
+
end
|
200
|
+
end
|