alchemy_cms 3.1.0.beta1 → 3.1.0.beta2
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/.gitignore +1 -0
- data/.travis.yml +4 -2
- data/README.md +9 -1
- data/alchemy_cms.gemspec +24 -13
- data/app/assets/javascripts/alchemy/alchemy.autocomplete.js.coffee +1 -1
- data/app/assets/javascripts/alchemy/alchemy.element_editors.js.coffee +1 -1
- data/app/assets/javascripts/alchemy/alchemy.initializer.js.coffee +9 -0
- data/app/assets/javascripts/alchemy/alchemy.js +4 -0
- data/app/assets/javascripts/alchemy/alchemy.preview.js.coffee +3 -2
- data/app/assets/javascripts/alchemy/alchemy.preview_window.js.coffee +2 -0
- data/app/assets/javascripts/alchemy/alchemy.translations.js.coffee +43 -1
- data/app/assets/stylesheets/alchemy/_mixins.scss +1 -2
- data/app/assets/stylesheets/alchemy/archive.scss +1 -1
- data/app/assets/stylesheets/alchemy/base.scss +18 -1
- data/app/assets/stylesheets/alchemy/buttons.scss +5 -0
- data/app/assets/stylesheets/alchemy/dialogs.scss +0 -1
- data/app/assets/stylesheets/alchemy/frame.scss +17 -10
- data/app/assets/stylesheets/alchemy/menubar.css.scss +3 -0
- data/app/assets/stylesheets/alchemy/tables.scss +30 -8
- data/app/controllers/alchemy/admin/attachments_controller.rb +9 -1
- data/app/controllers/alchemy/admin/essence_files_controller.rb +3 -4
- data/app/controllers/alchemy/pages_controller.rb +20 -2
- data/app/models/alchemy/content.rb +2 -1
- data/app/models/alchemy/element.rb +1 -1
- data/app/views/alchemy/admin/attachments/_files_list.html.erb +22 -18
- data/app/views/alchemy/admin/attachments/index.html.erb +1 -1
- data/app/views/alchemy/admin/languages/_table.html.erb +29 -25
- data/app/views/alchemy/admin/languages/index.html.erb +1 -1
- data/app/views/alchemy/admin/pictures/info.html.erb +3 -2
- data/app/views/alchemy/admin/resources/_table.html.erb +17 -13
- data/app/views/alchemy/admin/resources/index.html.erb +1 -1
- data/app/views/alchemy/admin/sites/index.html.erb +1 -1
- data/app/views/alchemy/admin/tags/edit.html.erb +1 -1
- data/app/views/alchemy/admin/tags/index.html.erb +14 -10
- data/app/views/alchemy/essences/_essence_file_editor.html.erb +20 -24
- data/app/views/alchemy/messages/contact_form_mail.es.text.erb +12 -0
- data/app/views/layouts/alchemy/admin.html.erb +2 -0
- data/bin/alchemy +58 -26
- data/config/locales/alchemy.en.yml +2 -1
- data/config/locales/alchemy.es.yml +958 -0
- data/config/locales/alchemy.fr.yml +1 -1
- data/config/locales/alchemy.ru.yml +837 -0
- data/config/locales/simple_form.es.yml +6 -0
- data/config/locales/simple_form.ru.yml +25 -0
- data/lib/alchemy/engine.rb +11 -0
- data/lib/alchemy/essence.rb +12 -1
- data/lib/alchemy/resources_helper.rb +3 -1
- data/lib/alchemy/test_support/essence_shared_examples.rb +37 -0
- data/lib/alchemy/test_support/factories.rb +2 -0
- data/lib/alchemy/version.rb +1 -1
- data/lib/rails/generators/alchemy/module/templates/module_config.rb.tt +4 -2
- data/lib/rails/generators/alchemy/scaffold/files/alchemy.es.yml +31 -0
- data/lib/rails/generators/alchemy/scaffold/scaffold_generator.rb +1 -0
- data/lib/rails/templates/alchemy.rb +2 -0
- data/lib/tasks/alchemy/install.rake +11 -7
- data/spec/controllers/admin/attachments_controller_spec.rb +21 -0
- data/spec/controllers/admin/essence_files_controller_spec.rb +13 -12
- data/spec/controllers/alchemy/api/contents_controller_spec.rb +4 -4
- data/spec/controllers/attachments_controller_spec.rb +18 -0
- data/spec/controllers/pages_controller_spec.rb +20 -3
- data/spec/dummy/db/migrate/20121026104128_create_events.rb +2 -0
- data/spec/dummy/db/schema.rb +5 -3
- data/spec/features/admin/resources_integration_spec.rb +5 -0
- data/spec/features/page_feature_spec.rb +20 -0
- data/spec/models/content_spec.rb +24 -2
- data/spec/models/element_spec.rb +11 -0
- data/spec/views/essences/essence_file_editor_spec.rb +61 -0
- data/vendor/assets/javascripts/jquery_plugins/jquery.floatThead.min.js +3 -0
- data/vendor/assets/javascripts/tinymce/langs/es.js +197 -0
- data/vendor/assets/javascripts/tinymce/langs/ru.js +197 -0
- metadata +53 -38
@@ -0,0 +1,25 @@
|
|
1
|
+
ru:
|
2
|
+
simple_form:
|
3
|
+
"yes": 'Да'
|
4
|
+
"no": 'Нет'
|
5
|
+
required:
|
6
|
+
text: 'обязательные поля'
|
7
|
+
mark: '*'
|
8
|
+
# You can uncomment the line below if you need to overwrite the whole required html.
|
9
|
+
# When using html, text and mark won't be used.
|
10
|
+
# html: '<abbr title="required">*</abbr>'
|
11
|
+
error_notification:
|
12
|
+
default_message: "Пожалуйста, исправьте эти ошибки:"
|
13
|
+
# Labels and hints examples
|
14
|
+
# labels:
|
15
|
+
# defaults:
|
16
|
+
# password: 'Password'
|
17
|
+
# user:
|
18
|
+
# new:
|
19
|
+
# email: 'E-mail to sign in.'
|
20
|
+
# edit:
|
21
|
+
# email: 'E-mail.'
|
22
|
+
# hints:
|
23
|
+
# defaults:
|
24
|
+
# username: 'User name to sign in.'
|
25
|
+
# password: 'No special characters, please.'
|
data/lib/alchemy/engine.rb
CHANGED
@@ -83,6 +83,17 @@ module Alchemy
|
|
83
83
|
NonStupidDigestAssets.whitelist += [/^tinymce\//]
|
84
84
|
end
|
85
85
|
|
86
|
+
# We need to require each essence class in development mode,
|
87
|
+
# so it can register itself as essence relation on Page and Element models
|
88
|
+
# @see lib/alchemy/essence.rb:71
|
89
|
+
initializer 'alchemy.load_essence_classes' do |app|
|
90
|
+
unless Rails.application.config.cache_classes
|
91
|
+
Dir.glob(File.join(File.dirname(__FILE__), '../../app/models/alchemy/essence_*.rb')).each do |essence|
|
92
|
+
require essence
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
86
97
|
config.after_initialize do
|
87
98
|
require_relative './userstamp'
|
88
99
|
# In order to have Alchemy's helpers and basic controller methods
|
data/lib/alchemy/essence.rb
CHANGED
@@ -24,6 +24,8 @@ module Alchemy #:nodoc:
|
|
24
24
|
# Specify the column for the preview_text method.
|
25
25
|
#
|
26
26
|
def acts_as_essence(options={})
|
27
|
+
register_as_essence_association!
|
28
|
+
|
27
29
|
configuration = {
|
28
30
|
ingredient_column: 'body'
|
29
31
|
}.update(options)
|
@@ -41,7 +43,9 @@ module Alchemy #:nodoc:
|
|
41
43
|
scope :available, -> { joins(:element).merge(Element.available) }
|
42
44
|
scope :from_element, ->(name) { joins(:element).where(alchemy_elements: { name: name }) }
|
43
45
|
|
44
|
-
delegate :
|
46
|
+
delegate :restricted?, to: :page, allow_nil: true
|
47
|
+
delegate :trashed?, to: :element, allow_nil: true
|
48
|
+
delegate :public?, to: :element, allow_nil: true
|
45
49
|
|
46
50
|
after_update :touch_content
|
47
51
|
|
@@ -63,6 +67,13 @@ module Alchemy #:nodoc:
|
|
63
67
|
EOV
|
64
68
|
end
|
65
69
|
|
70
|
+
# Register the current class as has_many association on +Alchemy::Page+ and +Alchemy::Element+ models
|
71
|
+
def register_as_essence_association!
|
72
|
+
klass_name = self.model_name.to_s
|
73
|
+
arguments = [:has_many, klass_name.demodulize.tableize.to_sym, through: :contents,
|
74
|
+
source: :essence, source_type: klass_name]
|
75
|
+
%w(Page Element).each { |k| "Alchemy::#{k}".constantize.send(*arguments) }
|
76
|
+
end
|
66
77
|
end
|
67
78
|
|
68
79
|
module InstanceMethods
|
@@ -95,6 +95,8 @@ module Alchemy
|
|
95
95
|
type: 'date',
|
96
96
|
value: l(resource_instance_variable.send(attribute[:name]) || Time.now, format: :datepicker)
|
97
97
|
}
|
98
|
+
when 'time'
|
99
|
+
options.merge(as: 'time')
|
98
100
|
when 'text'
|
99
101
|
options.merge(as: 'text', input_html: {rows: 4})
|
100
102
|
else
|
@@ -104,7 +106,7 @@ module Alchemy
|
|
104
106
|
|
105
107
|
# Renders the human model name with a count as h1 header
|
106
108
|
def resources_header
|
107
|
-
content_tag :h1, "#{resources_instance_variable.total_count} #{resource_model.model_name.human(:
|
109
|
+
content_tag :h1, "#{resources_instance_variable.total_count} #{resource_model.model_name.human(count: resources_instance_variable.total_count)}", class: 'resources-header'
|
108
110
|
end
|
109
111
|
|
110
112
|
# Returns true if the resource contains any relations
|
@@ -153,4 +153,41 @@ shared_examples_for "an essence" do
|
|
153
153
|
end
|
154
154
|
end
|
155
155
|
end
|
156
|
+
|
157
|
+
context 'delegations' do
|
158
|
+
let(:page) { create(:restricted_page) }
|
159
|
+
let(:element) { create(:element, name: 'headline', create_contents_after_create: true, page: page) }
|
160
|
+
let(:content) { element.contents.find_by(essence_type: 'Alchemy::EssenceText') }
|
161
|
+
let(:essence) { content.essence }
|
162
|
+
|
163
|
+
it "delegates restricted? to page" do
|
164
|
+
expect(page.restricted?).to be(true)
|
165
|
+
expect(essence.restricted?).to be(true)
|
166
|
+
end
|
167
|
+
|
168
|
+
it "delegates trashed? to element" do
|
169
|
+
element.update!(position: nil)
|
170
|
+
expect(element.trashed?).to be true
|
171
|
+
expect(essence.trashed?).to be true
|
172
|
+
end
|
173
|
+
|
174
|
+
it "delegates public? to element" do
|
175
|
+
element.update!(public: false)
|
176
|
+
expect(element.public?).to be false
|
177
|
+
expect(essence.public?).to be false
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
describe 'essence relations' do
|
182
|
+
let(:page) { create(:restricted_page) }
|
183
|
+
let(:element) { create(:element) }
|
184
|
+
|
185
|
+
it "registers itself on page as essence relation" do
|
186
|
+
expect(page.respond_to?(essence.class.model_name.route_key)).to be(true)
|
187
|
+
end
|
188
|
+
|
189
|
+
it "registers itself on element as essence relation" do
|
190
|
+
expect(element.respond_to?(essence.class.model_name.route_key)).to be(true)
|
191
|
+
end
|
192
|
+
end
|
156
193
|
end
|
@@ -134,6 +134,8 @@ FactoryGirl.define do
|
|
134
134
|
hidden_name 'not shown'
|
135
135
|
starts_at DateTime.new(2012, 03, 02, 8, 15)
|
136
136
|
ends_at DateTime.new(2012, 03, 02, 19, 30)
|
137
|
+
lunch_starts_at DateTime.new(2012, 03, 02, 12, 15)
|
138
|
+
lunch_ends_at DateTime.new(2012, 03, 02, 13, 45)
|
137
139
|
description "something\nfancy"
|
138
140
|
published false
|
139
141
|
entrance_fee 12.3
|
data/lib/alchemy/version.rb
CHANGED
@@ -5,11 +5,13 @@ Alchemy::Modules.register_module({
|
|
5
5
|
name: 'modules.<%= @module_name %>',
|
6
6
|
controller: '/admin/<%= @module_name %>',
|
7
7
|
action: 'index',
|
8
|
-
image: '
|
8
|
+
image: 'alchemy/<%= @module_name %>_module.png',
|
9
9
|
sub_navigation: [{
|
10
10
|
name: 'modules.<%= @module_name %>',
|
11
11
|
controller: '/admin/<%= @module_name %>',
|
12
12
|
action: 'index'
|
13
13
|
}]
|
14
14
|
}
|
15
|
-
})
|
15
|
+
})
|
16
|
+
|
17
|
+
Alchemy.register_ability(<%= @class_name %>Ability)
|
@@ -0,0 +1,31 @@
|
|
1
|
+
es:
|
2
|
+
alchemy:
|
3
|
+
|
4
|
+
# Translations for page layout names
|
5
|
+
page_layout_names:
|
6
|
+
index: Inicio
|
7
|
+
|
8
|
+
# Translations for element names
|
9
|
+
element_names:
|
10
|
+
article: Artículo
|
11
|
+
|
12
|
+
# Translations for content names
|
13
|
+
content_names:
|
14
|
+
headline: Titular
|
15
|
+
text: Texto
|
16
|
+
picture: Imagen
|
17
|
+
|
18
|
+
# Default texts for new contents created
|
19
|
+
default_content_texts:
|
20
|
+
article_headline: "Bienvenido a tu primera página de Alchemy CMS"
|
21
|
+
article_text: '<p><strong>Como empezar.</strong></p><p>Lo primero de todo deberías leer sobre Alchemy y su arquitectura en las <a class="external" href="http://guides.alchemy-cms.com/edge/alchemy_approach.html" target="_blank" data-link-target="blank">guías</a>.</p><p>Las cosas más importantes que debes saber sobre Alchemy son elementos (<i>elements</i>) y disposiciones de página (<i>page layouts</i>).</p><p><span style="text-decoration: underline;"><strong>Elementos:</strong></span></p><p>Con Alchemy puedes dividir las páginas en partes de contenido, elementos. Estos elementos se pueden definir mediante varios tipos de contenido básicos: esencias (<i>essences</i>). Las esencias básicas son:</p><ul><li>EssenceText - <em>Un única línea de texto</em></li><li>EssenceRichtext - <em>Un bloque de texto formateado mediante TinyMCE</em></li><li>EssencePicture - <em>Una referencia a una imagen</em></li><li>EssenceHtml - <em>Código HTML empotrado</em></li><li>EssenceSelect - <em>Una selección de valores</em></li><li>EssenceBoolean - <em>Una casilla de verificación</em></li></ul><p>Los elementos se definen en el fichero YAML <strong>config/alchemy/elements.yml</strong></p><p><a class="external" href="http://guides.alchemy-cms.com/edge/elements.html" target="_blank" data-link-target="blank">Lee más sobre elementos y cómo definirlos en las guías.</a></p><p><span style="text-decoration: underline;"><strong>Tipos de página:</strong></span></p><p>Puedes definir varios tipos de páginas, llamados disposiciones de páginas (<i>page layouts</i>). Puedes asignar elementos a las disposiciones de páginas y controlar cómo se comportan los elementos y una página con una disposición concreta.</p><p>Las disposiciones de páginas se definen en el fichero YAML <strong>config/alchemy/page_layouts.yml</strong></p><p><a class="external" href="http://guides.alchemy-cms.com/edge/page_layouts.html" target="_blank" data-link-target="blank">Lee más sobre definir disposiciones de páginas en las guías.</a></p>'
|
22
|
+
|
23
|
+
# Hint texts for elements
|
24
|
+
element_hints:
|
25
|
+
article: "Este es el texto de ayuda del elemento artículo. Puedes cambiar este texto en `config/locales/alchemy.en.yml`. Siéntete libre de cambiarlo a tu gusto, es tuyo."
|
26
|
+
|
27
|
+
# Hint texts for contents
|
28
|
+
content_hints:
|
29
|
+
headline: "Esta es una sencilla linea de texto sin formato"
|
30
|
+
picture: "Las imágenes se almacenan en la librería. Puedes asignar una imagen varias veces en tu sitio. Alchemy tiene una herramienta de recorte de imagen integrada."
|
31
|
+
text: "Este es un bloque de texto enriquecido mediante el editor TinyMCE. Puedes cambiar la configuración del editor. Ver http://guides.alchemy-cms.com/edge/customize_tinymce.html"
|
@@ -32,6 +32,7 @@ module Alchemy
|
|
32
32
|
template "page_layouts.yml.tt", "#{Rails.root}/config/alchemy/page_layouts.yml"
|
33
33
|
copy_file "#{current_path}/files/alchemy.en.yml", "#{Rails.root}/config/locales/alchemy.en.yml"
|
34
34
|
copy_file "#{current_path}/files/alchemy.de.yml", "#{Rails.root}/config/locales/alchemy.de.yml"
|
35
|
+
copy_file "#{current_path}/files/alchemy.es.yml", "#{Rails.root}/config/locales/alchemy.es.yml"
|
35
36
|
copy_file "#{current_path}/files/application.html.erb", "#{Rails.root}/app/views/layouts/application.html.erb"
|
36
37
|
copy_file "#{current_path}/files/_standard.html.erb", "#{Rails.root}/app/views/alchemy/page_layouts/_standard.html.erb"
|
37
38
|
copy_file "#{current_path}/files/_article_view.html.erb", "#{Rails.root}/app/views/alchemy/elements/_article_view.html.erb"
|
@@ -4,3 +4,5 @@ require File.expand_path('../../../alchemy/version', __FILE__)
|
|
4
4
|
gem 'alchemy_cms', github: 'magiclabs/alchemy_cms', branch: 'master'
|
5
5
|
gem 'alchemy-devise', github: 'magiclabs/alchemy-devise', branch: 'master'
|
6
6
|
gem 'capistrano', '~> 2.15.5', group: 'development'
|
7
|
+
|
8
|
+
run 'bundle install'
|
@@ -28,19 +28,23 @@ namespace :alchemy do
|
|
28
28
|
|
29
29
|
desc "Installs Alchemy CMS into your app."
|
30
30
|
task :install do
|
31
|
-
|
32
|
-
|
31
|
+
unless ENV['from_binary']
|
32
|
+
puts "\nAlchemy Installer"
|
33
|
+
puts "-----------------"
|
34
|
+
end
|
33
35
|
Rake::Task["alchemy:mount"].invoke
|
34
|
-
system(
|
36
|
+
system("rails g alchemy:scaffold#{ ENV['from_binary'] ? ' --force' : '' }") || exit!(1)
|
35
37
|
Alchemy::InstallTask.new.set_primary_language
|
36
38
|
Rake::Task["db:create"].invoke
|
37
39
|
Rake::Task["alchemy:install:migrations"].invoke
|
38
40
|
Rake::Task["db:migrate"].invoke
|
39
41
|
Rake::Task["alchemy:db:seed"].invoke
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
42
|
+
unless ENV['from_binary']
|
43
|
+
puts "\nAlchemy successfully installed."
|
44
|
+
puts "\nNow start the server with:"
|
45
|
+
puts "\n$ bin/rails server"
|
46
|
+
puts "\nand point your browser to http://localhost:3000/admin and follow the onscreen instructions to finalize the installation."
|
47
|
+
end
|
44
48
|
end
|
45
49
|
|
46
50
|
desc "Mounts Alchemy into your routes."
|
@@ -40,6 +40,27 @@ module Alchemy
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
43
|
+
|
44
|
+
describe 'only and expect options' do
|
45
|
+
let!(:png) { create(:attachment) }
|
46
|
+
let!(:jpg) { create(:attachment, file: File.new(File.expand_path('../../../../spec/fixtures/image3.jpeg', __FILE__))) }
|
47
|
+
|
48
|
+
context 'with params[:only]' do
|
49
|
+
it 'only loads attachments with matching content type' do
|
50
|
+
get :index, only: 'jpeg'
|
51
|
+
expect(assigns(:attachments).to_a).to eq([jpg])
|
52
|
+
expect(assigns(:attachments).to_a).to_not eq([png])
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
context 'with params[:except]' do
|
57
|
+
it 'does not load attachments with matching content type' do
|
58
|
+
get :index, except: 'jpeg'
|
59
|
+
expect(assigns(:attachments).to_a).to eq([png])
|
60
|
+
expect(assigns(:attachments).to_a).to_not eq([jpg])
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
43
64
|
end
|
44
65
|
|
45
66
|
describe '#show' do
|
@@ -6,23 +6,25 @@ module Alchemy
|
|
6
6
|
sign_in(admin_user)
|
7
7
|
end
|
8
8
|
|
9
|
-
let(:
|
10
|
-
let(:
|
9
|
+
let(:essence_file) { mock_model('EssenceFile', :attachment= => nil, content: content) }
|
10
|
+
let(:content) { mock_model('Content') }
|
11
11
|
let(:attachment) { mock_model('Attachment') }
|
12
12
|
|
13
13
|
describe '#edit' do
|
14
14
|
before do
|
15
|
-
expect(
|
15
|
+
expect(EssenceFile).to receive(:find)
|
16
|
+
.with(essence_file.id.to_s)
|
17
|
+
.and_return(essence_file)
|
16
18
|
end
|
17
19
|
|
18
|
-
it "
|
19
|
-
get :edit,
|
20
|
-
expect(assigns(:
|
20
|
+
it "assigns @essence_file with the EssenceFile found by id" do
|
21
|
+
get :edit, id: essence_file.id
|
22
|
+
expect(assigns(:essence_file)).to eq(essence_file)
|
21
23
|
end
|
22
24
|
|
23
|
-
it "should assign @
|
24
|
-
get :edit,
|
25
|
-
expect(assigns(:
|
25
|
+
it "should assign @content with essence_file's content" do
|
26
|
+
get :edit, id: essence_file.id
|
27
|
+
expect(assigns(:content)).to eq(content)
|
26
28
|
end
|
27
29
|
end
|
28
30
|
|
@@ -32,7 +34,7 @@ module Alchemy
|
|
32
34
|
end
|
33
35
|
|
34
36
|
it "should update the attributes of essence_file" do
|
35
|
-
expect(essence_file).to receive(:
|
37
|
+
expect(essence_file).to receive(:update).and_return(true)
|
36
38
|
xhr :put, :update, id: essence_file.id
|
37
39
|
end
|
38
40
|
end
|
@@ -41,6 +43,7 @@ module Alchemy
|
|
41
43
|
before do
|
42
44
|
expect(Content).to receive(:find_by).and_return(content)
|
43
45
|
expect(Attachment).to receive(:find_by).and_return(attachment)
|
46
|
+
allow(content).to receive(:essence).and_return(essence_file)
|
44
47
|
end
|
45
48
|
|
46
49
|
it "should assign @attachment with the Attachment found by attachment_id" do
|
@@ -52,8 +55,6 @@ module Alchemy
|
|
52
55
|
expect(content.essence).to receive(:attachment=).with(attachment)
|
53
56
|
xhr :put, :assign, content_id: content.id, attachment_id: attachment.id
|
54
57
|
end
|
55
|
-
|
56
58
|
end
|
57
|
-
|
58
59
|
end
|
59
60
|
end
|
@@ -30,9 +30,9 @@ module Alchemy
|
|
30
30
|
|
31
31
|
describe '#show' do
|
32
32
|
context 'with no other params given' do
|
33
|
-
let(:page) {
|
34
|
-
let(:element) {
|
35
|
-
let(:content) {
|
33
|
+
let(:page) { create(:page) }
|
34
|
+
let(:element) { create(:element, page: page) }
|
35
|
+
let(:content) { create(:content, element: element) }
|
36
36
|
|
37
37
|
before do
|
38
38
|
expect(Content).to receive(:find).and_return(content)
|
@@ -45,7 +45,7 @@ module Alchemy
|
|
45
45
|
end
|
46
46
|
|
47
47
|
context 'requesting an restricted content' do
|
48
|
-
let(:page) {
|
48
|
+
let(:page) { create(:page, restricted: true) }
|
49
49
|
|
50
50
|
it "responds with 403" do
|
51
51
|
get :show, id: content.id, format: :json
|
@@ -8,6 +8,24 @@ module Alchemy
|
|
8
8
|
expect { get :download, id: 0 }.to raise_error(ActiveRecord::RecordNotFound)
|
9
9
|
end
|
10
10
|
|
11
|
+
context 'with public attachment' do
|
12
|
+
before do
|
13
|
+
allow(Attachment).to receive(:find).and_return(attachment)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "sends download as attachment." do
|
17
|
+
get :download, :id => attachment.id
|
18
|
+
expect(response.status).to eq(200)
|
19
|
+
expect(response.headers['Content-Disposition']).to match(/attachment/)
|
20
|
+
end
|
21
|
+
|
22
|
+
it "sends download inline." do
|
23
|
+
get :show, :id => attachment.id
|
24
|
+
expect(response.status).to eq(200)
|
25
|
+
expect(response.headers['Content-Disposition']).to match(/inline/)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
11
29
|
context 'with restricted attachment' do
|
12
30
|
before do
|
13
31
|
allow(attachment).to receive(:restricted?).and_return(true)
|
@@ -143,11 +143,20 @@ module Alchemy
|
|
143
143
|
let!(:legacy_url) { LegacyPageUrl.create(urlname: 'legacy-url', page: page) }
|
144
144
|
let(:legacy_url2) { LegacyPageUrl.create(urlname: 'legacy-url', page: second_page) }
|
145
145
|
let(:legacy_url3) { LegacyPageUrl.create(urlname: 'index.php?id=2', page: second_page) }
|
146
|
+
let(:legacy_url4) { LegacyPageUrl.create(urlname: 'index.php?option=com_content&view=article&id=48&Itemid=69', page: second_page) }
|
147
|
+
let(:legacy_url5) { LegacyPageUrl.create(urlname: 'nested/legacy/url', page: second_page) }
|
146
148
|
|
147
|
-
it "should redirect permanently to page that belongs to legacy page url
|
148
|
-
|
149
|
+
it "should redirect permanently to page that belongs to legacy page url even if url has an unknown format & get parameters" do
|
150
|
+
expect(request).to receive(:fullpath).at_least(:once).and_return(legacy_url4.urlname)
|
151
|
+
get :show, urlname: "index.php"
|
149
152
|
expect(response.status).to eq(301)
|
150
|
-
expect(response).to redirect_to("/#{
|
153
|
+
expect(response).to redirect_to("/#{second_page.urlname}")
|
154
|
+
end
|
155
|
+
|
156
|
+
it "should not pass query string for legacy routes" do
|
157
|
+
expect(request).to receive(:fullpath).at_least(:once).and_return(legacy_url3.urlname)
|
158
|
+
get :show, urlname: "index.php"
|
159
|
+
expect(URI.parse(response["Location"]).query).to be_nil
|
151
160
|
end
|
152
161
|
|
153
162
|
it "should only redirect to legacy url if no page was found for urlname" do
|
@@ -157,14 +166,22 @@ module Alchemy
|
|
157
166
|
end
|
158
167
|
|
159
168
|
it "should redirect to last page that has that legacy url" do
|
169
|
+
expect(request).to receive(:fullpath).at_least(:once).and_return(legacy_url2.urlname)
|
160
170
|
get :show, urlname: legacy_url2.urlname
|
161
171
|
expect(response).to redirect_to("/#{second_page.urlname}")
|
162
172
|
end
|
163
173
|
|
164
174
|
it "should redirect even if the url has get parameters" do
|
175
|
+
expect(request).to receive(:fullpath).at_least(:once).and_return(legacy_url3.urlname)
|
165
176
|
get :show, urlname: legacy_url3.urlname
|
166
177
|
expect(response).to redirect_to("/#{second_page.urlname}")
|
167
178
|
end
|
179
|
+
|
180
|
+
it "should redirect even if the url has nested urlname" do
|
181
|
+
expect(request).to receive(:fullpath).at_least(:once).and_return(legacy_url5.urlname)
|
182
|
+
get :show, urlname: legacy_url5.urlname
|
183
|
+
expect(response).to redirect_to("/#{second_page.urlname}")
|
184
|
+
end
|
168
185
|
end
|
169
186
|
end
|
170
187
|
|
@@ -6,6 +6,8 @@ class CreateEvents < ActiveRecord::Migration
|
|
6
6
|
t.string "hidden_name"
|
7
7
|
t.datetime "starts_at"
|
8
8
|
t.datetime "ends_at"
|
9
|
+
t.time "lunch_starts_at"
|
10
|
+
t.time "lunch_ends_at"
|
9
11
|
t.text "description"
|
10
12
|
t.decimal "entrance_fee", :precision => 6, :scale => 2
|
11
13
|
t.boolean "published"
|