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/lib/alchemy/upgrader.rb
CHANGED
|
@@ -5,13 +5,14 @@ module Alchemy
|
|
|
5
5
|
|
|
6
6
|
Dir["#{File.dirname(__FILE__)}/upgrader/*.rb"].each { |f| require f }
|
|
7
7
|
|
|
8
|
-
extend
|
|
9
|
-
extend
|
|
10
|
-
extend
|
|
11
|
-
extend
|
|
12
|
-
extend
|
|
13
|
-
extend
|
|
14
|
-
extend
|
|
8
|
+
extend Alchemy::Upgrader::TwoPointNine
|
|
9
|
+
extend Alchemy::Upgrader::TwoPointSix
|
|
10
|
+
extend Alchemy::Upgrader::TwoPointFive
|
|
11
|
+
extend Alchemy::Upgrader::TwoPointFour
|
|
12
|
+
extend Alchemy::Upgrader::TwoPointThree
|
|
13
|
+
extend Alchemy::Upgrader::TwoPointTwo
|
|
14
|
+
extend Alchemy::Upgrader::TwoPointOne
|
|
15
|
+
extend Alchemy::Upgrader::TwoPointZero
|
|
15
16
|
|
|
16
17
|
class << self
|
|
17
18
|
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
module Alchemy
|
|
2
|
+
module Upgrader::TwoPointNine
|
|
3
|
+
|
|
4
|
+
private
|
|
5
|
+
|
|
6
|
+
def alchemy_29_todos
|
|
7
|
+
notice = <<-NOTE
|
|
8
|
+
|
|
9
|
+
Alchemy User Class Removed
|
|
10
|
+
--------------------------
|
|
11
|
+
|
|
12
|
+
We removed the user model from the Alchemy core!
|
|
13
|
+
|
|
14
|
+
You have to provide your own user model or
|
|
15
|
+
add the `alchemy-devise` gem to your Gemfile.
|
|
16
|
+
|
|
17
|
+
If you want to use the default user class from Alchemy:
|
|
18
|
+
|
|
19
|
+
# Gemfile
|
|
20
|
+
gem 'alchemy-devise', '~> 1.1'
|
|
21
|
+
|
|
22
|
+
$ bin/rake alchemy_devise:install:migrations db:migrate
|
|
23
|
+
|
|
24
|
+
In order to add your own user class to Alchemy, please
|
|
25
|
+
make shure it meets the API:
|
|
26
|
+
|
|
27
|
+
https://github.com/magiclabs/alchemy_cms/blob/2.9-stable/lib/alchemy/auth_accessors.rb
|
|
28
|
+
|
|
29
|
+
NOTE
|
|
30
|
+
todo notice
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Adds the model stamper ability to the provided user class
|
|
2
|
+
#
|
|
3
|
+
# It only adds it, if the user model is a active_record model.
|
|
4
|
+
#
|
|
5
|
+
if Alchemy.user_class < ActiveRecord::Base
|
|
6
|
+
Alchemy.user_class.class_eval do
|
|
7
|
+
model_stamper
|
|
8
|
+
stampable stamper_class_name: Alchemy.user_class_name
|
|
9
|
+
end
|
|
10
|
+
end
|
data/lib/alchemy/version.rb
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
require File.expand_path('../../../alchemy/version', __FILE__)
|
|
3
3
|
|
|
4
4
|
gem 'alchemy_cms', "~> #{Alchemy::VERSION}"
|
|
5
|
+
gem 'alchemy-devise', github: 'magiclabs/alchemy-devise', branch: '1.1-stable'
|
|
5
6
|
|
|
6
7
|
if yes?("\nDo you want to use Capistrano for deployment? (y/N)")
|
|
7
8
|
gem 'capistrano', group: 'development'
|
data/lib/tasks/alchemy/db.rake
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
require 'alchemy/seeder'
|
|
2
|
+
require 'alchemy/tasks/helpers'
|
|
3
|
+
include Alchemy::Tasks::Helpers
|
|
2
4
|
|
|
3
5
|
namespace :alchemy do
|
|
4
6
|
namespace :db do
|
|
@@ -8,13 +10,11 @@ namespace :alchemy do
|
|
|
8
10
|
Alchemy::Seeder.seed!
|
|
9
11
|
end
|
|
10
12
|
|
|
11
|
-
desc "Dumps the database to STDOUT (Pass DUMP_FILENAME to store the dump into a file).
|
|
13
|
+
desc "Dumps the database to STDOUT (Pass DUMP_FILENAME to store the dump into a file)."
|
|
12
14
|
task :dump => :environment do
|
|
13
|
-
db_conf = Rails.configuration.database_configuration.fetch(Rails.env)
|
|
14
|
-
raise "Sorry, but Alchemy only supports MySQL database dumping at the moment." unless db_conf['adapter'] =~ /mysql/
|
|
15
15
|
dump_store = ENV['DUMP_FILENAME'] ? " > #{ENV['DUMP_FILENAME']}" : ""
|
|
16
|
-
|
|
17
|
-
system
|
|
16
|
+
dump_cmd = database_dump_command(database_config['adapter'])
|
|
17
|
+
system "#{dump_cmd}#{dump_store}"
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
end
|
|
@@ -8,7 +8,7 @@ module Alchemy
|
|
|
8
8
|
before do
|
|
9
9
|
sign_in(admin_user)
|
|
10
10
|
end
|
|
11
|
-
|
|
11
|
+
|
|
12
12
|
describe "#index" do
|
|
13
13
|
|
|
14
14
|
it "should always paginate the records" do
|
|
@@ -44,9 +44,9 @@ module Alchemy
|
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
end
|
|
47
|
-
|
|
47
|
+
|
|
48
48
|
describe "#new" do
|
|
49
|
-
|
|
49
|
+
|
|
50
50
|
context "in overlay" do
|
|
51
51
|
|
|
52
52
|
before do
|
|
@@ -2,59 +2,81 @@ require 'spec_helper'
|
|
|
2
2
|
|
|
3
3
|
module Alchemy
|
|
4
4
|
describe Admin::DashboardController do
|
|
5
|
+
let(:user) { admin_user }
|
|
5
6
|
|
|
6
|
-
before
|
|
7
|
-
sign_in(admin_user)
|
|
8
|
-
end
|
|
7
|
+
before { sign_in(user) }
|
|
9
8
|
|
|
10
9
|
describe '#index' do
|
|
11
10
|
before do
|
|
12
11
|
Page.stub_chain(:from_current_site, :all_last_edited_from).and_return([])
|
|
13
12
|
Page.stub_chain(:from_current_site, :all_locked).and_return([])
|
|
14
|
-
User.stub
|
|
15
|
-
|
|
13
|
+
User.stub(:logged_in).and_return([user])
|
|
14
|
+
user.stub(:sign_in_count).and_return(5)
|
|
16
15
|
end
|
|
17
16
|
|
|
18
|
-
it "
|
|
17
|
+
it "assigns @last_edited_pages" do
|
|
19
18
|
get :index
|
|
20
19
|
expect(assigns(:last_edited_pages)).to eq([])
|
|
21
20
|
end
|
|
22
21
|
|
|
23
|
-
it "
|
|
22
|
+
it "assigns @locked_pages" do
|
|
24
23
|
get :index
|
|
25
24
|
expect(assigns(:locked_pages)).to eq([])
|
|
26
25
|
end
|
|
27
26
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
context 'with user class having logged_in scope' do
|
|
28
|
+
context 'with other users online' do
|
|
29
|
+
let(:another_user) { mock_model('User') }
|
|
30
|
+
|
|
31
|
+
before do
|
|
32
|
+
Alchemy.user_class.should_receive(:logged_in).and_return([another_user])
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it "assigns @online_users" do
|
|
36
|
+
get :index
|
|
37
|
+
expect(assigns(:online_users)).to eq([another_user])
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
context 'without other users online' do
|
|
42
|
+
it "does not assign @online_users" do
|
|
43
|
+
get :index
|
|
44
|
+
expect(assigns(:online_users)).to eq([])
|
|
45
|
+
end
|
|
46
|
+
end
|
|
31
47
|
end
|
|
32
48
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
49
|
+
context 'user having signed in before' do
|
|
50
|
+
before do
|
|
51
|
+
user.should_receive(:sign_in_count).and_return(5)
|
|
52
|
+
user.should_receive(:last_sign_in_at).and_return(Time.now)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
it "assigns @first_time" do
|
|
56
|
+
get :index
|
|
57
|
+
expect(assigns(:first_time)).to eq(false)
|
|
58
|
+
end
|
|
36
59
|
end
|
|
37
60
|
|
|
38
|
-
it "
|
|
61
|
+
it "assigns @sites" do
|
|
39
62
|
get :index
|
|
40
63
|
expect(assigns(:sites)).to eq(Site.scoped)
|
|
41
64
|
end
|
|
42
65
|
end
|
|
43
|
-
|
|
66
|
+
|
|
44
67
|
describe '#info' do
|
|
45
|
-
it "
|
|
68
|
+
it "assigns @alchemy_version with the current Alchemy version" do
|
|
46
69
|
get :info
|
|
47
70
|
expect(assigns(:alchemy_version)).to eq(Alchemy.version)
|
|
48
71
|
end
|
|
49
72
|
end
|
|
50
73
|
|
|
51
74
|
describe '#update_check' do
|
|
52
|
-
|
|
53
75
|
context "if current Alchemy version equals the latest released version or it is newer" do
|
|
54
|
-
before
|
|
55
|
-
controller.stub
|
|
56
|
-
Alchemy.stub
|
|
57
|
-
|
|
76
|
+
before {
|
|
77
|
+
controller.stub(:latest_alchemy_version).and_return('2.6')
|
|
78
|
+
Alchemy.stub(:version).and_return("2.6")
|
|
79
|
+
}
|
|
58
80
|
|
|
59
81
|
it "should render 'false'" do
|
|
60
82
|
get :update_check
|
|
@@ -63,10 +85,10 @@ module Alchemy
|
|
|
63
85
|
end
|
|
64
86
|
|
|
65
87
|
context "if current Alchemy version is older than latest released version" do
|
|
66
|
-
before
|
|
67
|
-
controller.stub
|
|
68
|
-
Alchemy.stub
|
|
69
|
-
|
|
88
|
+
before {
|
|
89
|
+
controller.stub(:latest_alchemy_version).and_return('2.6')
|
|
90
|
+
Alchemy.stub(:version).and_return("2.5")
|
|
91
|
+
}
|
|
70
92
|
|
|
71
93
|
it "should render 'true'" do
|
|
72
94
|
get :update_check
|
|
@@ -75,12 +97,12 @@ module Alchemy
|
|
|
75
97
|
end
|
|
76
98
|
|
|
77
99
|
context "requesting rubygems.org" do
|
|
78
|
-
before
|
|
100
|
+
before {
|
|
79
101
|
Net::HTTP.any_instance.stub(:request).and_return(
|
|
80
102
|
OpenStruct.new({code: '200', body: '[{"number": "2.6"}, {"number": "2.5"}]'})
|
|
81
103
|
)
|
|
82
|
-
Alchemy.stub
|
|
83
|
-
|
|
104
|
+
Alchemy.stub(:version).and_return("2.6")
|
|
105
|
+
}
|
|
84
106
|
|
|
85
107
|
it "should have response code of 200" do
|
|
86
108
|
get :update_check
|
|
@@ -89,12 +111,12 @@ module Alchemy
|
|
|
89
111
|
end
|
|
90
112
|
|
|
91
113
|
context "requesting github.com" do
|
|
92
|
-
before
|
|
93
|
-
controller.stub
|
|
114
|
+
before {
|
|
115
|
+
controller.stub(:query_rubygems).and_return(OpenStruct.new({code: '503'}))
|
|
94
116
|
Net::HTTP.any_instance.stub(:request).and_return(
|
|
95
117
|
OpenStruct.new({code: '200', body: '[{"name": "2.6"}, {"name": "2.5"}]'})
|
|
96
118
|
)
|
|
97
|
-
|
|
119
|
+
}
|
|
98
120
|
|
|
99
121
|
it "should have response code of 200" do
|
|
100
122
|
get :update_check
|
|
@@ -103,18 +125,17 @@ module Alchemy
|
|
|
103
125
|
end
|
|
104
126
|
|
|
105
127
|
context "rubygems.org and github.com are unavailable" do
|
|
106
|
-
before
|
|
128
|
+
before {
|
|
107
129
|
Net::HTTP.any_instance.stub(:request).and_return(
|
|
108
130
|
OpenStruct.new({code: '503'})
|
|
109
131
|
)
|
|
110
|
-
|
|
132
|
+
}
|
|
111
133
|
|
|
112
134
|
it "should have status code 503" do
|
|
113
135
|
get :update_check
|
|
114
136
|
expect(response.code).to eq('503')
|
|
115
137
|
end
|
|
116
138
|
end
|
|
117
|
-
|
|
118
139
|
end
|
|
119
140
|
|
|
120
141
|
end
|
|
@@ -111,7 +111,7 @@ module Alchemy
|
|
|
111
111
|
before(:each) do
|
|
112
112
|
@element = FactoryGirl.create(:element, :public => false, :position => nil, :page_id => 58, :cell_id => 32)
|
|
113
113
|
# Because of a before_create filter it can not be created with a nil position and needs to be trashed here
|
|
114
|
-
@element.trash
|
|
114
|
+
@element.trash!
|
|
115
115
|
end
|
|
116
116
|
|
|
117
117
|
it "should set a new position to the element" do
|
|
@@ -41,7 +41,7 @@ module Alchemy
|
|
|
41
41
|
before do
|
|
42
42
|
picture.image_file_width = 300
|
|
43
43
|
picture.image_file_height = 250
|
|
44
|
-
essence.should_receive(:picture).and_return(picture)
|
|
44
|
+
essence.should_receive(:picture).any_number_of_times.and_return(picture)
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
context 'with no render_size present in essence' do
|
|
@@ -67,14 +67,30 @@ module Alchemy
|
|
|
67
67
|
end
|
|
68
68
|
|
|
69
69
|
context 'with render_size present in essence' do
|
|
70
|
-
|
|
70
|
+
it "sets sizes from these values" do
|
|
71
71
|
essence.stub(:render_size).and_return('30x25')
|
|
72
|
-
end
|
|
73
72
|
|
|
74
|
-
it "sets sizes from these values" do
|
|
75
73
|
get :crop, id: 1
|
|
76
|
-
expect(assigns(:size_x)).to eq(
|
|
77
|
-
expect(assigns(:size_y)).to eq(
|
|
74
|
+
expect(assigns(:size_x)).to eq(30)
|
|
75
|
+
expect(assigns(:size_y)).to eq(25)
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
context 'when width or height is not fixed' do
|
|
79
|
+
it 'infers the height from the image file preserving the aspect ratio' do
|
|
80
|
+
essence.stub(:render_size).and_return('30')
|
|
81
|
+
|
|
82
|
+
get :crop, id: 1
|
|
83
|
+
expect(assigns(:size_x)).to eq(30)
|
|
84
|
+
expect(assigns(:size_y)).to eq(25)
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
it 'infers the height from the image file preserving the aspect ratio' do
|
|
88
|
+
essence.stub(:render_size).and_return('x25')
|
|
89
|
+
|
|
90
|
+
get :crop, id: 1
|
|
91
|
+
expect(assigns(:size_x)).to eq(30)
|
|
92
|
+
expect(assigns(:size_y)).to eq(25)
|
|
93
|
+
end
|
|
78
94
|
end
|
|
79
95
|
end
|
|
80
96
|
|
|
@@ -3,9 +3,17 @@ require 'spec_helper'
|
|
|
3
3
|
|
|
4
4
|
module Alchemy
|
|
5
5
|
describe Admin::PagesController do
|
|
6
|
+
let(:user) { editor_user }
|
|
7
|
+
before { sign_in(user) }
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
+
describe '#index' do
|
|
10
|
+
let(:language_root) { FactoryGirl.build_stubbed(:language_root_page) }
|
|
11
|
+
|
|
12
|
+
it "assigns @page_root variable" do
|
|
13
|
+
Page.should_receive(:language_root_for).with(1).and_return(language_root)
|
|
14
|
+
get :index
|
|
15
|
+
assigns(:page_root).should be(language_root)
|
|
16
|
+
end
|
|
9
17
|
end
|
|
10
18
|
|
|
11
19
|
describe "#flush" do
|
|
@@ -21,11 +29,9 @@ module Alchemy
|
|
|
21
29
|
context "pages in clipboard" do
|
|
22
30
|
|
|
23
31
|
let(:clipboard) { session[:clipboard] = Clipboard.new }
|
|
24
|
-
let(:page) { mock_model(
|
|
32
|
+
let(:page) { mock_model(Alchemy::Page, name: 'Foobar') }
|
|
25
33
|
|
|
26
|
-
before
|
|
27
|
-
clipboard[:pages] = [{id: page.id, action: 'copy'}]
|
|
28
|
-
end
|
|
34
|
+
before { clipboard[:pages] = [{id: page.id, action: 'copy'}] }
|
|
29
35
|
|
|
30
36
|
it "should load all pages from clipboard" do
|
|
31
37
|
get :new, {page_id: page.id, format: :js}
|
|
@@ -36,21 +42,20 @@ module Alchemy
|
|
|
36
42
|
end
|
|
37
43
|
|
|
38
44
|
describe '#show' do
|
|
39
|
-
|
|
40
|
-
let(:page) { mock_model('Page', language_code: 'nl') }
|
|
45
|
+
let(:page) { mock_model(Alchemy::Page, language_code: 'nl') }
|
|
41
46
|
|
|
42
47
|
before do
|
|
43
|
-
Page.
|
|
44
|
-
Page.stub
|
|
48
|
+
Page.should_receive(:find).with("#{page.id}").and_return(page)
|
|
49
|
+
Page.stub(:language_root_for).and_return(mock_model(Alchemy::Page))
|
|
45
50
|
end
|
|
46
51
|
|
|
47
52
|
it "should assign @preview_mode with true" do
|
|
48
|
-
|
|
53
|
+
get :show, id: page.id
|
|
49
54
|
expect(assigns(:preview_mode)).to eq(true)
|
|
50
55
|
end
|
|
51
56
|
|
|
52
57
|
it "should set the I18n locale to the pages language code" do
|
|
53
|
-
|
|
58
|
+
get :show, id: page.id
|
|
54
59
|
expect(::I18n.locale).to eq(:nl)
|
|
55
60
|
end
|
|
56
61
|
end
|
|
@@ -151,7 +156,7 @@ module Alchemy
|
|
|
151
156
|
let(:page) { mock_model(Page, {name: 'Foobar', slug: 'foobar', urlname: 'root/parent/foobar', redirects_to_external?: false, layoutpage?: false, taggable?: false}) }
|
|
152
157
|
|
|
153
158
|
it "should always show the slug" do
|
|
154
|
-
Page.stub
|
|
159
|
+
Page.stub(:find).and_return(page)
|
|
155
160
|
get :configure, {id: page.id, format: :js}
|
|
156
161
|
response.body.should match /value="foobar"/
|
|
157
162
|
end
|
|
@@ -160,30 +165,21 @@ module Alchemy
|
|
|
160
165
|
|
|
161
166
|
describe '#create' do
|
|
162
167
|
let(:language) { mock_model('Language', code: 'kl') }
|
|
163
|
-
let(:parent) { mock_model(
|
|
164
|
-
let(:page_params)
|
|
165
|
-
{parent_id: parent.id, name: 'new Page'}
|
|
166
|
-
end
|
|
168
|
+
let(:parent) { mock_model(Alchemy::Page, language: language) }
|
|
169
|
+
let(:page_params) { {parent_id: parent.id, name: 'new Page'} }
|
|
167
170
|
|
|
168
|
-
context "" do
|
|
171
|
+
context "a new page" do
|
|
169
172
|
before do
|
|
170
173
|
Page.any_instance.stub(:set_language_from_parent_or_default_language)
|
|
171
|
-
Page.any_instance.stub(save
|
|
174
|
+
Page.any_instance.stub(:save).and_return(true)
|
|
172
175
|
end
|
|
173
176
|
|
|
174
|
-
it "
|
|
175
|
-
controller.stub
|
|
177
|
+
it "is nested under given parent" do
|
|
178
|
+
controller.stub(:edit_admin_page_path).and_return('bla')
|
|
176
179
|
post :create, {page: page_params, format: :js}
|
|
177
180
|
expect(assigns(:page).parent_id).to eq(parent.id)
|
|
178
181
|
end
|
|
179
182
|
|
|
180
|
-
it "redirects to edit page template" do
|
|
181
|
-
page = mock_model('Page')
|
|
182
|
-
controller.should_receive(:edit_admin_page_path).and_return('bla')
|
|
183
|
-
post :create, page: page_params
|
|
184
|
-
response.should redirect_to('bla')
|
|
185
|
-
end
|
|
186
|
-
|
|
187
183
|
context "if new page can not be saved" do
|
|
188
184
|
it "should redirect to admin_pages_path" do
|
|
189
185
|
Page.any_instance.stub(:save).and_return(false)
|
|
@@ -198,14 +194,14 @@ module Alchemy
|
|
|
198
194
|
end
|
|
199
195
|
|
|
200
196
|
it "should redirect to given url" do
|
|
201
|
-
post :create, page: page_params, redirect_to:
|
|
202
|
-
response.should redirect_to(
|
|
197
|
+
post :create, page: page_params, redirect_to: admin_pictures_path
|
|
198
|
+
response.should redirect_to(admin_pictures_path)
|
|
203
199
|
end
|
|
204
200
|
|
|
205
201
|
context "but new page can not be saved" do
|
|
206
202
|
it "should redirect to admin_pages_path" do
|
|
207
203
|
Page.any_instance.stub(:save).and_return(false)
|
|
208
|
-
post :create, page: {}, redirect_to:
|
|
204
|
+
post :create, page: {}, redirect_to: Alchemy.login_path
|
|
209
205
|
response.should redirect_to(admin_pages_path)
|
|
210
206
|
end
|
|
211
207
|
end
|
|
@@ -221,7 +217,7 @@ module Alchemy
|
|
|
221
217
|
end
|
|
222
218
|
|
|
223
219
|
context "with paste_from_clipboard in parameters" do
|
|
224
|
-
let(:page_in_clipboard) { mock_model(
|
|
220
|
+
let(:page_in_clipboard) { mock_model(Alchemy::Page) }
|
|
225
221
|
|
|
226
222
|
before do
|
|
227
223
|
Page.stub!(:find_by_id).with(parent.id).and_return(parent)
|
|
@@ -279,12 +275,10 @@ module Alchemy
|
|
|
279
275
|
let(:clipboard) { session[:clipboard] = Clipboard.new }
|
|
280
276
|
let(:page) { FactoryGirl.create(:public_page) }
|
|
281
277
|
|
|
282
|
-
before
|
|
283
|
-
clipboard[:pages] = [{id: page.id}]
|
|
284
|
-
end
|
|
278
|
+
before { clipboard[:pages] = [{id: page.id}] }
|
|
285
279
|
|
|
286
280
|
it "should also remove the page from clipboard" do
|
|
287
|
-
post :destroy, {id: page.id, _method: :delete}
|
|
281
|
+
post :destroy, {id: page.id, _method: :delete, format: 'js'}
|
|
288
282
|
clipboard[:pages].should be_empty
|
|
289
283
|
end
|
|
290
284
|
|
|
@@ -306,7 +300,7 @@ module Alchemy
|
|
|
306
300
|
end
|
|
307
301
|
|
|
308
302
|
describe '#visit' do
|
|
309
|
-
let(:page) { mock_model(
|
|
303
|
+
let(:page) { mock_model(Alchemy::Page, urlname: 'home') }
|
|
310
304
|
|
|
311
305
|
before do
|
|
312
306
|
Page.stub!(:find).with("#{page.id}").and_return(page)
|
|
@@ -320,39 +314,30 @@ module Alchemy
|
|
|
320
314
|
end
|
|
321
315
|
|
|
322
316
|
describe '#fold' do
|
|
323
|
-
let(:page) { mock_model(
|
|
324
|
-
|
|
325
|
-
before do
|
|
326
|
-
Page.stub!(:find).with(page.id).and_return(page)
|
|
327
|
-
end
|
|
317
|
+
let(:page) { mock_model(Alchemy::Page) }
|
|
318
|
+
before { Page.stub(:find).and_return(page) }
|
|
328
319
|
|
|
329
320
|
context "if page is currently not folded" do
|
|
330
|
-
before
|
|
331
|
-
page.stub!(:folded?).and_return(false)
|
|
332
|
-
end
|
|
321
|
+
before { page.stub(:folded?).and_return(false) }
|
|
333
322
|
|
|
334
323
|
it "should fold the page" do
|
|
335
|
-
page.should_receive(:fold!).with(
|
|
324
|
+
page.should_receive(:fold!).with(user.id, true).and_return(true)
|
|
336
325
|
post :fold, id: page.id, format: :js
|
|
337
326
|
end
|
|
338
327
|
end
|
|
339
328
|
|
|
340
329
|
context "if page is already folded" do
|
|
341
|
-
before
|
|
342
|
-
page.stub!(:folded?).and_return(true)
|
|
343
|
-
end
|
|
330
|
+
before { page.stub(:folded?).and_return(true) }
|
|
344
331
|
|
|
345
332
|
it "should unfold the page" do
|
|
346
|
-
page.should_receive(:fold!).with(
|
|
333
|
+
page.should_receive(:fold!).with(user.id, false).and_return(true)
|
|
347
334
|
post :fold, id: page.id, format: :js
|
|
348
335
|
end
|
|
349
336
|
end
|
|
350
337
|
end
|
|
351
338
|
|
|
352
339
|
describe '#sort' do
|
|
353
|
-
before
|
|
354
|
-
Page.stub!(:language_root_for).and_return(mock_model('Page'))
|
|
355
|
-
end
|
|
340
|
+
before { Page.stub(:language_root_for).and_return(mock_model(Alchemy::Page)) }
|
|
356
341
|
|
|
357
342
|
it "should assign @sorting with true" do
|
|
358
343
|
get :sort, format: :js
|
|
@@ -361,16 +346,15 @@ module Alchemy
|
|
|
361
346
|
end
|
|
362
347
|
|
|
363
348
|
describe '#unlock' do
|
|
364
|
-
let(:page) { mock_model(
|
|
349
|
+
let(:page) { mock_model(Alchemy::Page, name: 'Best practices') }
|
|
365
350
|
|
|
366
351
|
before do
|
|
367
|
-
|
|
368
|
-
Page.stub!(:find).with("#{page.id}").and_return(page)
|
|
352
|
+
Page.stub(:find).with("#{page.id}").and_return(page)
|
|
369
353
|
Page.stub_chain(:from_current_site, :all_locked_by).and_return(nil)
|
|
354
|
+
page.should_receive(:unlock!).and_return(true)
|
|
370
355
|
end
|
|
371
356
|
|
|
372
357
|
it "should unlock the page" do
|
|
373
|
-
page.should_receive(:unlock!)
|
|
374
358
|
post :unlock, id: "#{page.id}", format: :js
|
|
375
359
|
end
|
|
376
360
|
|
|
@@ -385,7 +369,6 @@ module Alchemy
|
|
|
385
369
|
end
|
|
386
370
|
end
|
|
387
371
|
end
|
|
388
|
-
|
|
389
372
|
end
|
|
390
373
|
|
|
391
374
|
end
|