alchemy_cms 3.3.0.rc1 → 3.3.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -2
- data/Gemfile +1 -0
- data/alchemy_cms.gemspec +6 -6
- data/app/assets/javascripts/alchemy/alchemy.base.js.coffee +0 -7
- data/app/assets/javascripts/alchemy/alchemy.dialog.js.coffee +4 -4
- data/app/assets/javascripts/alchemy/alchemy.element_editors.js.coffee +51 -5
- data/app/assets/javascripts/alchemy/alchemy.sitemap.js.coffee +0 -2
- data/app/assets/stylesheets/alchemy/elements.scss +2 -2
- data/app/controllers/alchemy/admin/elements_controller.rb +2 -0
- data/app/controllers/alchemy/admin/pages_controller.rb +11 -3
- data/app/controllers/alchemy/admin/pictures_controller.rb +1 -0
- data/app/models/alchemy/element.rb +3 -1
- data/app/models/alchemy/element/element_contents.rb +2 -7
- data/app/models/alchemy/element/presenters.rb +11 -4
- data/app/models/alchemy/page.rb +3 -1
- data/app/views/alchemy/admin/attachments/archive_overlay.js.erb +0 -1
- data/app/views/alchemy/admin/contents/create.js.erb +0 -1
- data/app/views/alchemy/admin/elements/_element_header.html.erb +3 -1
- data/app/views/alchemy/admin/elements/order.js.erb +25 -10
- data/app/views/alchemy/admin/elements/update.js.erb +1 -2
- data/app/views/alchemy/admin/essence_files/assign.js.erb +0 -1
- data/app/views/alchemy/admin/essence_pictures/assign.js.erb +0 -1
- data/app/views/alchemy/admin/legacy_page_urls/create.js.erb +0 -1
- data/app/views/alchemy/admin/pages/destroy.js.erb +0 -1
- data/app/views/alchemy/admin/pages/update.js.erb +6 -4
- data/app/views/alchemy/admin/pictures/_filter_and_size_bar.html.erb +2 -1
- data/app/views/alchemy/admin/pictures/_picture_to_assign.html.erb +1 -7
- data/app/views/alchemy/admin/pictures/archive_overlay.js.erb +0 -1
- data/bin/alchemy +1 -1
- data/bin/rspec +3 -2
- data/bin/spring +6 -6
- data/config/alchemy/config.yml +6 -1
- data/lib/alchemy/seeder.rb +9 -3
- data/lib/alchemy/version.rb +1 -1
- metadata +6 -471
- data/spec/controllers/alchemy/admin/attachments_controller_spec.rb +0 -193
- data/spec/controllers/alchemy/admin/base_controller_spec.rb +0 -87
- data/spec/controllers/alchemy/admin/clipboard_controller_spec.rb +0 -60
- data/spec/controllers/alchemy/admin/contents_controller_spec.rb +0 -78
- data/spec/controllers/alchemy/admin/dashboard_controller_spec.rb +0 -144
- data/spec/controllers/alchemy/admin/elements_controller_spec.rb +0 -496
- data/spec/controllers/alchemy/admin/essence_files_controller_spec.rb +0 -76
- data/spec/controllers/alchemy/admin/essence_pictures_controller_spec.rb +0 -202
- data/spec/controllers/alchemy/admin/languages_controller_spec.rb +0 -73
- data/spec/controllers/alchemy/admin/layoutpages_controller_spec.rb +0 -21
- data/spec/controllers/alchemy/admin/pages_controller_spec.rb +0 -639
- data/spec/controllers/alchemy/admin/pictures_controller_spec.rb +0 -383
- data/spec/controllers/alchemy/admin/resources_controller_spec.rb +0 -81
- data/spec/controllers/alchemy/admin/tags_controller_spec.rb +0 -63
- data/spec/controllers/alchemy/admin/trash_controller_spec.rb +0 -67
- data/spec/controllers/alchemy/api/contents_controller_spec.rb +0 -125
- data/spec/controllers/alchemy/api/elements_controller_spec.rb +0 -124
- data/spec/controllers/alchemy/api/pages_controller_spec.rb +0 -167
- data/spec/controllers/alchemy/attachments_controller_spec.rb +0 -64
- data/spec/controllers/alchemy/base_controller_spec.rb +0 -106
- data/spec/controllers/alchemy/elements_controller_spec.rb +0 -48
- data/spec/controllers/alchemy/messages_controller_spec.rb +0 -204
- data/spec/controllers/alchemy/on_page_layout_mixin_spec.rb +0 -330
- data/spec/controllers/alchemy/pages_controller_spec.rb +0 -343
- data/spec/controllers/alchemy/pictures_controller_spec.rb +0 -415
- data/spec/dummy/Rakefile +0 -6
- data/spec/dummy/app/assets/javascripts/application.js +0 -13
- data/spec/dummy/app/assets/stylesheets/application.css +0 -15
- data/spec/dummy/app/controllers/admin/events_controller.rb +0 -3
- data/spec/dummy/app/controllers/application_controller.rb +0 -15
- data/spec/dummy/app/controllers/login_controller.rb +0 -5
- data/spec/dummy/app/helpers/application_helper.rb +0 -2
- data/spec/dummy/app/mailers/.gitkeep +0 -0
- data/spec/dummy/app/models/ability.rb +0 -9
- data/spec/dummy/app/models/dummy_model.rb +0 -3
- data/spec/dummy/app/models/dummy_user.rb +0 -15
- data/spec/dummy/app/models/event.rb +0 -10
- data/spec/dummy/app/models/location.rb +0 -3
- data/spec/dummy/app/views/alchemy/elements/_all_you_can_eat_editor.html.erb +0 -11
- data/spec/dummy/app/views/alchemy/elements/_all_you_can_eat_view.html.erb +0 -31
- data/spec/dummy/app/views/alchemy/elements/_article_editor.html.erb +0 -6
- data/spec/dummy/app/views/alchemy/elements/_article_view.html.erb +0 -10
- data/spec/dummy/app/views/alchemy/elements/_bild_editor.html.erb +0 -3
- data/spec/dummy/app/views/alchemy/elements/_bild_view.html.erb +0 -5
- data/spec/dummy/app/views/alchemy/elements/_contactform_editor.html.erb +0 -6
- data/spec/dummy/app/views/alchemy/elements/_contactform_view.html.erb +0 -16
- data/spec/dummy/app/views/alchemy/elements/_download_editor.html.erb +0 -3
- data/spec/dummy/app/views/alchemy/elements/_download_view.html.erb +0 -5
- data/spec/dummy/app/views/alchemy/elements/_erb_element_editor.html.erb +0 -3
- data/spec/dummy/app/views/alchemy/elements/_erb_element_view.html.erb +0 -5
- data/spec/dummy/app/views/alchemy/elements/_header_editor.html.erb +0 -3
- data/spec/dummy/app/views/alchemy/elements/_header_view.html.erb +0 -5
- data/spec/dummy/app/views/alchemy/elements/_headline_editor.html.erb +0 -1
- data/spec/dummy/app/views/alchemy/elements/_headline_view.html.erb +0 -1
- data/spec/dummy/app/views/alchemy/elements/_news_editor.html.erb +0 -5
- data/spec/dummy/app/views/alchemy/elements/_news_view.html.erb +0 -11
- data/spec/dummy/app/views/alchemy/elements/_search_editor.html.erb +0 -1
- data/spec/dummy/app/views/alchemy/elements/_search_view.html.erb +0 -4
- data/spec/dummy/app/views/alchemy/elements/_slide_editor.html.erb +0 -3
- data/spec/dummy/app/views/alchemy/elements/_slide_view.html.erb +0 -5
- data/spec/dummy/app/views/alchemy/elements/_slider_editor.html.erb +0 -2
- data/spec/dummy/app/views/alchemy/elements/_slider_view.html.erb +0 -4
- data/spec/dummy/app/views/alchemy/elements/_text_editor.html.erb +0 -3
- data/spec/dummy/app/views/alchemy/elements/_text_view.html.erb +0 -5
- data/spec/dummy/app/views/alchemy/page_layouts/_standard.html.erb +0 -15
- data/spec/dummy/app/views/layouts/application.html.erb +0 -17
- data/spec/dummy/bin/bundle +0 -3
- data/spec/dummy/bin/rails +0 -4
- data/spec/dummy/bin/rake +0 -4
- data/spec/dummy/config.ru +0 -4
- data/spec/dummy/config/alchemy/cells.yml +0 -5
- data/spec/dummy/config/alchemy/elements.yml +0 -109
- data/spec/dummy/config/alchemy/page_layouts.yml +0 -32
- data/spec/dummy/config/application.rb +0 -32
- data/spec/dummy/config/boot.rb +0 -5
- data/spec/dummy/config/database.yml +0 -32
- data/spec/dummy/config/environment.rb +0 -5
- data/spec/dummy/config/environments/development.rb +0 -41
- data/spec/dummy/config/environments/production.rb +0 -77
- data/spec/dummy/config/environments/test.rb +0 -43
- data/spec/dummy/config/initializers/alchemy.rb +0 -3
- data/spec/dummy/config/initializers/assets.rb +0 -11
- data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/dummy/config/initializers/cookies_serializer.rb +0 -3
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -4
- data/spec/dummy/config/initializers/inflections.rb +0 -16
- data/spec/dummy/config/initializers/mime_types.rb +0 -4
- data/spec/dummy/config/initializers/secret_token.rb +0 -12
- data/spec/dummy/config/initializers/session_store.rb +0 -3
- data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/spec/dummy/config/locales/kl.yml +0 -2
- data/spec/dummy/config/routes.rb +0 -12
- data/spec/dummy/config/secrets.yml +0 -22
- data/spec/dummy/db/migrate/20121026104128_create_events.rb +0 -20
- data/spec/dummy/db/migrate/20130328101418_create_locations.rb +0 -9
- 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/20131209225243_create_dummy_users.rb +0 -9
- data/spec/dummy/db/migrate/20150122213511_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb +0 -31
- data/spec/dummy/db/migrate/20150122213512_add_missing_unique_indices.acts_as_taggable_on_engine.rb +0 -20
- data/spec/dummy/db/migrate/20150122213513_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb +0 -15
- data/spec/dummy/db/migrate/20150122213514_add_missing_taggable_index.acts_as_taggable_on_engine.rb +0 -10
- data/spec/dummy/db/migrate/20150412103152_create_dummy_model.rb +0 -7
- data/spec/dummy/db/migrate/20150608204610_add_parent_element_id_to_alchemy_elements.rb +0 -1
- data/spec/dummy/db/migrate/20150729151825_add_link_text_to_alchemy_essence_files.rb +0 -1
- data/spec/dummy/db/migrate/20150906195818_add_locale_to_alchemy_languages.rb +0 -1
- data/spec/dummy/db/schema.rb +0 -326
- data/spec/dummy/db/seeds.rb +0 -1
- data/spec/dummy/lib/assets/.gitkeep +0 -0
- data/spec/dummy/public/404.html +0 -67
- data/spec/dummy/public/422.html +0 -67
- data/spec/dummy/public/500.html +0 -66
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/spec/javascripts +0 -1
- data/spec/factories.rb +0 -13
- data/spec/features/admin/admin_layout_spec.rb +0 -14
- data/spec/features/admin/dashboard_spec.rb +0 -81
- data/spec/features/admin/edit_elements_feature_spec.rb +0 -36
- data/spec/features/admin/language_tree_feature_spec.rb +0 -32
- data/spec/features/admin/languages_features_spec.rb +0 -65
- data/spec/features/admin/legacy_page_url_management_spec.rb +0 -62
- data/spec/features/admin/link_overlay_spec.rb +0 -53
- data/spec/features/admin/locale_select_feature_spec.rb +0 -25
- data/spec/features/admin/modules_integration_spec.rb +0 -23
- data/spec/features/admin/navigation_feature_spec.rb +0 -22
- data/spec/features/admin/page_creation_feature_spec.rb +0 -51
- data/spec/features/admin/page_editing_feature_spec.rb +0 -135
- data/spec/features/admin/picture_library_integration_spec.rb +0 -62
- data/spec/features/admin/resources_integration_spec.rb +0 -128
- data/spec/features/admin/site_select_feature_spec.rb +0 -31
- data/spec/features/admin/tinymce_feature_spec.rb +0 -33
- data/spec/features/navigation_spec.rb +0 -9
- data/spec/features/page_feature_spec.rb +0 -186
- data/spec/features/page_redirects_spec.rb +0 -358
- data/spec/features/picture_security_spec.rb +0 -29
- data/spec/features/security_spec.rb +0 -24
- data/spec/features/translation_integration_spec.rb +0 -51
- data/spec/fixtures/500x500.png +0 -0
- data/spec/fixtures/80x60.png +0 -0
- data/spec/fixtures/animated.gif +0 -0
- data/spec/fixtures/image with spaces.png +0 -0
- data/spec/fixtures/image.png +0 -0
- data/spec/fixtures/image2.PNG +0 -0
- data/spec/fixtures/image3.jpeg +0 -0
- data/spec/helpers/alchemy/admin/attachments_helper_spec.rb +0 -15
- data/spec/helpers/alchemy/admin/base_helper_spec.rb +0 -280
- data/spec/helpers/alchemy/admin/contents_helper_spec.rb +0 -46
- data/spec/helpers/alchemy/admin/elements_helper_spec.rb +0 -314
- data/spec/helpers/alchemy/admin/essences_helper_spec.rb +0 -201
- data/spec/helpers/alchemy/admin/navigation_helper_spec.rb +0 -294
- data/spec/helpers/alchemy/admin/pages_helper_spec.rb +0 -63
- data/spec/helpers/alchemy/admin/pictures_helper_spec.rb +0 -28
- data/spec/helpers/alchemy/admin/tags_helper_spec.rb +0 -111
- data/spec/helpers/alchemy/base_helper_spec.rb +0 -44
- data/spec/helpers/alchemy/elements_block_helper_spec.rb +0 -135
- data/spec/helpers/alchemy/elements_helper_spec.rb +0 -326
- data/spec/helpers/alchemy/essences_helper_spec.rb +0 -85
- data/spec/helpers/alchemy/pages_helper_spec.rb +0 -499
- data/spec/helpers/alchemy/picture_url_helpers_spec.rb +0 -78
- data/spec/helpers/alchemy/url_helper_spec.rb +0 -200
- data/spec/javascripts/alchemy/dialog_spec.coffee +0 -82
- data/spec/javascripts/alchemy/link_overlay_spec.coffee +0 -25
- data/spec/javascripts/alchemy_integration_spec.coffee +0 -3
- data/spec/javascripts/fixtures/select.html +0 -3
- data/spec/javascripts/helpers/mock-ajax.js +0 -199
- data/spec/javascripts/helpers/test_responses/test_responses.js +0 -1
- data/spec/javascripts/support/jasmine.yml +0 -29
- data/spec/libraries/auth_accessors_spec.rb +0 -40
- data/spec/libraries/config_spec.rb +0 -111
- data/spec/libraries/controller_actions_spec.rb +0 -133
- data/spec/libraries/i18n_spec.rb +0 -37
- data/spec/libraries/kaminari/scoped_pagination_url_helper_spec.rb +0 -30
- data/spec/libraries/modules_spec.rb +0 -67
- data/spec/libraries/mount_point_spec.rb +0 -77
- data/spec/libraries/page_layout_spec.rb +0 -150
- data/spec/libraries/paths_spec.rb +0 -15
- data/spec/libraries/permissions_spec.rb +0 -260
- data/spec/libraries/resource_spec.rb +0 -344
- data/spec/libraries/resources_helper_spec.rb +0 -193
- data/spec/libraries/shell_spec.rb +0 -121
- data/spec/libraries/template_tracker_spec.rb +0 -85
- data/spec/libraries/tinymce_spec.rb +0 -111
- data/spec/libraries/userstamp_spec.rb +0 -10
- data/spec/mailers/alchemy/messages_spec.rb +0 -21
- data/spec/models/alchemy/attachment_spec.rb +0 -250
- data/spec/models/alchemy/cell_spec.rb +0 -101
- data/spec/models/alchemy/content_spec.rb +0 -513
- data/spec/models/alchemy/element_spec.rb +0 -862
- data/spec/models/alchemy/element_to_page_spec.rb +0 -13
- data/spec/models/alchemy/essence_boolean_spec.rb +0 -10
- data/spec/models/alchemy/essence_date_spec.rb +0 -28
- data/spec/models/alchemy/essence_file_spec.rb +0 -40
- data/spec/models/alchemy/essence_html_spec.rb +0 -18
- data/spec/models/alchemy/essence_link_spec.rb +0 -10
- data/spec/models/alchemy/essence_picture_spec.rb +0 -255
- data/spec/models/alchemy/essence_richtext_spec.rb +0 -23
- data/spec/models/alchemy/essence_select_spec.rb +0 -10
- data/spec/models/alchemy/essence_text_spec.rb +0 -110
- data/spec/models/alchemy/language_spec.rb +0 -243
- data/spec/models/alchemy/legacy_page_url_spec.rb +0 -21
- data/spec/models/alchemy/message_spec.rb +0 -55
- data/spec/models/alchemy/page_spec.rb +0 -2108
- data/spec/models/alchemy/picture_spec.rb +0 -418
- data/spec/models/alchemy/site_spec.rb +0 -168
- data/spec/models/alchemy/tag_spec.rb +0 -29
- data/spec/models/dummy_model_spec.rb +0 -10
- data/spec/requests/alchemy/admin/resources_requests_spec.rb +0 -26
- data/spec/requests/alchemy/admin/site_requests_spec.rb +0 -19
- data/spec/requests/alchemy/site_requests_spec.rb +0 -18
- data/spec/requests/alchemy/sitemap_spec.rb +0 -56
- data/spec/routing/api_routing_spec.rb +0 -150
- data/spec/routing/routing_spec.rb +0 -340
- data/spec/spec_helper.rb +0 -90
- data/spec/support/ci/install_phantomjs +0 -7
- data/spec/support/hint_examples.rb +0 -28
- data/spec/support/test_tweaks.rb +0 -31
- data/spec/support/transformation_examples.rb +0 -179
- data/spec/tasks/helpers_spec.rb +0 -217
- data/spec/views/admin/pictures/show_spec.rb +0 -43
- data/spec/views/essences/essence_boolean_editor_spec.rb +0 -32
- data/spec/views/essences/essence_boolean_view_spec.rb +0 -23
- data/spec/views/essences/essence_date_view_spec.rb +0 -38
- data/spec/views/essences/essence_file_editor_spec.rb +0 -59
- data/spec/views/essences/essence_file_view_spec.rb +0 -77
- data/spec/views/essences/essence_html_view_spec.rb +0 -22
- data/spec/views/essences/essence_link_view_spec.rb +0 -41
- data/spec/views/essences/essence_picture_editor_spec.rb +0 -80
- data/spec/views/essences/essence_picture_view_spec.rb +0 -128
- data/spec/views/essences/essence_richtext_view_spec.rb +0 -32
- data/spec/views/essences/essence_select_view_spec.rb +0 -11
- data/spec/views/essences/essence_text_view_spec.rb +0 -51
@@ -1,63 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Alchemy
|
4
|
-
module Admin
|
5
|
-
describe TagsController do
|
6
|
-
before { authorize_user(:as_admin) }
|
7
|
-
|
8
|
-
describe '#create' do
|
9
|
-
context 'without required params' do
|
10
|
-
render_views
|
11
|
-
|
12
|
-
it "does not create tag" do
|
13
|
-
alchemy_post :create, tag: {name: ''}
|
14
|
-
expect(response.body).to have_content("can't be blank")
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
context 'with required params' do
|
19
|
-
it "creates tag and redirects to tags view" do
|
20
|
-
expect {
|
21
|
-
alchemy_post :create, tag: {name: 'Foo'}
|
22
|
-
}.to change { ActsAsTaggableOn::Tag.count }.by(1)
|
23
|
-
expect(response).to redirect_to admin_tags_path
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
describe '#edit' do
|
29
|
-
let(:tag) { ActsAsTaggableOn::Tag.create(name: 'Sputz') }
|
30
|
-
let(:another_tag) { ActsAsTaggableOn::Tag.create(name: 'Hutzl') }
|
31
|
-
|
32
|
-
before { another_tag; tag }
|
33
|
-
|
34
|
-
it "loads alls tags but not the one editing" do
|
35
|
-
alchemy_get :edit, id: tag.id
|
36
|
-
expect(assigns(:tags)).to include(another_tag)
|
37
|
-
expect(assigns(:tags)).not_to include(tag)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
describe '#update' do
|
42
|
-
let(:tag) { ActsAsTaggableOn::Tag.create(name: 'Sputz') }
|
43
|
-
|
44
|
-
it "changes tags name" do
|
45
|
-
alchemy_put :update, id: tag.id, tag: {name: 'Foo'}
|
46
|
-
expect(response).to redirect_to(admin_tags_path)
|
47
|
-
expect(tag.reload.name).to eq('Foo')
|
48
|
-
end
|
49
|
-
|
50
|
-
context 'with merg_to param given' do
|
51
|
-
let(:another_tag) { ActsAsTaggableOn::Tag.create(name: 'Hutzl') }
|
52
|
-
|
53
|
-
it "replaces tag with other tag" do
|
54
|
-
expect(Alchemy::Tag).to receive(:replace)
|
55
|
-
expect_any_instance_of(ActsAsTaggableOn::Tag).to receive(:destroy)
|
56
|
-
alchemy_put :update, id: tag.id, tag: {merge_to: another_tag.id}
|
57
|
-
expect(response).to redirect_to(admin_tags_path)
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
@@ -1,67 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Alchemy
|
4
|
-
module Admin
|
5
|
-
describe TrashController do
|
6
|
-
render_views
|
7
|
-
|
8
|
-
let(:alchemy_page) { create(:alchemy_page, :public) }
|
9
|
-
let(:element) { create(:alchemy_element, public: false, page: alchemy_page) }
|
10
|
-
|
11
|
-
before {
|
12
|
-
authorize_user(:as_admin)
|
13
|
-
element.trash!
|
14
|
-
}
|
15
|
-
|
16
|
-
it "should hold trashed elements" do
|
17
|
-
alchemy_get :index, page_id: alchemy_page.id
|
18
|
-
expect(response.body).to have_selector("#element_#{element.id}.element-editor")
|
19
|
-
end
|
20
|
-
|
21
|
-
it "should not hold elements that are not trashed" do
|
22
|
-
element = create(:alchemy_element, page: alchemy_page, public: false)
|
23
|
-
alchemy_get :index, page_id: alchemy_page.id
|
24
|
-
expect(response.body).not_to have_selector("#element_#{element.id}.element-editor")
|
25
|
-
end
|
26
|
-
|
27
|
-
context "with unique elements inside the trash" do
|
28
|
-
let(:trashed) { build_stubbed(:alchemy_element, :unique, position: nil, public: false, folded: true, page: alchemy_page) }
|
29
|
-
before { allow(Element).to receive(:trashed).and_return([trashed]) }
|
30
|
-
|
31
|
-
context "and no unique elements on the page" do
|
32
|
-
before do
|
33
|
-
allow(alchemy_page).to receive(:elements).and_return double(not_trashed: double(pluck: []))
|
34
|
-
end
|
35
|
-
|
36
|
-
it "unique elements should be draggable" do
|
37
|
-
alchemy_get :index, page_id: alchemy_page.id
|
38
|
-
expect(response.body).to have_selector("#element_#{trashed.id}.element-editor.draggable")
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
context "and with an unique element on the page" do
|
43
|
-
let(:unique) { build_stubbed(:alchemy_element, :unique) }
|
44
|
-
let(:page) { build_stubbed(:alchemy_page, :public) }
|
45
|
-
|
46
|
-
before do
|
47
|
-
allow(Page).to receive(:find).and_return(page)
|
48
|
-
allow(page).to receive(:elements).and_return double(not_trashed: double(pluck: [unique.name]))
|
49
|
-
end
|
50
|
-
|
51
|
-
it "unique elements should not be draggable" do
|
52
|
-
alchemy_get :index, page_id: page.id
|
53
|
-
expect(response.body).to have_selector("#element_#{trashed.id}.element-editor.not-draggable")
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
describe "#clear" do
|
59
|
-
it "should destroy all containing elements" do
|
60
|
-
expect(Element.trashed).not_to be_empty
|
61
|
-
alchemy_xhr :post, :clear, page_id: alchemy_page.id
|
62
|
-
expect(Element.trashed).to be_empty
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
@@ -1,125 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Alchemy
|
4
|
-
describe Api::ContentsController do
|
5
|
-
describe '#index' do
|
6
|
-
let!(:page) { create(:alchemy_page) }
|
7
|
-
let!(:element) { create(:alchemy_element, page: page) }
|
8
|
-
let!(:content) { create(:alchemy_content, element: element) }
|
9
|
-
|
10
|
-
it "returns all public contents as json objects" do
|
11
|
-
alchemy_get :index, format: :json
|
12
|
-
|
13
|
-
expect(response.status).to eq(200)
|
14
|
-
expect(response.content_type).to eq('application/json')
|
15
|
-
|
16
|
-
result = JSON.parse(response.body)
|
17
|
-
|
18
|
-
expect(result).to have_key("contents")
|
19
|
-
expect(result['contents'].size).to eq(Alchemy::Content.count)
|
20
|
-
end
|
21
|
-
|
22
|
-
context 'with element_id' do
|
23
|
-
let!(:other_element) { create(:alchemy_element, page: page) }
|
24
|
-
let!(:other_content) { create(:alchemy_content, element: other_element) }
|
25
|
-
|
26
|
-
it "returns only contents from this element" do
|
27
|
-
alchemy_get :index, element_id: other_element.id, format: :json
|
28
|
-
|
29
|
-
expect(response.status).to eq(200)
|
30
|
-
expect(response.content_type).to eq('application/json')
|
31
|
-
|
32
|
-
result = JSON.parse(response.body)
|
33
|
-
|
34
|
-
expect(result).to have_key("contents")
|
35
|
-
expect(result['contents'].size).to eq(1)
|
36
|
-
expect(result['contents'][0]['element_id']).to eq(other_element.id)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
context 'with empty element_id' do
|
41
|
-
it "returns all contents" do
|
42
|
-
alchemy_get :index, element_id: element.id, format: :json
|
43
|
-
|
44
|
-
expect(response.status).to eq(200)
|
45
|
-
expect(response.content_type).to eq('application/json')
|
46
|
-
|
47
|
-
result = JSON.parse(response.body)
|
48
|
-
|
49
|
-
expect(result).to have_key("contents")
|
50
|
-
expect(result['contents'].size).to eq(Alchemy::Content.count)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
describe '#show' do
|
56
|
-
context 'with no other params given' do
|
57
|
-
let(:page) { create(:alchemy_page) }
|
58
|
-
let(:element) { create(:alchemy_element, page: page) }
|
59
|
-
let(:content) { create(:alchemy_content, element: element) }
|
60
|
-
|
61
|
-
before do
|
62
|
-
expect(Content).to receive(:find).and_return(content)
|
63
|
-
end
|
64
|
-
|
65
|
-
it "returns content as json" do
|
66
|
-
alchemy_get :show, id: content.id, format: :json
|
67
|
-
|
68
|
-
expect(response.status).to eq(200)
|
69
|
-
expect(response.content_type).to eq('application/json')
|
70
|
-
|
71
|
-
result = JSON.parse(response.body)
|
72
|
-
|
73
|
-
expect(result['id']).to eq(content.id)
|
74
|
-
end
|
75
|
-
|
76
|
-
context 'requesting an restricted content' do
|
77
|
-
let(:page) { create(:alchemy_page, restricted: true) }
|
78
|
-
|
79
|
-
it "responds with 403" do
|
80
|
-
alchemy_get :show, id: content.id, format: :json
|
81
|
-
|
82
|
-
expect(response.content_type).to eq('application/json')
|
83
|
-
expect(response.status).to eq(403)
|
84
|
-
|
85
|
-
result = JSON.parse(response.body)
|
86
|
-
|
87
|
-
expect(result).to have_key("error")
|
88
|
-
expect(result['error']).to eq("Not authorized")
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
context 'with element_id and name params given' do
|
94
|
-
let!(:page) { create(:alchemy_page) }
|
95
|
-
let!(:element) { create(:alchemy_element, page: page) }
|
96
|
-
let!(:content) { create(:alchemy_content, element: element) }
|
97
|
-
|
98
|
-
it 'returns the named content from element with given id.' do
|
99
|
-
alchemy_get :show, element_id: element.id, name: content.name, format: :json
|
100
|
-
|
101
|
-
expect(response.status).to eq(200)
|
102
|
-
expect(response.content_type).to eq('application/json')
|
103
|
-
|
104
|
-
result = JSON.parse(response.body)
|
105
|
-
|
106
|
-
expect(result['id']).to eq(content.id)
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
context 'with empty element_id or name param' do
|
111
|
-
it 'returns 404 error.' do
|
112
|
-
alchemy_get :show, element_id: '', name: '', format: :json
|
113
|
-
|
114
|
-
expect(response.status).to eq(404)
|
115
|
-
expect(response.content_type).to eq('application/json')
|
116
|
-
|
117
|
-
result = JSON.parse(response.body)
|
118
|
-
|
119
|
-
expect(result).to have_key("error")
|
120
|
-
expect(result['error']).to eq("Record not found")
|
121
|
-
end
|
122
|
-
end
|
123
|
-
end
|
124
|
-
end
|
125
|
-
end
|
@@ -1,124 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Alchemy
|
4
|
-
describe Api::ElementsController do
|
5
|
-
describe '#index' do
|
6
|
-
let(:page) { create(:alchemy_page, :public) }
|
7
|
-
|
8
|
-
before do
|
9
|
-
2.times { create(:alchemy_element, page: page) }
|
10
|
-
end
|
11
|
-
|
12
|
-
it "returns all public elements as json objects" do
|
13
|
-
alchemy_get :index, format: :json
|
14
|
-
|
15
|
-
expect(response.status).to eq(200)
|
16
|
-
expect(response.content_type).to eq('application/json')
|
17
|
-
|
18
|
-
result = JSON.parse(response.body)
|
19
|
-
|
20
|
-
expect(result).to have_key('elements')
|
21
|
-
expect(result['elements'].size).to eq(Alchemy::Element.count)
|
22
|
-
end
|
23
|
-
|
24
|
-
context 'with page_id param' do
|
25
|
-
let!(:other_page) { create(:alchemy_page, :public) }
|
26
|
-
let!(:other_element) { create(:alchemy_element, page: other_page) }
|
27
|
-
|
28
|
-
it "returns only elements from this page" do
|
29
|
-
alchemy_get :index, page_id: other_page.id, format: :json
|
30
|
-
|
31
|
-
expect(response.status).to eq(200)
|
32
|
-
expect(response.content_type).to eq('application/json')
|
33
|
-
|
34
|
-
result = JSON.parse(response.body)
|
35
|
-
|
36
|
-
expect(result).to have_key('elements')
|
37
|
-
expect(result['elements'].size).to eq(1)
|
38
|
-
expect(result['elements'][0]['page_id']).to eq(other_page.id)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
context 'with empty page_id param' do
|
43
|
-
it "returns all elements" do
|
44
|
-
alchemy_get :index, page_id: '', format: :json
|
45
|
-
|
46
|
-
expect(response.status).to eq(200)
|
47
|
-
expect(response.content_type).to eq('application/json')
|
48
|
-
|
49
|
-
result = JSON.parse(response.body)
|
50
|
-
|
51
|
-
expect(result).to have_key('elements')
|
52
|
-
expect(result['elements'].size).to eq(Alchemy::Element.count)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
context 'with named param' do
|
57
|
-
let!(:other_element) { create(:alchemy_element, page: page, name: 'news') }
|
58
|
-
|
59
|
-
it "returns only elements named like this." do
|
60
|
-
alchemy_get :index, named: 'news', format: :json
|
61
|
-
|
62
|
-
expect(response.status).to eq(200)
|
63
|
-
expect(response.content_type).to eq('application/json')
|
64
|
-
|
65
|
-
result = JSON.parse(response.body)
|
66
|
-
|
67
|
-
expect(result).to have_key('elements')
|
68
|
-
expect(result['elements'].size).to eq(1)
|
69
|
-
expect(result['elements'][0]['name']).to eq('news')
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
context 'with empty named param' do
|
74
|
-
it "returns all elements" do
|
75
|
-
alchemy_get :index, named: '', format: :json
|
76
|
-
|
77
|
-
expect(response.status).to eq(200)
|
78
|
-
expect(response.content_type).to eq('application/json')
|
79
|
-
|
80
|
-
result = JSON.parse(response.body)
|
81
|
-
|
82
|
-
expect(result).to have_key('elements')
|
83
|
-
expect(result['elements'].size).to eq(Alchemy::Element.count)
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
describe '#show' do
|
89
|
-
let(:page) { build_stubbed(:alchemy_page) }
|
90
|
-
let(:element) { build_stubbed(:alchemy_element, page: page, position: 1) }
|
91
|
-
|
92
|
-
before do
|
93
|
-
expect(Element).to receive(:find).and_return(element)
|
94
|
-
end
|
95
|
-
|
96
|
-
it "returns element as json" do
|
97
|
-
alchemy_get :show, id: element.id, format: :json
|
98
|
-
|
99
|
-
expect(response.status).to eq(200)
|
100
|
-
expect(response.content_type).to eq('application/json')
|
101
|
-
|
102
|
-
result = JSON.parse(response.body)
|
103
|
-
|
104
|
-
expect(result['id']).to eq(element.id)
|
105
|
-
end
|
106
|
-
|
107
|
-
context 'requesting an restricted element' do
|
108
|
-
let(:page) { build_stubbed(:alchemy_page, restricted: true) }
|
109
|
-
|
110
|
-
it "responds with 403" do
|
111
|
-
alchemy_get :show, id: element.id, format: :json
|
112
|
-
|
113
|
-
expect(response.status).to eq(403)
|
114
|
-
expect(response.content_type).to eq('application/json')
|
115
|
-
|
116
|
-
result = JSON.parse(response.body)
|
117
|
-
|
118
|
-
expect(result).to have_key('error')
|
119
|
-
expect(result['error']).to eq("Not authorized")
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|
123
|
-
end
|
124
|
-
end
|
@@ -1,167 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Alchemy
|
4
|
-
describe Api::PagesController do
|
5
|
-
describe '#index' do
|
6
|
-
let!(:page) { create(:alchemy_page, :public) }
|
7
|
-
|
8
|
-
it "returns all public pages as json objects" do
|
9
|
-
alchemy_get :index, format: :json
|
10
|
-
|
11
|
-
expect(response.status).to eq(200)
|
12
|
-
expect(response.content_type).to eq('application/json')
|
13
|
-
|
14
|
-
result = JSON.parse(response.body)
|
15
|
-
|
16
|
-
expect(result).to have_key('pages')
|
17
|
-
expect(result['pages'].size).to eq(2)
|
18
|
-
end
|
19
|
-
|
20
|
-
context 'with page_layout' do
|
21
|
-
let!(:other_page) { create(:alchemy_page, :public, page_layout: 'news') }
|
22
|
-
|
23
|
-
it "returns only page with this page layout" do
|
24
|
-
alchemy_get :index, {page_layout: 'news', format: :json}
|
25
|
-
|
26
|
-
expect(response.status).to eq(200)
|
27
|
-
expect(response.content_type).to eq('application/json')
|
28
|
-
|
29
|
-
result = JSON.parse(response.body)
|
30
|
-
|
31
|
-
expect(result).to have_key('pages')
|
32
|
-
expect(result['pages'].size).to eq(1)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
context 'with empty string as page_layout' do
|
37
|
-
it "returns all pages" do
|
38
|
-
alchemy_get :index, {page_layout: '', format: :json}
|
39
|
-
|
40
|
-
expect(response.status).to eq(200)
|
41
|
-
expect(response.content_type).to eq('application/json')
|
42
|
-
|
43
|
-
result = JSON.parse(response.body)
|
44
|
-
|
45
|
-
expect(result).to have_key('pages')
|
46
|
-
expect(result['pages'].size).to eq(2)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
describe '#show' do
|
52
|
-
context 'for existing page' do
|
53
|
-
let(:page) { build_stubbed(:alchemy_page, :public, urlname: 'a-page') }
|
54
|
-
|
55
|
-
before do
|
56
|
-
expect(Page).to receive(:find_by).and_return(page)
|
57
|
-
end
|
58
|
-
|
59
|
-
it "returns page as json" do
|
60
|
-
alchemy_get :show, {urlname: page.urlname, format: :json}
|
61
|
-
|
62
|
-
expect(response.status).to eq(200)
|
63
|
-
expect(response.content_type).to eq('application/json')
|
64
|
-
|
65
|
-
result = JSON.parse(response.body)
|
66
|
-
|
67
|
-
expect(result['id']).to eq(page.id)
|
68
|
-
end
|
69
|
-
|
70
|
-
context 'requesting an restricted page' do
|
71
|
-
let(:page) { build_stubbed(:alchemy_page, restricted: true, urlname: 'a-page') }
|
72
|
-
|
73
|
-
it "responds with 403" do
|
74
|
-
alchemy_get :show, {urlname: page.urlname, format: :json}
|
75
|
-
|
76
|
-
expect(response.status).to eq(403)
|
77
|
-
expect(response.content_type).to eq('application/json')
|
78
|
-
|
79
|
-
result = JSON.parse(response.body)
|
80
|
-
|
81
|
-
expect(result).to have_key('error')
|
82
|
-
expect(result['error']).to eq("Not authorized")
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
context 'requesting a not public page' do
|
87
|
-
let(:page) { build_stubbed(:alchemy_page, urlname: 'a-page') }
|
88
|
-
|
89
|
-
it "responds with 403" do
|
90
|
-
alchemy_get :show, {urlname: page.urlname, format: :json}
|
91
|
-
|
92
|
-
expect(response.status).to eq(403)
|
93
|
-
expect(response.content_type).to eq('application/json')
|
94
|
-
|
95
|
-
result = JSON.parse(response.body)
|
96
|
-
|
97
|
-
expect(result).to have_key('error')
|
98
|
-
expect(result['error']).to eq("Not authorized")
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
context 'requesting an unknown page' do
|
104
|
-
it "responds with 404" do
|
105
|
-
alchemy_get :show, {urlname: 'not-existing', format: :json}
|
106
|
-
|
107
|
-
expect(response.status).to eq(404)
|
108
|
-
expect(response.content_type).to eq('application/json')
|
109
|
-
|
110
|
-
result = JSON.parse(response.body)
|
111
|
-
|
112
|
-
expect(result).to have_key('error')
|
113
|
-
expect(result['error']).to eq("Record not found")
|
114
|
-
end
|
115
|
-
|
116
|
-
context "because of requesting not existing language" do
|
117
|
-
let(:page) { create(:alchemy_page, :public) }
|
118
|
-
|
119
|
-
it "responds with 404" do
|
120
|
-
alchemy_get :show, {urlname: page.urlname, locale: 'na', format: :json}
|
121
|
-
expect(response.status).to eq(404)
|
122
|
-
end
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
context 'requesting a page with id' do
|
127
|
-
let(:page) { create(:alchemy_page, :public) }
|
128
|
-
|
129
|
-
it "responds with json" do
|
130
|
-
alchemy_get :show, {id: page.id, format: :json}
|
131
|
-
|
132
|
-
expect(response.status).to eq(200)
|
133
|
-
expect(response.content_type).to eq('application/json')
|
134
|
-
|
135
|
-
result = JSON.parse(response.body)
|
136
|
-
|
137
|
-
expect(result['id']).to eq(page.id)
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
context 'in an environment with multiple languages' do
|
142
|
-
let(:klingon) { create(:alchemy_language, :klingon) }
|
143
|
-
|
144
|
-
context 'having two pages with the same url names in different languages' do
|
145
|
-
let!(:english_page) { create(:alchemy_page, :public, language: Language.default, name: "same-name") }
|
146
|
-
let!(:klingon_page) { create(:alchemy_page, :public, language: klingon, name: "same-name") }
|
147
|
-
|
148
|
-
context 'when a locale is given' do
|
149
|
-
it 'renders the page related to its language' do
|
150
|
-
alchemy_get :show, {urlname: "same-name", locale: klingon_page.language_code, format: :json}
|
151
|
-
result = JSON.parse(response.body)
|
152
|
-
expect(result['id']).to eq(klingon_page.id)
|
153
|
-
end
|
154
|
-
end
|
155
|
-
|
156
|
-
context 'when no locale is given' do
|
157
|
-
it 'renders the page of the default language' do
|
158
|
-
alchemy_get :show, {urlname: "same-name", format: :json}
|
159
|
-
result = JSON.parse(response.body)
|
160
|
-
expect(result['id']).to eq(english_page.id)
|
161
|
-
end
|
162
|
-
end
|
163
|
-
end
|
164
|
-
end
|
165
|
-
end
|
166
|
-
end
|
167
|
-
end
|