alchemy_cms 2.8.3 → 2.9.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.
- checksums.yaml +4 -4
- data/.travis.yml +3 -2
- data/README.md +108 -25
- data/alchemy_cms.gemspec +0 -1
- data/app/assets/stylesheets/alchemy/archive.scss +2 -2
- data/app/assets/stylesheets/alchemy/base.scss +0 -37
- data/app/assets/stylesheets/alchemy/elements.scss +1 -1
- data/app/assets/stylesheets/alchemy/flash.scss +1 -1
- data/app/assets/stylesheets/alchemy/form_elements.scss +1 -1
- data/app/assets/stylesheets/alchemy/icon-font.css.scss +40 -40
- data/app/assets/stylesheets/alchemy/icons.scss +4 -32
- data/app/assets/stylesheets/alchemy/jquery-ui.scss +4 -4
- data/app/assets/stylesheets/alchemy/menubar.css.scss +20 -12
- data/app/assets/stylesheets/alchemy/modules.scss +0 -4
- data/app/assets/stylesheets/alchemy/search.scss +1 -1
- data/app/assets/stylesheets/alchemy/sitemap.scss +1 -1
- data/app/assets/stylesheets/tiny_mce/plugins/inlinepopups/skins/alchemy-tinymce-dialog/window.css.scss +3 -3
- data/app/controllers/alchemy/admin/base_controller.rb +12 -8
- data/app/controllers/alchemy/admin/dashboard_controller.rb +10 -5
- data/app/controllers/alchemy/admin/elements_controller.rb +1 -1
- data/app/controllers/alchemy/admin/essence_pictures_controller.rb +8 -1
- data/app/controllers/alchemy/admin/layoutpages_controller.rb +1 -1
- data/app/controllers/alchemy/admin/pages_controller.rb +11 -6
- data/app/controllers/alchemy/admin/resources_controller.rb +2 -2
- data/app/controllers/alchemy/admin/users_controller.rb +1 -1
- data/app/controllers/alchemy/base_controller.rb +71 -37
- data/app/controllers/alchemy/elements_controller.rb +1 -1
- data/app/controllers/alchemy/pages_controller.rb +9 -3
- data/app/controllers/alchemy/pictures_controller.rb +1 -0
- data/app/helpers/alchemy/admin/base_helper.rb +2 -10
- data/app/helpers/alchemy/admin/pages_helper.rb +1 -1
- data/app/helpers/alchemy/base_helper.rb +1 -1
- data/app/helpers/alchemy/pages_helper.rb +1 -1
- data/app/models/alchemy/attachment.rb +3 -4
- data/app/models/alchemy/cell.rb +1 -1
- data/app/models/alchemy/content.rb +3 -4
- data/app/models/alchemy/element.rb +5 -6
- data/app/models/alchemy/folded_page.rb +1 -1
- data/app/models/alchemy/language.rb +1 -1
- data/app/models/alchemy/message.rb +1 -7
- data/app/models/alchemy/page.rb +12 -10
- data/app/models/alchemy/page/{cells.rb → page_cells.rb} +2 -2
- data/app/models/alchemy/page/{elements.rb → page_elements.rb} +2 -2
- data/app/models/alchemy/page/{naming.rb → page_naming.rb} +1 -1
- data/app/models/alchemy/page/{natures.rb → page_natures.rb} +3 -3
- data/app/models/alchemy/page/{scopes.rb → page_scopes.rb} +3 -3
- data/app/models/alchemy/page/page_users.rb +33 -0
- data/app/models/alchemy/picture.rb +3 -3
- data/app/models/alchemy/site.rb +2 -2
- data/app/views/alchemy/admin/dashboard/_locked_pages.html.erb +1 -1
- data/app/views/alchemy/admin/dashboard/_recent_pages.html.erb +1 -1
- data/app/views/alchemy/admin/dashboard/_sites.html.erb +1 -1
- data/app/views/alchemy/admin/dashboard/index.html.erb +10 -4
- data/app/views/alchemy/admin/pages/_page.html.erb +1 -1
- data/app/views/alchemy/admin/pages/update.js.erb +1 -1
- data/app/views/alchemy/{user_sessions → base}/leave.html.erb +2 -2
- data/app/views/alchemy/base/permission_denied.js.erb +3 -2
- data/app/views/layouts/alchemy/admin.html.erb +6 -3
- data/config/alchemy/config.yml +1 -11
- data/config/alchemy/modules.yml +0 -12
- data/config/locales/alchemy.de.yml +3 -40
- data/config/locales/alchemy.en.yml +2 -22
- data/config/routes.rb +2 -27
- data/db/migrate/20130827094554_alchemy_two_point_six.rb +0 -31
- data/lib/alchemy/auth_accessors.rb +54 -0
- data/lib/alchemy/capistrano.rb +5 -17
- data/lib/alchemy/engine.rb +7 -7
- data/lib/alchemy/errors.rb +6 -0
- data/lib/alchemy/essence.rb +2 -2
- data/lib/alchemy/seeder.rb +1 -1
- data/lib/alchemy/tasks/helpers.rb +83 -0
- data/lib/alchemy/test_support/auth_helpers.rb +35 -0
- data/lib/alchemy/test_support/controller_requests.rb +37 -0
- data/{spec/support → lib/alchemy/test_support}/factories.rb +7 -28
- data/{spec/support/alchemy → lib/alchemy/test_support}/integration_helpers.rb +9 -36
- data/lib/alchemy/upgrader.rb +8 -7
- data/lib/alchemy/upgrader/two_point_nine.rb +33 -0
- data/lib/alchemy/userstamp.rb +10 -0
- data/lib/alchemy/version.rb +1 -3
- data/lib/rails/templates/alchemy.rb +1 -0
- data/lib/tasks/alchemy/db.rake +5 -5
- data/spec/controllers/admin/attachments_controller_spec.rb +3 -3
- data/spec/controllers/admin/dashboard_controller_spec.rb +55 -34
- data/spec/controllers/admin/elements_controller_spec.rb +1 -1
- data/spec/controllers/admin/essence_pictures_controller_spec.rb +22 -6
- data/spec/controllers/admin/pages_controller_spec.rb +41 -58
- data/spec/controllers/admin/resources_controller_spec.rb +30 -5
- data/spec/controllers/admin/trash_controller_spec.rb +1 -1
- data/spec/controllers/attachments_controller_spec.rb +26 -44
- data/spec/controllers/base_controller_spec.rb +8 -33
- data/spec/controllers/elements_controller_spec.rb +1 -1
- data/spec/controllers/pages_controller_spec.rb +7 -15
- data/spec/controllers/pictures_controller_spec.rb +44 -5
- data/spec/dummy/app/controllers/application_controller.rb +9 -1
- data/spec/dummy/app/models/user.rb +14 -0
- data/spec/dummy/db/migrate/20130827094554_alchemy_two_point_six.rb +0 -31
- data/spec/dummy/db/schema.rb +0 -31
- data/spec/features/admin/language_tree_feature_spec.rb +34 -0
- data/spec/features/admin/pages_controller_spec.rb +1 -1
- data/spec/features/pages_controller_spec.rb +5 -12
- data/spec/features/picture_security_spec.rb +2 -2
- data/spec/features/security_spec.rb +6 -45
- data/spec/features/translation_integration_spec.rb +11 -20
- data/spec/{support → fixtures}/80x60.png +0 -0
- data/spec/support/image with spaces.png b/data/spec/fixtures/image with → spaces.png +0 -0
- data/spec/{support → fixtures}/image.png +0 -0
- data/spec/{support → fixtures}/image2.PNG +0 -0
- data/spec/{support → fixtures}/image3.jpeg +0 -0
- data/spec/helpers/admin/base_helper_spec.rb +31 -43
- data/spec/helpers/admin/pages_helper_spec.rb +4 -2
- data/spec/helpers/base_helper_spec.rb +10 -3
- data/spec/helpers/pages_helper_spec.rb +32 -22
- data/spec/models/attachment_spec.rb +1 -1
- data/spec/models/element_spec.rb +33 -57
- data/spec/models/message_spec.rb +0 -16
- data/spec/models/page_spec.rb +62 -26
- data/spec/models/picture_spec.rb +5 -5
- data/spec/spec_helper.rb +13 -4
- data/spec/tasks/helpers_spec.rb +213 -0
- metadata +33 -75
- data/app/controllers/alchemy/passwords_controller.rb +0 -35
- data/app/controllers/alchemy/user_sessions_controller.rb +0 -67
- data/app/controllers/alchemy/users_controller.rb +0 -46
- data/app/mailers/alchemy/notifications.rb +0 -33
- data/app/models/alchemy/page/users.rb +0 -25
- data/app/models/alchemy/user.rb +0 -183
- data/app/views/alchemy/admin/users/_table.html.erb +0 -69
- data/app/views/alchemy/admin/users/_user.html.erb +0 -39
- data/app/views/alchemy/admin/users/edit.html.erb +0 -6
- data/app/views/alchemy/admin/users/index.html.erb +0 -58
- data/app/views/alchemy/admin/users/new.html.erb +0 -6
- data/app/views/alchemy/notifications/admin_user_created.de.text.erb +0 -15
- data/app/views/alchemy/notifications/admin_user_created.en.text.erb +0 -15
- data/app/views/alchemy/notifications/registered_user_created.de.text.erb +0 -13
- data/app/views/alchemy/notifications/registered_user_created.en.text.erb +0 -13
- data/app/views/alchemy/notifications/reset_password_instructions.de.text.erb +0 -8
- data/app/views/alchemy/notifications/reset_password_instructions.en.text.erb +0 -8
- data/app/views/alchemy/passwords/edit.html.erb +0 -35
- data/app/views/alchemy/passwords/new.html.erb +0 -30
- data/app/views/alchemy/user_sessions/new.html.erb +0 -48
- data/app/views/alchemy/users/new.html.erb +0 -14
- data/config/initializers/devise.rb +0 -242
- data/config/locales/devise.de.yml +0 -58
- data/config/locales/devise.en.yml +0 -60
- data/lib/rails/generators/alchemy/devise/devise_generator.rb +0 -29
- data/spec/controllers/admin/users_controller_spec.rb +0 -132
- data/spec/controllers/passwords_controller_spec.rb +0 -16
- data/spec/controllers/user_sessions_controller_spec.rb +0 -22
- data/spec/controllers/users_controller_spec.rb +0 -66
- data/spec/mailers/notifications_spec.rb +0 -67
- data/spec/models/user_spec.rb +0 -252
- data/spec/support/alchemy/controller_helpers.rb +0 -35
data/spec/dummy/db/schema.rb
CHANGED
|
@@ -268,37 +268,6 @@ ActiveRecord::Schema.define(:version => 20130827094554) do
|
|
|
268
268
|
add_index "alchemy_sites", ["host", "public"], :name => "alchemy_sites_public_hosts_idx"
|
|
269
269
|
add_index "alchemy_sites", ["host"], :name => "index_alchemy_sites_on_host"
|
|
270
270
|
|
|
271
|
-
create_table "alchemy_users", :force => true do |t|
|
|
272
|
-
t.string "firstname"
|
|
273
|
-
t.string "lastname"
|
|
274
|
-
t.string "login"
|
|
275
|
-
t.string "email"
|
|
276
|
-
t.string "gender"
|
|
277
|
-
t.string "roles", :default => "registered"
|
|
278
|
-
t.string "language"
|
|
279
|
-
t.string "encrypted_password", :limit => 128, :default => "", :null => false
|
|
280
|
-
t.string "password_salt", :limit => 128, :default => "", :null => false
|
|
281
|
-
t.integer "sign_in_count", :default => 0, :null => false
|
|
282
|
-
t.integer "failed_attempts", :default => 0, :null => false
|
|
283
|
-
t.datetime "last_request_at"
|
|
284
|
-
t.datetime "current_sign_in_at"
|
|
285
|
-
t.datetime "last_sign_in_at"
|
|
286
|
-
t.string "current_sign_in_ip"
|
|
287
|
-
t.string "last_sign_in_ip"
|
|
288
|
-
t.datetime "created_at", :null => false
|
|
289
|
-
t.datetime "updated_at", :null => false
|
|
290
|
-
t.integer "creator_id"
|
|
291
|
-
t.integer "updater_id"
|
|
292
|
-
t.text "cached_tag_list"
|
|
293
|
-
t.string "reset_password_token"
|
|
294
|
-
t.datetime "reset_password_sent_at"
|
|
295
|
-
end
|
|
296
|
-
|
|
297
|
-
add_index "alchemy_users", ["email"], :name => "index_alchemy_users_on_email", :unique => true
|
|
298
|
-
add_index "alchemy_users", ["login"], :name => "index_alchemy_users_on_login", :unique => true
|
|
299
|
-
add_index "alchemy_users", ["reset_password_token"], :name => "index_alchemy_users_on_reset_password_token", :unique => true
|
|
300
|
-
add_index "alchemy_users", ["roles"], :name => "index_alchemy_users_on_roles"
|
|
301
|
-
|
|
302
271
|
create_table "events", :force => true do |t|
|
|
303
272
|
t.string "name"
|
|
304
273
|
t.string "hidden_name"
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe 'Language tree feature', js: true do
|
|
4
|
+
|
|
5
|
+
let(:klingonian) { FactoryGirl.create(:klingonian) }
|
|
6
|
+
let(:german_root) { FactoryGirl.create(:language_root_page) }
|
|
7
|
+
let(:klingonian_root) { FactoryGirl.create(:language_root_page, :name => 'Klingonian', :language => klingonian) }
|
|
8
|
+
|
|
9
|
+
before do
|
|
10
|
+
german_root
|
|
11
|
+
authorize_as_admin
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
context "in a multilangual environment" do
|
|
15
|
+
before { klingonian_root }
|
|
16
|
+
|
|
17
|
+
it "one should be able to switch the language tree" do
|
|
18
|
+
visit('/admin/pages')
|
|
19
|
+
page.select 'Klingonian', from: 'language_tree_select'
|
|
20
|
+
page.should have_selector('#sitemap', text: 'Klingonian')
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
context "with no language root page" do
|
|
25
|
+
before { klingonian }
|
|
26
|
+
|
|
27
|
+
it "it should display the form for creating language root" do
|
|
28
|
+
visit('/admin/pages')
|
|
29
|
+
page.select 'Klingonian', from: 'language_tree_select'
|
|
30
|
+
page.should have_content('This language tree does not exist')
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
end
|
|
@@ -24,7 +24,7 @@ module Alchemy
|
|
|
24
24
|
it "one should be able to switch the language tree" do
|
|
25
25
|
visit('/admin/pages')
|
|
26
26
|
page.select 'Klingonian', :from => 'language'
|
|
27
|
-
page.should have_selector('#sitemap', :text => 'Klingonian')
|
|
27
|
+
page.should have_selector('#sitemap .sitemap_pagename_link', :text => 'Klingonian')
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
after { Capybara.default_wait_time = 2 } # Reset to default
|
|
@@ -109,7 +109,7 @@ module Alchemy
|
|
|
109
109
|
context "in multi language mode" do
|
|
110
110
|
|
|
111
111
|
before do
|
|
112
|
-
Config.stub
|
|
112
|
+
Config.stub(:get) { |arg| arg == :url_nesting ? true : Config.parameter(arg) }
|
|
113
113
|
PagesController.any_instance.stub(:multi_language?).and_return(true)
|
|
114
114
|
end
|
|
115
115
|
|
|
@@ -123,7 +123,7 @@ module Alchemy
|
|
|
123
123
|
context "if requested page is unpublished" do
|
|
124
124
|
|
|
125
125
|
before do
|
|
126
|
-
Config.stub
|
|
126
|
+
Config.stub(:get) { |arg| arg == :url_nesting ? false : Config.parameter(arg) }
|
|
127
127
|
public_page_1.update_attributes(:public => false, :name => 'Not Public', :urlname => '')
|
|
128
128
|
public_child
|
|
129
129
|
end
|
|
@@ -170,7 +170,7 @@ module Alchemy
|
|
|
170
170
|
|
|
171
171
|
context "wrong language requested" do
|
|
172
172
|
|
|
173
|
-
before {
|
|
173
|
+
before { Alchemy.user_class.stub(:admins).and_return([1, 2]) }
|
|
174
174
|
|
|
175
175
|
it "should render 404 if urlname and lang parameter do not belong to same page" do
|
|
176
176
|
FactoryGirl.create(:english)
|
|
@@ -193,7 +193,7 @@ module Alchemy
|
|
|
193
193
|
|
|
194
194
|
before do
|
|
195
195
|
PagesController.any_instance.stub(:multi_language?).and_return(false)
|
|
196
|
-
Config.stub
|
|
196
|
+
Config.stub(:get) { |arg| arg == :url_nesting ? false : Config.parameter(arg) }
|
|
197
197
|
end
|
|
198
198
|
|
|
199
199
|
it "should redirect from nested language code url to normal url" do
|
|
@@ -237,7 +237,7 @@ module Alchemy
|
|
|
237
237
|
describe "Handling of non-existing pages" do
|
|
238
238
|
|
|
239
239
|
before do
|
|
240
|
-
|
|
240
|
+
Alchemy.user_class.stub(:admins).and_return([1, 2]) # We need a admin user or the signup page will show up
|
|
241
241
|
visit "/non-existing-page"
|
|
242
242
|
end
|
|
243
243
|
|
|
@@ -247,12 +247,5 @@ module Alchemy
|
|
|
247
247
|
|
|
248
248
|
end
|
|
249
249
|
|
|
250
|
-
context "with invalid byte code char in urlname parameter" do
|
|
251
|
-
it "should render page not found" do
|
|
252
|
-
visit '/%ed'
|
|
253
|
-
page.status_code.should == 404
|
|
254
|
-
end
|
|
255
|
-
end
|
|
256
|
-
|
|
257
250
|
end
|
|
258
251
|
end
|
|
@@ -2,10 +2,10 @@ require 'spec_helper'
|
|
|
2
2
|
|
|
3
3
|
describe 'Picture renderung security', :js => true do
|
|
4
4
|
|
|
5
|
-
let(:picture) { Alchemy::Picture.create(:image_file => File.new(File.expand_path('../../
|
|
5
|
+
let(:picture) { Alchemy::Picture.create(:image_file => File.new(File.expand_path('../../fixtures/image.png', __FILE__))) }
|
|
6
6
|
|
|
7
7
|
# Prevent the signup view from being rendered.
|
|
8
|
-
before { Alchemy
|
|
8
|
+
before { Alchemy.user_class.stub(:count).and_return 1 }
|
|
9
9
|
|
|
10
10
|
context "passing no security token" do
|
|
11
11
|
|
|
@@ -1,51 +1,12 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
|
-
describe "Security
|
|
3
|
+
describe "Security." do
|
|
4
|
+
before { Alchemy::Page.root.children.destroy_all }
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
context "If no user is present" do
|
|
11
|
-
|
|
12
|
-
it "render the signup view" do
|
|
13
|
-
visit '/'
|
|
14
|
-
current_path.should == '/admin/signup'
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
context "If user is present" do
|
|
19
|
-
|
|
20
|
-
before do
|
|
21
|
-
create_admin_user
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
it "a visitor should not be able to signup" do
|
|
25
|
-
visit '/admin/signup'
|
|
26
|
-
within('#alchemy_greeting') { page.should_not have_content('have to signup') }
|
|
6
|
+
context "If user is not logged in" do
|
|
7
|
+
it "should see login form" do
|
|
8
|
+
visit '/admin/dashboard'
|
|
9
|
+
current_path.should == Alchemy.login_path
|
|
27
10
|
end
|
|
28
|
-
|
|
29
|
-
context "that is not logged in" do
|
|
30
|
-
it "should see login-form" do
|
|
31
|
-
visit '/admin/dashboard'
|
|
32
|
-
current_path.should == '/admin/login'
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
context "that is already logged in" do
|
|
37
|
-
|
|
38
|
-
before do
|
|
39
|
-
login_into_alchemy
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
it "should be redirected to dashboard" do
|
|
43
|
-
visit '/admin/login'
|
|
44
|
-
current_path.should == '/admin/dashboard'
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
end
|
|
48
|
-
|
|
49
11
|
end
|
|
50
|
-
|
|
51
12
|
end
|
|
@@ -1,57 +1,48 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe "Translation integration" do
|
|
4
|
-
|
|
5
4
|
context "in admin backend" do
|
|
6
|
-
|
|
7
|
-
before do
|
|
8
|
-
authorize_as_admin
|
|
9
|
-
end
|
|
5
|
+
before { authorize_as_admin(mock_model('User', alchemy_roles: %w(admin), role_symbols: [:admin], language: 'de', name: 'Peter')) }
|
|
10
6
|
|
|
11
7
|
it "should be possible to set the locale of the admin backend via params" do
|
|
12
|
-
visit admin_dashboard_path(:
|
|
8
|
+
visit admin_dashboard_path(locale: 'de')
|
|
13
9
|
page.should have_content('Willkommen')
|
|
14
10
|
end
|
|
15
11
|
|
|
16
12
|
it "should store the current locale in the session" do
|
|
17
|
-
visit admin_dashboard_path(:
|
|
13
|
+
visit admin_dashboard_path(locale: 'de')
|
|
18
14
|
visit admin_dashboard_path
|
|
19
15
|
page.should have_content('Willkommen')
|
|
20
16
|
end
|
|
21
17
|
|
|
22
18
|
it "should be possible to change the current locale in the session" do
|
|
23
|
-
visit admin_dashboard_path(:
|
|
19
|
+
visit admin_dashboard_path(locale: 'de')
|
|
24
20
|
page.should have_content('Willkommen')
|
|
25
|
-
visit admin_dashboard_path(:
|
|
21
|
+
visit admin_dashboard_path(locale: 'en')
|
|
26
22
|
page.should have_content('Welcome')
|
|
27
23
|
end
|
|
28
24
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
context 'with unknown locale' do
|
|
26
|
+
it "it uses the users default language" do
|
|
27
|
+
visit admin_dashboard_path(locale: 'ko')
|
|
28
|
+
page.should have_content('Willkommen')
|
|
29
|
+
end
|
|
32
30
|
end
|
|
33
31
|
|
|
34
32
|
context "if no other parameter is given" do
|
|
35
33
|
it "should use the current users language setting" do
|
|
36
|
-
Alchemy::User.first.update_attributes!(language: 'de')
|
|
37
34
|
visit admin_dashboard_path
|
|
38
35
|
page.should have_content('Willkommen')
|
|
39
36
|
end
|
|
40
37
|
end
|
|
41
|
-
|
|
42
38
|
end
|
|
43
39
|
|
|
44
40
|
context "with translated header" do
|
|
45
|
-
|
|
46
|
-
before do
|
|
47
|
-
Capybara.current_driver = :rack_test_translated_header
|
|
48
|
-
end
|
|
41
|
+
before { Capybara.current_driver = :rack_test_translated_header }
|
|
49
42
|
|
|
50
43
|
it "should use the browsers language setting if no other parameter is given" do
|
|
51
44
|
visit root_path
|
|
52
45
|
::I18n.locale.should == :de
|
|
53
46
|
end
|
|
54
|
-
|
|
55
47
|
end
|
|
56
|
-
|
|
57
48
|
end
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -2,46 +2,35 @@ require 'spec_helper'
|
|
|
2
2
|
|
|
3
3
|
module Alchemy
|
|
4
4
|
describe Admin::BaseHelper do
|
|
5
|
-
|
|
6
5
|
context "maximum amount of images option" do
|
|
6
|
+
subject { helper.max_image_count }
|
|
7
7
|
|
|
8
|
-
before(
|
|
9
|
-
@options = {}
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
context "with max_images option" do
|
|
13
|
-
|
|
14
|
-
it "should return nil for empty string" do
|
|
15
|
-
@options[:max_images] = ""
|
|
16
|
-
max_image_count.should be(nil)
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
it "should return an integer for string number" do
|
|
20
|
-
@options[:max_images] = "1"
|
|
21
|
-
max_image_count.should be(1)
|
|
22
|
-
end
|
|
8
|
+
before { helper.instance_variable_set('@options', options) }
|
|
23
9
|
|
|
10
|
+
context "with max_images option set to emtpy string" do
|
|
11
|
+
let(:options) { {max_images: ""} }
|
|
12
|
+
it { should eq(nil) }
|
|
24
13
|
end
|
|
25
14
|
|
|
26
|
-
context "with
|
|
27
|
-
|
|
28
|
-
it
|
|
29
|
-
|
|
30
|
-
max_image_count.should be(nil)
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
it "should return an integer for string number" do
|
|
34
|
-
@options[:maximum_amount_of_images] = "1"
|
|
35
|
-
max_image_count.should be(1)
|
|
36
|
-
end
|
|
15
|
+
context "with max_images option set to '1'" do
|
|
16
|
+
let(:options) { {max_images: "1"} }
|
|
17
|
+
it { should eq(1) }
|
|
18
|
+
end
|
|
37
19
|
|
|
20
|
+
context "with maximum_amount_of_images option set to emtpy string" do
|
|
21
|
+
let(:options) { {maximum_amount_of_images: ""} }
|
|
22
|
+
it { should eq(nil) }
|
|
38
23
|
end
|
|
39
24
|
|
|
25
|
+
context "with maximum_amount_of_images option set to '1'" do
|
|
26
|
+
let(:options) { {maximum_amount_of_images: "1"} }
|
|
27
|
+
it { should eq(1) }
|
|
28
|
+
end
|
|
40
29
|
end
|
|
41
30
|
|
|
42
31
|
describe "#merge_params" do
|
|
43
|
-
before
|
|
44
|
-
controller.stub
|
|
32
|
+
before do
|
|
33
|
+
controller.stub(:params).and_return({:first => '1', :second => '2'})
|
|
45
34
|
end
|
|
46
35
|
|
|
47
36
|
it "returns a hash that contains the current params and additional params given as attributes" do
|
|
@@ -50,9 +39,10 @@ module Alchemy
|
|
|
50
39
|
end
|
|
51
40
|
|
|
52
41
|
describe "#merge_params_without" do
|
|
53
|
-
before
|
|
54
|
-
controller.stub
|
|
42
|
+
before do
|
|
43
|
+
controller.stub(:params).and_return({:first => '1', :second => '2'})
|
|
55
44
|
end
|
|
45
|
+
|
|
56
46
|
it "can delete a single param" do
|
|
57
47
|
helper.merge_params_without(:second).should == {:first => '1'}
|
|
58
48
|
end
|
|
@@ -72,9 +62,8 @@ module Alchemy
|
|
|
72
62
|
end
|
|
73
63
|
|
|
74
64
|
describe "#merge_params_only" do
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
controller.stub!(:params).and_return({:first => '1', :second => '2', :third => '3'})
|
|
65
|
+
before do
|
|
66
|
+
controller.stub(:params).and_return({:first => '1', :second => '2', :third => '3'})
|
|
78
67
|
end
|
|
79
68
|
|
|
80
69
|
it "can keep a single param" do
|
|
@@ -93,7 +82,6 @@ module Alchemy
|
|
|
93
82
|
helper.merge_params_only([:first])
|
|
94
83
|
controller.params.should == {:first => '1', :second => '2', :third => '3'}
|
|
95
84
|
end
|
|
96
|
-
|
|
97
85
|
end
|
|
98
86
|
|
|
99
87
|
describe '#toolbar_button' do
|
|
@@ -104,7 +92,7 @@ module Alchemy
|
|
|
104
92
|
|
|
105
93
|
it "renders a toolbar button" do
|
|
106
94
|
helper.toolbar_button(
|
|
107
|
-
url:
|
|
95
|
+
url: admin_dashboard_path
|
|
108
96
|
).should match /<div.+class="button_with_label/
|
|
109
97
|
end
|
|
110
98
|
end
|
|
@@ -116,7 +104,7 @@ module Alchemy
|
|
|
116
104
|
|
|
117
105
|
it "returns empty string" do
|
|
118
106
|
helper.toolbar_button(
|
|
119
|
-
url:
|
|
107
|
+
url: admin_dashboard_path
|
|
120
108
|
).should be_empty
|
|
121
109
|
end
|
|
122
110
|
end
|
|
@@ -128,7 +116,7 @@ module Alchemy
|
|
|
128
116
|
|
|
129
117
|
it "returns the button" do
|
|
130
118
|
helper.toolbar_button(
|
|
131
|
-
url:
|
|
119
|
+
url: admin_dashboard_path,
|
|
132
120
|
skip_permission_check: true
|
|
133
121
|
).should match /<div.+class="button_with_label/
|
|
134
122
|
end
|
|
@@ -142,24 +130,24 @@ module Alchemy
|
|
|
142
130
|
it "returns reads the permission from url" do
|
|
143
131
|
helper.should_receive(:permission_array_from_url)
|
|
144
132
|
helper.toolbar_button(
|
|
145
|
-
url:
|
|
133
|
+
url: admin_dashboard_path,
|
|
146
134
|
if_permitted_to: ''
|
|
147
135
|
).should_not be_empty
|
|
148
136
|
end
|
|
149
137
|
end
|
|
150
138
|
|
|
151
139
|
context "with overlay option set to false" do
|
|
152
|
-
before
|
|
140
|
+
before do
|
|
153
141
|
helper.stub(:permitted_to?).and_return(true)
|
|
154
142
|
helper.should_receive(:permission_array_from_url)
|
|
155
|
-
|
|
143
|
+
end
|
|
156
144
|
|
|
157
145
|
it "renders a normal link" do
|
|
158
146
|
button = helper.toolbar_button(
|
|
159
|
-
url:
|
|
147
|
+
url: admin_dashboard_path,
|
|
160
148
|
overlay: false
|
|
161
149
|
)
|
|
162
|
-
button.should match /<a.+href="#{
|
|
150
|
+
button.should match /<a.+href="#{admin_dashboard_path}"/
|
|
163
151
|
button.should_not match /data-alchemy-overlay/
|
|
164
152
|
end
|
|
165
153
|
end
|
|
@@ -3,8 +3,10 @@ require 'spec_helper'
|
|
|
3
3
|
describe Alchemy::Admin::PagesHelper do
|
|
4
4
|
|
|
5
5
|
describe '#sitemap_folder_link' do
|
|
6
|
-
let(:user) {
|
|
7
|
-
|
|
6
|
+
let(:user) { mock_model('User', alchemy_roles: %w(admin), role_symbols: [:admin]) }
|
|
7
|
+
|
|
8
|
+
before { helper.stub(:current_alchemy_user).and_return(user) }
|
|
9
|
+
|
|
8
10
|
subject { helper.sitemap_folder_link(page) }
|
|
9
11
|
|
|
10
12
|
context "with folded page" do
|