alchemy_cms 3.1.3 → 3.2.0.beta
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/.editorconfig +2 -2
- data/.hound.yml +2 -0
- data/.rubocop.yml +1063 -0
- data/.travis.yml +14 -10
- data/Gemfile +4 -7
- data/README.md +16 -8
- data/alchemy_cms.gemspec +8 -7
- data/app/assets/javascripts/alchemy/alchemy.base.js.coffee +10 -11
- data/app/assets/javascripts/alchemy/alchemy.js +1 -1
- data/app/assets/stylesheets/alchemy/{admin.css.scss → admin.scss} +1 -0
- data/app/assets/stylesheets/alchemy/{icon-font.css.scss → icon-font.scss} +0 -0
- data/app/assets/stylesheets/alchemy/{menubar.css.scss → menubar.scss} +0 -0
- data/app/assets/stylesheets/alchemy/{print.css.scss → print.scss} +0 -0
- data/app/assets/stylesheets/alchemy/selects.scss +0 -6
- data/app/controllers/alchemy/admin/contents_controller.rb +3 -4
- data/app/controllers/alchemy/admin/pictures_controller.rb +0 -2
- data/app/controllers/alchemy/api/contents_controller.rb +1 -1
- data/app/controllers/alchemy/api/elements_controller.rb +2 -2
- data/app/controllers/alchemy/api/pages_controller.rb +1 -1
- data/app/controllers/alchemy/elements_controller.rb +0 -6
- data/app/controllers/alchemy/pages_controller.rb +17 -13
- data/app/controllers/alchemy/pictures_controller.rb +1 -0
- data/app/helpers/alchemy/admin/navigation_helper.rb +1 -1
- data/app/models/alchemy/element.rb +41 -17
- data/app/models/alchemy/page/page_naming.rb +16 -29
- data/bin/alchemy +1 -1
- data/config/routes.rb +1 -2
- data/db/migrate/20130827094554_alchemy_two_point_six.rb +0 -17
- data/lib/alchemy/capistrano.rb +3 -4
- data/lib/alchemy/controller_actions.rb +2 -1
- data/lib/alchemy/engine.rb +1 -0
- data/lib/alchemy/errors.rb +7 -0
- data/lib/alchemy/essence.rb +4 -4
- data/lib/alchemy/permissions.rb +1 -1
- data/lib/alchemy/shell.rb +26 -11
- data/lib/alchemy/test_support/controller_requests.rb +48 -12
- data/lib/alchemy/upgrader.rb +1 -0
- data/lib/alchemy/upgrader/three_point_one.rb +0 -1
- data/lib/alchemy/upgrader/three_point_two.rb +39 -0
- data/lib/alchemy/version.rb +1 -1
- data/lib/rails/templates/alchemy.rb +2 -2
- data/lib/tasks/alchemy/install.rake +2 -1
- data/spec/controllers/admin/attachments_controller_spec.rb +14 -14
- data/spec/controllers/admin/clipboard_controller_spec.rb +5 -5
- data/spec/controllers/admin/contents_controller_spec.rb +8 -14
- data/spec/controllers/admin/dashboard_controller_spec.rb +12 -12
- data/spec/controllers/admin/elements_controller_spec.rb +30 -31
- data/spec/controllers/admin/essence_files_controller_spec.rb +6 -6
- data/spec/controllers/admin/essence_pictures_controller_spec.rb +17 -17
- data/spec/controllers/admin/languages_controller_spec.rb +3 -3
- data/spec/controllers/admin/layoutpages_controller_spec.rb +3 -3
- data/spec/controllers/admin/pages_controller_spec.rb +48 -48
- data/spec/controllers/admin/pictures_controller_spec.rb +19 -19
- data/spec/controllers/admin/resources_controller_spec.rb +2 -2
- data/spec/controllers/admin/trash_controller_spec.rb +5 -5
- data/spec/controllers/alchemy/admin/tags_controller_spec.rb +5 -5
- data/spec/controllers/alchemy/api/contents_controller_spec.rb +46 -11
- data/spec/controllers/alchemy/api/elements_controller_spec.rb +42 -14
- data/spec/controllers/alchemy/api/pages_controller_spec.rb +26 -16
- data/spec/controllers/attachments_controller_spec.rb +7 -7
- data/spec/controllers/elements_controller_spec.rb +16 -19
- data/spec/controllers/messages_controller_spec.rb +15 -15
- data/spec/controllers/pages_controller_spec.rb +16 -25
- data/spec/controllers/pictures_controller_spec.rb +75 -49
- data/spec/dummy/Rakefile +1 -1
- data/spec/dummy/app/assets/stylesheets/application.css +5 -3
- data/spec/dummy/config/application.rb +11 -1
- data/spec/dummy/config/boot.rb +1 -1
- data/spec/dummy/config/environment.rb +1 -1
- data/spec/dummy/config/environments/development.rb +14 -2
- data/spec/dummy/config/environments/production.rb +18 -21
- data/spec/dummy/config/environments/test.rb +9 -4
- data/spec/dummy/config/initializers/assets.rb +11 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/spec/dummy/config/initializers/mime_types.rb +0 -1
- data/spec/dummy/config/initializers/session_store.rb +1 -1
- data/spec/dummy/config/secrets.yml +22 -0
- data/spec/dummy/db/migrate/20130827094554_alchemy_two_point_six.rb +380 -0
- data/spec/dummy/db/migrate/20130828121054_remove_do_not_index_from_alchemy_essence_texts.rb +5 -0
- data/spec/dummy/db/migrate/20130828121120_remove_do_not_index_from_alchemy_essence_richtexts.rb +5 -0
- data/spec/dummy/db/migrate/20130918201742_add_published_at_to_alchemy_pages.rb +5 -0
- data/spec/dummy/db/migrate/20150122213511_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb +31 -0
- data/{db/migrate/20140107192720_add_missing_unique_indices_to_tags_and_taggings.rb → spec/dummy/db/migrate/20150122213512_add_missing_unique_indices.acts_as_taggable_on_engine.rb} +5 -6
- data/{db/migrate/20140701160159_add_taggings_counter_cache_to_tags.rb → spec/dummy/db/migrate/20150122213513_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb} +2 -1
- data/{db/migrate/20140701160225_add_missing_taggable_index.rb → spec/dummy/db/migrate/20150122213514_add_missing_taggable_index.acts_as_taggable_on_engine.rb} +1 -0
- data/spec/dummy/db/schema.rb +27 -31
- data/spec/dummy/public/404.html +20 -11
- data/spec/dummy/public/422.html +20 -11
- data/spec/dummy/public/500.html +19 -10
- data/spec/features/admin/page_creation_feature_spec.rb +2 -2
- data/spec/libraries/resource_spec.rb +1 -1
- data/spec/libraries/shell_spec.rb +2 -0
- data/spec/models/page_spec.rb +1 -13
- data/spec/spec_helper.rb +6 -4
- data/spec/support/rspec-activemodel-mocks_patch.rb +8 -0
- metadata +63 -56
- data/app/controllers/alchemy/contents_controller.rb +0 -18
- data/spec/controllers/contents_controller_spec.rb +0 -22
- data/spec/dummy/app/models/dummy_model.rb +0 -3
- data/spec/dummy/db/migrate/20130827094554_alchemy_two_point_six.rb +0 -1
- data/spec/dummy/db/migrate/20130828121054_remove_do_not_index_from_alchemy_essence_texts.rb +0 -1
- data/spec/dummy/db/migrate/20130828121120_remove_do_not_index_from_alchemy_essence_richtexts.rb +0 -1
- data/spec/dummy/db/migrate/20130918201742_add_published_at_to_alchemy_pages.rb +0 -1
- data/spec/dummy/db/migrate/20140107192720_add_missing_unique_indices_to_tags_and_taggings.rb +0 -1
- data/spec/dummy/db/migrate/20140701160159_add_taggings_counter_cache_to_tags.rb +0 -1
- data/spec/dummy/db/migrate/20140701160225_add_missing_taggable_index.rb +0 -1
- data/spec/dummy/db/migrate/20150412103152_create_dummy_model.rb +0 -7
- data/spec/dummy/spec/javascripts +0 -1
- data/spec/models/dummy_model_spec.rb +0 -11
|
@@ -4,47 +4,56 @@ module Alchemy
|
|
|
4
4
|
describe Api::PagesController do
|
|
5
5
|
|
|
6
6
|
describe '#index' do
|
|
7
|
-
let!(:page)
|
|
7
|
+
let!(:page) { create(:public_page) }
|
|
8
8
|
|
|
9
9
|
it "returns all public pages as json objects" do
|
|
10
|
-
|
|
10
|
+
alchemy_get :index, format: :json
|
|
11
11
|
expect(response.status).to eq(200)
|
|
12
12
|
expect(response.content_type).to eq('application/json')
|
|
13
|
-
expect(response.body).
|
|
13
|
+
expect(response.body).to eq("{\"pages\":[#{PageSerializer.new(page.parent).to_json},#{PageSerializer.new(page).to_json}]}")
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
context 'with page_layout' do
|
|
17
17
|
let!(:other_page) { create(:public_page, page_layout: 'news') }
|
|
18
18
|
|
|
19
|
-
it "returns only pages
|
|
20
|
-
|
|
19
|
+
it "returns only pages with this page layout" do
|
|
20
|
+
alchemy_get :index, {page_layout: 'news', format: :json}
|
|
21
21
|
expect(response.status).to eq(200)
|
|
22
22
|
expect(response.content_type).to eq('application/json')
|
|
23
|
-
expect(response.body).
|
|
24
|
-
|
|
23
|
+
expect(response.body).to eq("{\"pages\":[#{PageSerializer.new(other_page).to_json}]}")
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
context 'with empty string as page_layout' do
|
|
28
|
+
it "returns all pages" do
|
|
29
|
+
alchemy_get :index, {page_layout: '', format: :json}
|
|
30
|
+
expect(response.status).to eq(200)
|
|
31
|
+
expect(response.content_type).to eq('application/json')
|
|
32
|
+
expect(response.body).to eq("{\"pages\":[#{PageSerializer.new(page.parent).to_json},#{PageSerializer.new(page).to_json}]}")
|
|
25
33
|
end
|
|
26
34
|
end
|
|
27
35
|
end
|
|
28
36
|
|
|
29
37
|
describe '#show' do
|
|
30
38
|
context 'for existing page' do
|
|
31
|
-
let(:page) { build_stubbed(:public_page) }
|
|
39
|
+
let(:page) { build_stubbed(:public_page, urlname: 'a-page') }
|
|
32
40
|
|
|
33
41
|
before do
|
|
34
42
|
expect(Page).to receive(:find_by).and_return(page)
|
|
35
43
|
end
|
|
36
44
|
|
|
37
|
-
it "
|
|
38
|
-
|
|
45
|
+
it "returns page as json" do
|
|
46
|
+
alchemy_get :show, {urlname: page.urlname, format: :json}
|
|
39
47
|
expect(response.status).to eq(200)
|
|
40
48
|
expect(response.content_type).to eq('application/json')
|
|
49
|
+
expect(response.body).to eq(PageSerializer.new(page).to_json)
|
|
41
50
|
end
|
|
42
51
|
|
|
43
52
|
context 'requesting an restricted page' do
|
|
44
|
-
let(:page) { build_stubbed(:page, restricted: true) }
|
|
53
|
+
let(:page) { build_stubbed(:page, restricted: true, urlname: 'a-page') }
|
|
45
54
|
|
|
46
55
|
it "responds with 403" do
|
|
47
|
-
|
|
56
|
+
alchemy_get :show, {urlname: page.urlname, format: :json}
|
|
48
57
|
expect(response.content_type).to eq('application/json')
|
|
49
58
|
expect(response.status).to eq(403)
|
|
50
59
|
expect(response.body).to eq('{"error":"Not authorized"}')
|
|
@@ -52,10 +61,10 @@ module Alchemy
|
|
|
52
61
|
end
|
|
53
62
|
|
|
54
63
|
context 'requesting a not public page' do
|
|
55
|
-
let(:page) { build_stubbed(:page) }
|
|
64
|
+
let(:page) { build_stubbed(:page, urlname: 'a-page') }
|
|
56
65
|
|
|
57
66
|
it "responds with 403" do
|
|
58
|
-
|
|
67
|
+
alchemy_get :show, {urlname: page.urlname, format: :json}
|
|
59
68
|
expect(response.content_type).to eq('application/json')
|
|
60
69
|
expect(response.status).to eq(403)
|
|
61
70
|
expect(response.body).to eq('{"error":"Not authorized"}')
|
|
@@ -65,7 +74,7 @@ module Alchemy
|
|
|
65
74
|
|
|
66
75
|
context 'requesting an unknown page' do
|
|
67
76
|
it "responds with 404" do
|
|
68
|
-
|
|
77
|
+
alchemy_get :show, {urlname: 'not-existing', format: :json}
|
|
69
78
|
expect(response.content_type).to eq('application/json')
|
|
70
79
|
expect(response.status).to eq(404)
|
|
71
80
|
expect(response.body).to eq('{"error":"Record not found"}')
|
|
@@ -76,9 +85,10 @@ module Alchemy
|
|
|
76
85
|
let(:page) { create(:public_page) }
|
|
77
86
|
|
|
78
87
|
it "responds with json" do
|
|
79
|
-
|
|
88
|
+
alchemy_get :show, {id: page.id, format: :json}
|
|
80
89
|
expect(response.status).to eq(200)
|
|
81
90
|
expect(response.content_type).to eq('application/json')
|
|
91
|
+
expect(response.body).to eq(PageSerializer.new(page).to_json)
|
|
82
92
|
end
|
|
83
93
|
end
|
|
84
94
|
end
|
|
@@ -5,7 +5,7 @@ module Alchemy
|
|
|
5
5
|
let(:attachment) { build_stubbed(:attachment) }
|
|
6
6
|
|
|
7
7
|
it "should raise ActiveRecord::RecordNotFound for requesting not existing attachments" do
|
|
8
|
-
expect {
|
|
8
|
+
expect { alchemy_get :download, id: 0 }.to raise_error(ActiveRecord::RecordNotFound)
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
context 'with public attachment' do
|
|
@@ -14,13 +14,13 @@ module Alchemy
|
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
it "sends download as attachment." do
|
|
17
|
-
|
|
17
|
+
alchemy_get :download, :id => attachment.id
|
|
18
18
|
expect(response.status).to eq(200)
|
|
19
19
|
expect(response.headers['Content-Disposition']).to match(/attachment/)
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
it "sends download inline." do
|
|
23
|
-
|
|
23
|
+
alchemy_get :show, :id => attachment.id
|
|
24
24
|
expect(response.status).to eq(200)
|
|
25
25
|
expect(response.headers['Content-Disposition']).to match(/inline/)
|
|
26
26
|
end
|
|
@@ -34,13 +34,13 @@ module Alchemy
|
|
|
34
34
|
|
|
35
35
|
context 'as anonymous user' do
|
|
36
36
|
it "should not be possible to download attachments from restricted pages" do
|
|
37
|
-
|
|
37
|
+
alchemy_get :download, :id => attachment.id
|
|
38
38
|
expect(response.status).to eq(302)
|
|
39
39
|
expect(response).to redirect_to(Alchemy.login_path)
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
it "should not be possible to see attachments from restricted pages" do
|
|
43
|
-
|
|
43
|
+
alchemy_get :show, :id => attachment.id
|
|
44
44
|
expect(response.status).to eq(302)
|
|
45
45
|
expect(response).to redirect_to(Alchemy.login_path)
|
|
46
46
|
end
|
|
@@ -50,12 +50,12 @@ module Alchemy
|
|
|
50
50
|
before { sign_in(member_user) }
|
|
51
51
|
|
|
52
52
|
it "should be possible to download attachments from restricted pages" do
|
|
53
|
-
|
|
53
|
+
alchemy_get :download, :id => attachment.id
|
|
54
54
|
expect(response.status).to eq(200)
|
|
55
55
|
end
|
|
56
56
|
|
|
57
57
|
it "should be possible to see attachments from restricted pages" do
|
|
58
|
-
|
|
58
|
+
alchemy_get :show, :id => attachment.id
|
|
59
59
|
expect(response.status).to eq(200)
|
|
60
60
|
end
|
|
61
61
|
end
|
|
@@ -2,30 +2,36 @@ require 'spec_helper'
|
|
|
2
2
|
|
|
3
3
|
module Alchemy
|
|
4
4
|
describe ElementsController do
|
|
5
|
-
let(:public_page) {
|
|
6
|
-
let(:element) {
|
|
7
|
-
let(:restricted_page) {
|
|
8
|
-
let(:restricted_element) {
|
|
5
|
+
let(:public_page) { create(:public_page) }
|
|
6
|
+
let(:element) { create(:element, page: public_page, name: 'download') }
|
|
7
|
+
let(:restricted_page) { create(:public_page, restricted: true) }
|
|
8
|
+
let(:restricted_element) { create(:element, page: restricted_page, name: 'download') }
|
|
9
9
|
|
|
10
10
|
describe '#show' do
|
|
11
11
|
it "should render available elements" do
|
|
12
|
-
|
|
12
|
+
alchemy_get :show, id: element.id
|
|
13
13
|
expect(response.status).to eq(200)
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
it "should raise ActiveRecord::RecordNotFound error for trashed elements" do
|
|
17
17
|
element.trash!
|
|
18
|
-
expect {
|
|
18
|
+
expect {
|
|
19
|
+
alchemy_get :show, id: element.id
|
|
20
|
+
}.to raise_error(ActiveRecord::RecordNotFound)
|
|
19
21
|
end
|
|
20
22
|
|
|
21
23
|
it "should raise ActiveRecord::RecordNotFound error for unpublished elements" do
|
|
22
|
-
element.update_attributes(:
|
|
23
|
-
expect {
|
|
24
|
+
element.update_attributes(public: false)
|
|
25
|
+
expect {
|
|
26
|
+
alchemy_get :show, id: element.id
|
|
27
|
+
}.to raise_error(ActiveRecord::RecordNotFound)
|
|
24
28
|
end
|
|
25
29
|
|
|
26
30
|
context "for guest user" do
|
|
27
31
|
it "should raise ActiveRecord::RecordNotFound error for elements of restricted pages" do
|
|
28
|
-
expect {
|
|
32
|
+
expect {
|
|
33
|
+
alchemy_get :show, id: restricted_element.id
|
|
34
|
+
}.to raise_error(ActiveRecord::RecordNotFound)
|
|
29
35
|
end
|
|
30
36
|
end
|
|
31
37
|
|
|
@@ -33,19 +39,10 @@ module Alchemy
|
|
|
33
39
|
before { sign_in(member_user) }
|
|
34
40
|
|
|
35
41
|
it "should render elements of restricted pages" do
|
|
36
|
-
|
|
42
|
+
alchemy_get :show, id: restricted_element.id
|
|
37
43
|
expect(response.status).to eq(200)
|
|
38
44
|
end
|
|
39
45
|
end
|
|
40
|
-
|
|
41
|
-
context "requested for json format" do
|
|
42
|
-
it "should render json response but warns about deprecation" do
|
|
43
|
-
expect(ActiveSupport::Deprecation).to receive(:warn)
|
|
44
|
-
get :show, id: element.id, format: :json
|
|
45
|
-
expect(response.status).to eq(200)
|
|
46
|
-
expect(response.content_type).to eq('application/json')
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
46
|
end
|
|
50
47
|
end
|
|
51
48
|
end
|
|
@@ -13,14 +13,14 @@ module Alchemy
|
|
|
13
13
|
let(:page) { mock_model('Page', {urlname: 'contact', page_layout: 'contact'}) }
|
|
14
14
|
|
|
15
15
|
it "should redirect to @page" do
|
|
16
|
-
expect(
|
|
16
|
+
expect(alchemy_get :index).to redirect_to(show_page_path(urlname: page.urlname))
|
|
17
17
|
end
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
describe "#new" do
|
|
21
21
|
it "should render the alchemy/pages/show template" do
|
|
22
|
-
|
|
23
|
-
expect(
|
|
22
|
+
alchemy_get :new
|
|
23
|
+
expect(alchemy_get :new).to render_template('alchemy/pages/show')
|
|
24
24
|
end
|
|
25
25
|
end
|
|
26
26
|
|
|
@@ -34,7 +34,7 @@ module Alchemy
|
|
|
34
34
|
let(:message) { Message.new }
|
|
35
35
|
|
|
36
36
|
it "should raise ActiveRecord::RecordNotFound if element of contactform could not be found" do
|
|
37
|
-
expect {
|
|
37
|
+
expect { alchemy_post :create }.to raise_error(ActiveRecord::RecordNotFound)
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
context "if validation of message" do
|
|
@@ -51,7 +51,7 @@ module Alchemy
|
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
it "should render 'alchemy/pages/show' template" do
|
|
54
|
-
expect(
|
|
54
|
+
expect(alchemy_post :create).to render_template('alchemy/pages/show')
|
|
55
55
|
end
|
|
56
56
|
end
|
|
57
57
|
|
|
@@ -63,7 +63,7 @@ module Alchemy
|
|
|
63
63
|
|
|
64
64
|
it "Messages should call Messages#contact_form_mail to send the email" do
|
|
65
65
|
expect(Messages).to receive(:contact_form_mail)
|
|
66
|
-
|
|
66
|
+
alchemy_post :create
|
|
67
67
|
end
|
|
68
68
|
|
|
69
69
|
describe '#mail_to' do
|
|
@@ -76,7 +76,7 @@ module Alchemy
|
|
|
76
76
|
|
|
77
77
|
it "returns the ingredient" do
|
|
78
78
|
expect(Messages).to receive(:contact_form_mail).with(message, 'peter@schroeder.de', '', '')
|
|
79
|
-
|
|
79
|
+
alchemy_post :create
|
|
80
80
|
end
|
|
81
81
|
end
|
|
82
82
|
|
|
@@ -89,7 +89,7 @@ module Alchemy
|
|
|
89
89
|
|
|
90
90
|
it "returns the config value" do
|
|
91
91
|
expect(Messages).to receive(:contact_form_mail).with(message, 'your.mail@your-domain.com', '', '')
|
|
92
|
-
|
|
92
|
+
alchemy_post :create
|
|
93
93
|
end
|
|
94
94
|
end
|
|
95
95
|
end
|
|
@@ -104,7 +104,7 @@ module Alchemy
|
|
|
104
104
|
|
|
105
105
|
it "returns the ingredient" do
|
|
106
106
|
expect(Messages).to receive(:contact_form_mail).with(message, '', 'peter@schroeder.de', '')
|
|
107
|
-
|
|
107
|
+
alchemy_post :create
|
|
108
108
|
end
|
|
109
109
|
end
|
|
110
110
|
|
|
@@ -117,7 +117,7 @@ module Alchemy
|
|
|
117
117
|
|
|
118
118
|
it "returns the config value" do
|
|
119
119
|
expect(Messages).to receive(:contact_form_mail).with(message, '', 'your.mail@your-domain.com', '')
|
|
120
|
-
|
|
120
|
+
alchemy_post :create
|
|
121
121
|
end
|
|
122
122
|
end
|
|
123
123
|
end
|
|
@@ -132,7 +132,7 @@ module Alchemy
|
|
|
132
132
|
|
|
133
133
|
it "returns the ingredient" do
|
|
134
134
|
expect(Messages).to receive(:contact_form_mail).with(message, '', '', 'A new message')
|
|
135
|
-
|
|
135
|
+
alchemy_post :create
|
|
136
136
|
end
|
|
137
137
|
end
|
|
138
138
|
|
|
@@ -145,7 +145,7 @@ module Alchemy
|
|
|
145
145
|
|
|
146
146
|
it "returns the config value" do
|
|
147
147
|
expect(Messages).to receive(:contact_form_mail).with(message, '', '', 'A new contact form message')
|
|
148
|
-
|
|
148
|
+
alchemy_post :create
|
|
149
149
|
end
|
|
150
150
|
end
|
|
151
151
|
end
|
|
@@ -157,7 +157,7 @@ module Alchemy
|
|
|
157
157
|
end
|
|
158
158
|
|
|
159
159
|
it "should redirect to the given urlname" do
|
|
160
|
-
expect(
|
|
160
|
+
expect(alchemy_post :create).to redirect_to(show_page_path(urlname: 'success-page'))
|
|
161
161
|
end
|
|
162
162
|
end
|
|
163
163
|
|
|
@@ -173,7 +173,7 @@ module Alchemy
|
|
|
173
173
|
end
|
|
174
174
|
|
|
175
175
|
it "redirect to the given success page" do
|
|
176
|
-
expect(
|
|
176
|
+
expect(alchemy_post :create).to redirect_to(show_page_path(urlname: 'mailer-config-success-page'))
|
|
177
177
|
end
|
|
178
178
|
end
|
|
179
179
|
|
|
@@ -187,7 +187,7 @@ module Alchemy
|
|
|
187
187
|
|
|
188
188
|
it "should redirect to the language root page" do
|
|
189
189
|
expect(Language).to receive(:current).and_return(language)
|
|
190
|
-
expect(
|
|
190
|
+
expect(alchemy_post :create).to redirect_to(show_page_path(urlname: 'lang-root'))
|
|
191
191
|
end
|
|
192
192
|
end
|
|
193
193
|
end
|
|
@@ -15,7 +15,7 @@ module Alchemy
|
|
|
15
15
|
before { allow(controller).to receive(:current_alchemy_user).and_return(author_user) }
|
|
16
16
|
|
|
17
17
|
it "should not be able to visit a unpublic page" do
|
|
18
|
-
|
|
18
|
+
alchemy_get :show, urlname: unpublic.urlname
|
|
19
19
|
expect(response.status).to eq(404)
|
|
20
20
|
end
|
|
21
21
|
end
|
|
@@ -24,37 +24,28 @@ module Alchemy
|
|
|
24
24
|
render_views
|
|
25
25
|
|
|
26
26
|
it "should render a rss feed" do
|
|
27
|
-
|
|
27
|
+
alchemy_get :show, urlname: page.urlname, format: :rss
|
|
28
28
|
expect(response.content_type).to eq('application/rss+xml')
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
it "should include content" do
|
|
32
32
|
page.elements.first.content_by_name('news_headline').essence.update_attributes({body: 'Peters Petshop'})
|
|
33
|
-
|
|
33
|
+
alchemy_get :show, urlname: 'news', format: :rss
|
|
34
34
|
expect(response.body).to match /Peters Petshop/
|
|
35
35
|
end
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
context "requested for a page that does not contain a feed" do
|
|
39
39
|
it "should render xml 404 error" do
|
|
40
|
-
|
|
40
|
+
alchemy_get :show, urlname: default_language_root.urlname, format: :rss
|
|
41
41
|
expect(response.status).to eq(404)
|
|
42
42
|
end
|
|
43
43
|
end
|
|
44
44
|
|
|
45
|
-
context "requested for json format" do
|
|
46
|
-
it "should render json response but warns about deprecation" do
|
|
47
|
-
expect(ActiveSupport::Deprecation).to receive(:warn)
|
|
48
|
-
get :show, urlname: default_language_root.urlname, format: :json
|
|
49
|
-
expect(response.status).to eq(200)
|
|
50
|
-
expect(response.content_type).to eq('application/json')
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
|
|
54
45
|
describe "Layout rendering" do
|
|
55
46
|
context "with ajax request" do
|
|
56
47
|
it "should not render a layout" do
|
|
57
|
-
|
|
48
|
+
alchemy_xhr :get, :show, urlname: page.urlname
|
|
58
49
|
expect(response).to render_template(:show)
|
|
59
50
|
expect(response).not_to render_template(layout: 'application')
|
|
60
51
|
end
|
|
@@ -76,7 +67,7 @@ module Alchemy
|
|
|
76
67
|
|
|
77
68
|
context "with correct levelnames in params" do
|
|
78
69
|
it "should show the requested page" do
|
|
79
|
-
|
|
70
|
+
alchemy_get :show, {urlname: 'catalog/products/screwdriver'}
|
|
80
71
|
expect(response.status).to eq(200)
|
|
81
72
|
expect(response.body).to have_content("screwdriver")
|
|
82
73
|
end
|
|
@@ -84,7 +75,7 @@ module Alchemy
|
|
|
84
75
|
|
|
85
76
|
context "with incorrect levelnames in params" do
|
|
86
77
|
it "should render a 404 page" do
|
|
87
|
-
|
|
78
|
+
alchemy_get :show, {urlname: 'catalog/faqs/screwdriver'}
|
|
88
79
|
expect(response.status).to eq(404)
|
|
89
80
|
expect(response.body).to have_content('The page you were looking for doesn\'t exist')
|
|
90
81
|
end
|
|
@@ -93,7 +84,7 @@ module Alchemy
|
|
|
93
84
|
|
|
94
85
|
context "when a non-existent page is requested" do
|
|
95
86
|
it "should rescue a RoutingError with rendering a 404 page." do
|
|
96
|
-
|
|
87
|
+
alchemy_get :show, {urlname: 'doesntexist'}
|
|
97
88
|
expect(response.status).to eq(404)
|
|
98
89
|
expect(response.body).to have_content('The page you were looking for doesn\'t exist')
|
|
99
90
|
end
|
|
@@ -148,38 +139,38 @@ module Alchemy
|
|
|
148
139
|
|
|
149
140
|
it "should redirect permanently to page that belongs to legacy page url even if url has an unknown format & get parameters" do
|
|
150
141
|
expect(request).to receive(:fullpath).at_least(:once).and_return(legacy_url4.urlname)
|
|
151
|
-
|
|
142
|
+
alchemy_get :show, urlname: "index.php"
|
|
152
143
|
expect(response.status).to eq(301)
|
|
153
144
|
expect(response).to redirect_to("/#{second_page.urlname}")
|
|
154
145
|
end
|
|
155
146
|
|
|
156
147
|
it "should not pass query string for legacy routes" do
|
|
157
148
|
expect(request).to receive(:fullpath).at_least(:once).and_return(legacy_url3.urlname)
|
|
158
|
-
|
|
149
|
+
alchemy_get :show, urlname: "index.php"
|
|
159
150
|
expect(URI.parse(response["Location"]).query).to be_nil
|
|
160
151
|
end
|
|
161
152
|
|
|
162
153
|
it "should only redirect to legacy url if no page was found for urlname" do
|
|
163
|
-
|
|
154
|
+
alchemy_get :show, urlname: legacy_page.urlname
|
|
164
155
|
expect(response.status).to eq(200)
|
|
165
156
|
expect(response).not_to redirect_to("/#{page.urlname}")
|
|
166
157
|
end
|
|
167
158
|
|
|
168
159
|
it "should redirect to last page that has that legacy url" do
|
|
169
160
|
expect(request).to receive(:fullpath).at_least(:once).and_return(legacy_url2.urlname)
|
|
170
|
-
|
|
161
|
+
alchemy_get :show, urlname: legacy_url2.urlname
|
|
171
162
|
expect(response).to redirect_to("/#{second_page.urlname}")
|
|
172
163
|
end
|
|
173
164
|
|
|
174
165
|
it "should redirect even if the url has get parameters" do
|
|
175
166
|
expect(request).to receive(:fullpath).at_least(:once).and_return(legacy_url3.urlname)
|
|
176
|
-
|
|
167
|
+
alchemy_get :show, urlname: legacy_url3.urlname
|
|
177
168
|
expect(response).to redirect_to("/#{second_page.urlname}")
|
|
178
169
|
end
|
|
179
170
|
|
|
180
171
|
it "should redirect even if the url has nested urlname" do
|
|
181
172
|
expect(request).to receive(:fullpath).at_least(:once).and_return(legacy_url5.urlname)
|
|
182
|
-
|
|
173
|
+
alchemy_get :show, urlname: legacy_url5.urlname
|
|
183
174
|
expect(response).to redirect_to("/#{second_page.urlname}")
|
|
184
175
|
end
|
|
185
176
|
end
|
|
@@ -193,12 +184,12 @@ module Alchemy
|
|
|
193
184
|
|
|
194
185
|
context "with no lang parameter present" do
|
|
195
186
|
it "should store defaults language id in the session." do
|
|
196
|
-
|
|
187
|
+
alchemy_get :show, urlname: 'a-public-page'
|
|
197
188
|
expect(controller.session[:alchemy_language_id]).to eq(Language.default.id)
|
|
198
189
|
end
|
|
199
190
|
|
|
200
191
|
it "should store default language as class var." do
|
|
201
|
-
|
|
192
|
+
alchemy_get :show, urlname: 'a-public-page'
|
|
202
193
|
expect(Language.current).to eq(Language.default)
|
|
203
194
|
end
|
|
204
195
|
end
|