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
|
@@ -1,9 +1,34 @@
|
|
|
1
1
|
require "spec_helper"
|
|
2
2
|
|
|
3
|
-
describe
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
describe Admin::EventsController do
|
|
4
|
+
it "should include ResourcesHelper" do
|
|
5
|
+
controller.respond_to?(:resource_window_size).should be_true
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
describe '#index' do
|
|
9
|
+
let(:params) { Hash.new }
|
|
10
|
+
let(:peter) { Event.create(name: 'Peter') }
|
|
11
|
+
let(:lustig) { Event.create(name: 'Lustig') }
|
|
12
|
+
|
|
13
|
+
before do
|
|
14
|
+
sign_in(admin_user)
|
|
15
|
+
peter; lustig
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "returns all records" do
|
|
19
|
+
get :index, params
|
|
20
|
+
assigns(:events).should include(peter)
|
|
21
|
+
assigns(:events).should include(lustig)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
context 'with search query given' do
|
|
25
|
+
let(:params) { {query: 'PeTer'} }
|
|
26
|
+
|
|
27
|
+
it "returns only matching records" do
|
|
28
|
+
get :index, params
|
|
29
|
+
assigns(:events).should include(peter)
|
|
30
|
+
assigns(:events).should_not include(lustig)
|
|
31
|
+
end
|
|
7
32
|
end
|
|
8
33
|
end
|
|
9
|
-
end
|
|
34
|
+
end
|
|
@@ -1,64 +1,46 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
|
-
# Fixes missing method tempfile error
|
|
4
|
-
class Rack::Test::UploadedFile
|
|
5
|
-
attr_reader :tempfile
|
|
6
|
-
end
|
|
7
|
-
|
|
8
3
|
module Alchemy
|
|
9
4
|
describe AttachmentsController do
|
|
10
|
-
|
|
11
|
-
let(:public_page) { FactoryGirl.create(:public_page, :restricted => true) }
|
|
12
|
-
let(:element) { FactoryGirl.create(:element, :page => public_page, :name => 'download', :create_contents_after_create => true) }
|
|
13
|
-
let(:attachment) { Attachment.create(:file => File.new(File.expand_path('../../support/image.png', __FILE__))) }
|
|
14
|
-
|
|
15
|
-
before do
|
|
16
|
-
essence = element.contents.where(:name => 'file').first.essence
|
|
17
|
-
essence.attachment_id = attachment.id
|
|
18
|
-
essence.save
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
it "should not be possible to download attachments from restricted pages" do
|
|
22
|
-
get :download, :id => attachment.id
|
|
23
|
-
response.status.should == 302
|
|
24
|
-
response.should redirect_to(login_path)
|
|
25
|
-
end
|
|
5
|
+
let(:attachment) { FactoryGirl.build_stubbed(:attachment) }
|
|
26
6
|
|
|
27
7
|
it "should raise ActiveRecord::RecordNotFound for requesting not existing attachments" do
|
|
28
8
|
expect { get :download, id: 0 }.to raise_error(ActiveRecord::RecordNotFound)
|
|
29
9
|
end
|
|
30
10
|
|
|
31
|
-
context
|
|
32
|
-
|
|
11
|
+
context 'with restricted attachment' do
|
|
33
12
|
before do
|
|
34
|
-
|
|
13
|
+
attachment.stub(:restricted?).and_return(true)
|
|
14
|
+
Attachment.stub(:find).and_return(attachment)
|
|
35
15
|
end
|
|
36
16
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
17
|
+
context 'as anonymous user' do
|
|
18
|
+
it "should not be possible to download attachments from restricted pages" do
|
|
19
|
+
get :download, :id => attachment.id
|
|
20
|
+
response.status.should == 302
|
|
21
|
+
response.should redirect_to(Alchemy.login_path)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it "should not be possible to see attachments from restricted pages" do
|
|
25
|
+
get :show, :id => attachment.id
|
|
26
|
+
response.status.should == 302
|
|
27
|
+
response.should redirect_to(Alchemy.login_path)
|
|
28
|
+
end
|
|
40
29
|
end
|
|
41
30
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
it "should not be possible to see attachments from restricted pages" do
|
|
45
|
-
get :show, :id => attachment.id
|
|
46
|
-
response.status.should == 302
|
|
47
|
-
response.should redirect_to(login_path)
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
context "as registered user" do
|
|
31
|
+
context "as registered user" do
|
|
32
|
+
before { sign_in(registered_user) }
|
|
51
33
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
34
|
+
it "should be possible to download attachments from restricted pages" do
|
|
35
|
+
get :download, :id => attachment.id
|
|
36
|
+
response.status.should == 200
|
|
37
|
+
end
|
|
55
38
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
39
|
+
it "should be possible to see attachments from restricted pages" do
|
|
40
|
+
get :show, :id => attachment.id
|
|
41
|
+
response.status.should == 200
|
|
42
|
+
end
|
|
59
43
|
end
|
|
60
|
-
|
|
61
44
|
end
|
|
62
|
-
|
|
63
45
|
end
|
|
64
46
|
end
|
|
@@ -41,7 +41,7 @@ module Alchemy
|
|
|
41
41
|
context "with no lang param" do
|
|
42
42
|
|
|
43
43
|
it "should set the default language" do
|
|
44
|
-
controller.stub
|
|
44
|
+
controller.stub(:params).and_return({})
|
|
45
45
|
controller.send :set_language
|
|
46
46
|
assigns(:language).should == default_language
|
|
47
47
|
controller.session.should include_language_information_for(default_language)
|
|
@@ -51,7 +51,7 @@ module Alchemy
|
|
|
51
51
|
|
|
52
52
|
context "with language set in the session" do
|
|
53
53
|
before do
|
|
54
|
-
controller.stub
|
|
54
|
+
controller.stub(:session).and_return(language_id: klingonian.id, language_code: klingonian.code)
|
|
55
55
|
end
|
|
56
56
|
|
|
57
57
|
it "should use the language set in the session cookie" do
|
|
@@ -63,7 +63,7 @@ module Alchemy
|
|
|
63
63
|
context "with lang param" do
|
|
64
64
|
|
|
65
65
|
it "should set the language" do
|
|
66
|
-
controller.stub
|
|
66
|
+
controller.stub(:params).and_return(:lang => klingonian.code)
|
|
67
67
|
controller.send :set_language
|
|
68
68
|
assigns(:language).should == klingonian
|
|
69
69
|
controller.session.should include_language_information_for(klingonian)
|
|
@@ -72,7 +72,7 @@ module Alchemy
|
|
|
72
72
|
context "for language that does not exist" do
|
|
73
73
|
|
|
74
74
|
before do
|
|
75
|
-
controller.stub
|
|
75
|
+
controller.stub(:params).and_return(:lang => 'fo')
|
|
76
76
|
controller.send :set_language
|
|
77
77
|
end
|
|
78
78
|
|
|
@@ -95,49 +95,24 @@ module Alchemy
|
|
|
95
95
|
|
|
96
96
|
end
|
|
97
97
|
|
|
98
|
-
describe '#store_user_request_time' do
|
|
99
|
-
|
|
100
|
-
context "user not logged in" do
|
|
101
|
-
before { controller.stub!(:user_signed_in?).and_return(false) }
|
|
102
|
-
|
|
103
|
-
it "should not store the current request time" do
|
|
104
|
-
controller.send(:store_user_request_time).should == nil
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
context "user logged in" do
|
|
110
|
-
before do
|
|
111
|
-
controller.stub!(:user_signed_in?).and_return(true)
|
|
112
|
-
controller.stub!(:current_user).and_return(FactoryGirl.create(:user))
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
it "should not store the current request time" do
|
|
116
|
-
controller.send(:store_user_request_time).should == true
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
end
|
|
122
|
-
|
|
123
98
|
describe "#layout_for_page" do
|
|
124
99
|
it "should return false if params[:layout] is set to false" do
|
|
125
|
-
controller.stub
|
|
100
|
+
controller.stub(:params).and_return(layout: 'false')
|
|
126
101
|
expect(controller.send(:layout_for_page)).to be_false
|
|
127
102
|
end
|
|
128
103
|
|
|
129
104
|
it "should return false if params[:layout] is set to none" do
|
|
130
|
-
controller.stub
|
|
105
|
+
controller.stub(:params).and_return(layout: 'none')
|
|
131
106
|
expect(controller.send(:layout_for_page)).to be_false
|
|
132
107
|
end
|
|
133
108
|
|
|
134
109
|
it "should return the layout name set through params[:layout]" do
|
|
135
|
-
controller.stub
|
|
110
|
+
controller.stub(:params).and_return(layout: 'my_layout')
|
|
136
111
|
expect(controller.send(:layout_for_page)).to eq('my_layout')
|
|
137
112
|
end
|
|
138
113
|
|
|
139
114
|
it "should return 'application' if params[:layout] is not set" do
|
|
140
|
-
controller.stub
|
|
115
|
+
controller.stub(:params).and_return({})
|
|
141
116
|
expect(controller.send(:layout_for_page)).to eq('application')
|
|
142
117
|
end
|
|
143
118
|
end
|
|
@@ -6,12 +6,13 @@ module Alchemy
|
|
|
6
6
|
|
|
7
7
|
let(:default_language) { Language.get_default }
|
|
8
8
|
let(:default_language_root) { FactoryGirl.create(:language_root_page, :language => default_language, :name => 'Home', :public => true) }
|
|
9
|
+
let(:page) { FactoryGirl.create(:public_page, :parent_id => default_language_root.id, :page_layout => 'news', :name => 'News', :language => default_language, :do_not_autogenerate => false) }
|
|
10
|
+
|
|
11
|
+
before { controller.stub(:signup_required?).and_return(false) }
|
|
9
12
|
|
|
10
13
|
context "requested for a page containing a feed" do
|
|
11
14
|
render_views
|
|
12
15
|
|
|
13
|
-
let(:page) { FactoryGirl.create(:public_page, :parent_id => default_language_root.id, :page_layout => 'news', :name => 'News', :language => default_language, :do_not_autogenerate => false) }
|
|
14
|
-
|
|
15
16
|
it "should render a rss feed" do
|
|
16
17
|
get :show, :urlname => page.urlname, :format => :rss
|
|
17
18
|
response.content_type.should == 'application/rss+xml'
|
|
@@ -35,23 +36,18 @@ module Alchemy
|
|
|
35
36
|
end
|
|
36
37
|
|
|
37
38
|
describe "Layout rendering" do
|
|
38
|
-
|
|
39
39
|
context "with param layout set to none" do
|
|
40
|
-
|
|
41
40
|
it "should not render a layout" do
|
|
42
|
-
get :show, :urlname =>
|
|
41
|
+
get :show, :urlname => page.urlname, :layout => 'none'
|
|
43
42
|
response.body.should_not match /<head>/
|
|
44
43
|
end
|
|
45
|
-
|
|
46
44
|
end
|
|
47
45
|
|
|
48
46
|
context "with param layout set to false" do
|
|
49
|
-
|
|
50
47
|
it "should not render a layout" do
|
|
51
|
-
get :show, :urlname =>
|
|
48
|
+
get :show, :urlname => page.urlname, :layout => 'false'
|
|
52
49
|
response.body.should_not match /<head>/
|
|
53
50
|
end
|
|
54
|
-
|
|
55
51
|
end
|
|
56
52
|
|
|
57
53
|
context "with params layout set to not existing layout" do
|
|
@@ -92,8 +88,8 @@ module Alchemy
|
|
|
92
88
|
let(:product) { FactoryGirl.create(:public_page, :name => "Screwdriver", :parent_id => products.id, :language => default_language, :do_not_autogenerate => false, :visible => true) }
|
|
93
89
|
|
|
94
90
|
before do
|
|
95
|
-
|
|
96
|
-
Config.stub
|
|
91
|
+
Alchemy.user_class.stub(:admins).and_return(OpenStruct.new(count: 1))
|
|
92
|
+
Config.stub(:get) { |arg| arg == :url_nesting ? true : false }
|
|
97
93
|
product.elements.find_by_name('article').contents.essence_texts.first.essence.update_column(:body, 'screwdriver')
|
|
98
94
|
end
|
|
99
95
|
|
|
@@ -121,7 +117,6 @@ module Alchemy
|
|
|
121
117
|
|
|
122
118
|
context "when a non-existent page is requested" do
|
|
123
119
|
it "should rescue a RoutingError with rendering a 404 page." do
|
|
124
|
-
FactoryGirl.create(:admin_user) # otherwise we are redirected to create_user
|
|
125
120
|
get :show, {:urlname => 'doesntexist'}
|
|
126
121
|
response.status.should == 404
|
|
127
122
|
response.body.should have_content('The page you were looking for doesn\'t exist')
|
|
@@ -170,9 +165,6 @@ module Alchemy
|
|
|
170
165
|
describe 'Redirecting to legacy page urls' do
|
|
171
166
|
context 'Request a page with legacy url' do
|
|
172
167
|
|
|
173
|
-
# otherwise we are redirected to signup
|
|
174
|
-
before { FactoryGirl.create(:admin_user) }
|
|
175
|
-
|
|
176
168
|
let(:page) { FactoryGirl.create(:public_page, :name => 'New page name') }
|
|
177
169
|
let(:second_page) { FactoryGirl.create(:public_page, :name => 'Second Page') }
|
|
178
170
|
let(:legacy_page) { FactoryGirl.create(:public_page, :name => 'Legacy Url') }
|
|
@@ -12,7 +12,7 @@ module Alchemy
|
|
|
12
12
|
let(:restricted_page) { FactoryGirl.create(:public_page, :restricted => true) }
|
|
13
13
|
let(:element) { FactoryGirl.create(:element, :page => public_page, :name => 'bild', :create_contents_after_create => true) }
|
|
14
14
|
let(:restricted_element) { FactoryGirl.create(:element, :page => restricted_page, :name => 'bild', :create_contents_after_create => true) }
|
|
15
|
-
let(:picture) { Picture.create(:image_file => fixture_file_upload(File.expand_path('../../
|
|
15
|
+
let(:picture) { Picture.create(:image_file => fixture_file_upload(File.expand_path('../../fixtures/image.png', __FILE__), 'image/png')) }
|
|
16
16
|
|
|
17
17
|
context "Requesting a picture that is not assigned with any page" do
|
|
18
18
|
it "should render the picture" do
|
|
@@ -51,7 +51,7 @@ module Alchemy
|
|
|
51
51
|
it "should not render the picture, but redirect to login path" do
|
|
52
52
|
get :show, :id => picture.id, :sh => picture.security_token
|
|
53
53
|
response.status.should == 302
|
|
54
|
-
response.should redirect_to(login_path)
|
|
54
|
+
response.should redirect_to(Alchemy.login_path)
|
|
55
55
|
end
|
|
56
56
|
end
|
|
57
57
|
|
|
@@ -68,11 +68,9 @@ module Alchemy
|
|
|
68
68
|
end
|
|
69
69
|
|
|
70
70
|
describe 'Picture processing' do
|
|
71
|
+
let(:big_picture) { Picture.create(:image_file => fixture_file_upload(File.expand_path('../../fixtures/80x60.png', __FILE__), 'image/png')) }
|
|
71
72
|
|
|
72
73
|
context "with crop and size parameters" do
|
|
73
|
-
|
|
74
|
-
let(:big_picture) { Picture.create(:image_file => fixture_file_upload(File.expand_path('../../support/80x60.png', __FILE__), 'image/png')) }
|
|
75
|
-
|
|
76
74
|
it "should return a cropped image." do
|
|
77
75
|
options = {
|
|
78
76
|
:crop => 'crop',
|
|
@@ -83,6 +81,19 @@ module Alchemy
|
|
|
83
81
|
response.body[0x10..0x18].unpack('NN').should == [10,10]
|
|
84
82
|
end
|
|
85
83
|
|
|
84
|
+
context "without a full size specification" do
|
|
85
|
+
it "should raise an error" do
|
|
86
|
+
options = {
|
|
87
|
+
:crop => 'crop',
|
|
88
|
+
:size => '10',
|
|
89
|
+
:format => 'png'
|
|
90
|
+
}
|
|
91
|
+
expect do
|
|
92
|
+
get :show, options.merge(:id => big_picture.id, :sh => big_picture.security_token(options))
|
|
93
|
+
end.to raise_error ArgumentError
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
86
97
|
context "without upsample parameter" do
|
|
87
98
|
it "should not upsample the image." do
|
|
88
99
|
options = {
|
|
@@ -107,7 +118,35 @@ module Alchemy
|
|
|
107
118
|
response.body[0x10..0x18].unpack('NN').should == [10,10]
|
|
108
119
|
end
|
|
109
120
|
end
|
|
121
|
+
end
|
|
110
122
|
|
|
123
|
+
context "without crop but with size parameter" do
|
|
124
|
+
it "should resize the image preserving aspect ratio" do
|
|
125
|
+
options = {
|
|
126
|
+
:size => '40x40',
|
|
127
|
+
:format => 'png'
|
|
128
|
+
}
|
|
129
|
+
get :show, options.merge(:id => big_picture.id, :sh => big_picture.security_token(options))
|
|
130
|
+
response.body[0x10..0x18].unpack('NN').should == [40,30]
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
it "should resize the image inferring the height if not given" do
|
|
134
|
+
options = {
|
|
135
|
+
:size => '40',
|
|
136
|
+
:format => 'png'
|
|
137
|
+
}
|
|
138
|
+
get :show, options.merge(:id => big_picture.id, :sh => big_picture.security_token(options))
|
|
139
|
+
response.body[0x10..0x18].unpack('NN').should == [40,30]
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
it "should resize the image inferring the width if not given" do
|
|
143
|
+
options = {
|
|
144
|
+
:size => 'x30',
|
|
145
|
+
:format => 'png'
|
|
146
|
+
}
|
|
147
|
+
get :show, options.merge(:id => big_picture.id, :sh => big_picture.security_token(options))
|
|
148
|
+
response.body[0x10..0x18].unpack('NN').should == [40,30]
|
|
149
|
+
end
|
|
111
150
|
end
|
|
112
151
|
|
|
113
152
|
end
|
|
@@ -1,3 +1,11 @@
|
|
|
1
1
|
class ApplicationController < ActionController::Base
|
|
2
|
-
|
|
2
|
+
# Prevent CSRF attacks by raising an exception.
|
|
3
|
+
# For APIs, you may want to use :null_session instead.
|
|
4
|
+
protect_from_forgery with: :exception
|
|
5
|
+
|
|
6
|
+
private
|
|
7
|
+
|
|
8
|
+
def current_user
|
|
9
|
+
nil
|
|
10
|
+
end
|
|
3
11
|
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
class User
|
|
2
|
+
extend ::ActiveModel::Naming
|
|
3
|
+
extend ::ActiveModel::Translation
|
|
4
|
+
include ::ActiveModel::Validations
|
|
5
|
+
include ::ActiveModel::Conversion
|
|
6
|
+
include ::ActiveModel::MassAssignmentSecurity
|
|
7
|
+
attr_accessor :alchemy_roles, :email, :password
|
|
8
|
+
|
|
9
|
+
alias_method :role_symbols, :alchemy_roles
|
|
10
|
+
|
|
11
|
+
def self.logged_in
|
|
12
|
+
[]
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -265,37 +265,6 @@ class AlchemyTwoPointSix < ActiveRecord::Migration
|
|
|
265
265
|
add_index "alchemy_sites", ["host", "public"], :name => "alchemy_sites_public_hosts_idx"
|
|
266
266
|
add_index "alchemy_sites", ["host"], :name => "index_alchemy_sites_on_host"
|
|
267
267
|
|
|
268
|
-
create_table "alchemy_users", :force => true do |t|
|
|
269
|
-
t.string "firstname"
|
|
270
|
-
t.string "lastname"
|
|
271
|
-
t.string "login"
|
|
272
|
-
t.string "email"
|
|
273
|
-
t.string "gender"
|
|
274
|
-
t.string "roles", :default => "registered"
|
|
275
|
-
t.string "language"
|
|
276
|
-
t.string "encrypted_password", :limit => 128, :default => "", :null => false
|
|
277
|
-
t.string "password_salt", :limit => 128, :default => "", :null => false
|
|
278
|
-
t.integer "sign_in_count", :default => 0, :null => false
|
|
279
|
-
t.integer "failed_attempts", :default => 0, :null => false
|
|
280
|
-
t.datetime "last_request_at"
|
|
281
|
-
t.datetime "current_sign_in_at"
|
|
282
|
-
t.datetime "last_sign_in_at"
|
|
283
|
-
t.string "current_sign_in_ip"
|
|
284
|
-
t.string "last_sign_in_ip"
|
|
285
|
-
t.datetime "created_at", :null => false
|
|
286
|
-
t.datetime "updated_at", :null => false
|
|
287
|
-
t.integer "creator_id"
|
|
288
|
-
t.integer "updater_id"
|
|
289
|
-
t.text "cached_tag_list"
|
|
290
|
-
t.string "reset_password_token"
|
|
291
|
-
t.datetime "reset_password_sent_at"
|
|
292
|
-
end
|
|
293
|
-
|
|
294
|
-
add_index "alchemy_users", ["email"], :name => "index_alchemy_users_on_email", :unique => true
|
|
295
|
-
add_index "alchemy_users", ["login"], :name => "index_alchemy_users_on_login", :unique => true
|
|
296
|
-
add_index "alchemy_users", ["reset_password_token"], :name => "index_alchemy_users_on_reset_password_token", :unique => true
|
|
297
|
-
add_index "alchemy_users", ["roles"], :name => "index_alchemy_users_on_roles"
|
|
298
|
-
|
|
299
268
|
create_table "events", :force => true do |t|
|
|
300
269
|
t.string "name"
|
|
301
270
|
t.string "hidden_name"
|