locomotive_cms 2.4.1 → 2.5.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/README.textile +3 -3
- data/app/assets/images/locomotive/icons/flags/sk.png +0 -0
- data/app/assets/javascripts/aloha/plugins/custom/locomotive_media/lib/locomotive_media-plugin.js +1 -1
- data/app/assets/javascripts/locomotive/models/content_asset.js.coffee +7 -1
- data/app/assets/javascripts/locomotive/utils/aloha_settings.js.coffee +1 -1
- data/app/assets/javascripts/locomotive/utils/core_ext.js +1 -1
- data/app/assets/javascripts/locomotive/views/content_assets/picker_item_view.js.coffee +12 -0
- data/app/assets/javascripts/locomotive/views/content_assets/picker_view.js.coffee +149 -15
- data/app/assets/javascripts/locomotive/views/shared/asset_picker_view.js.coffee +16 -4
- data/app/assets/javascripts/locomotive/views/shared/form_view.js.coffee +1 -1
- data/app/assets/javascripts/locomotive/views/shared/list_item_view.js.coffee +1 -1
- data/app/assets/javascripts/tinymce/plugins/locomotive_media/editor_plugin.js +1 -1
- data/app/assets/stylesheets/locomotive/backoffice/_buttons.css.scss +56 -0
- data/app/assets/stylesheets/locomotive/backoffice/application.css.scss +6 -0
- data/app/assets/stylesheets/locomotive/backoffice/content_assets.css.scss +74 -4
- data/app/assets/stylesheets/locomotive/backoffice/dialog_changes.css.scss +4 -0
- data/app/assets/stylesheets/locomotive/shared/common.css.scss +7 -0
- data/app/controllers/locomotive/api/documentation_controller.rb +8 -2
- data/app/controllers/locomotive/api/pages_controller.rb +1 -1
- data/app/controllers/locomotive/content_assets_controller.rb +4 -0
- data/app/models/locomotive/content_asset.rb +5 -1
- data/app/models/locomotive/content_entry.rb +7 -2
- data/app/models/locomotive/content_type.rb +1 -1
- data/app/models/locomotive/editable_element.rb +1 -0
- data/app/models/locomotive/extensions/asset/types.rb +9 -4
- data/app/models/locomotive/extensions/asset/vignette.rb +2 -0
- data/app/models/locomotive/extensions/content_entry/csv.rb +2 -2
- data/app/models/locomotive/extensions/content_entry/localized.rb +18 -0
- data/app/models/locomotive/page.rb +2 -2
- data/app/models/locomotive/snippet.rb +8 -7
- data/app/models/locomotive/theme_asset.rb +12 -6
- data/app/models/locomotive/translation.rb +1 -1
- data/app/views/locomotive/content_assets/_picker.html.haml +23 -2
- data/app/views/locomotive/pages/_page.html.haml +2 -0
- data/app/views/locomotive/shared/_header.html.haml +3 -1
- data/app/views/locomotive/shared/_main_app_header.html.haml +1 -0
- data/app/views/locomotive/translations/index.html.haml +1 -1
- data/config/locales/admin_ui.bg.yml +1 -0
- data/config/locales/admin_ui.cs.yml +1 -0
- data/config/locales/admin_ui.de.yml +1 -0
- data/config/locales/admin_ui.en.yml +7 -0
- data/config/locales/admin_ui.es.yml +1 -0
- data/config/locales/admin_ui.et.yml +1 -0
- data/config/locales/admin_ui.fr.yml +12 -2
- data/config/locales/admin_ui.it.yml +1 -0
- data/config/locales/admin_ui.ja.yml +1 -0
- data/config/locales/admin_ui.nb.yml +1 -0
- data/config/locales/admin_ui.nl.yml +1 -0
- data/config/locales/admin_ui.pl.yml +1 -0
- data/config/locales/admin_ui.pt-BR.yml +1 -0
- data/config/locales/admin_ui.ru.yml +8 -4
- data/config/locales/admin_ui.sk.yml +360 -0
- data/config/locales/admin_ui.zh-CN.yml +1 -0
- data/config/locales/carrierwave.sk.yml +4 -0
- data/config/locales/default.fr.yml +3 -0
- data/config/locales/default.ru.yml +18 -7
- data/config/locales/default.sk.yml +249 -0
- data/config/locales/devise.sk.yml +64 -0
- data/config/locales/flash.sk.yml +115 -0
- data/config/locales/formtastic.fr.yml +7 -1
- data/config/locales/formtastic.sk.yml +125 -0
- data/config/routes.rb +2 -0
- data/lib/generators/locomotive/install/install_generator.rb +6 -0
- data/lib/generators/locomotive/install/templates/dragonfly.rb +16 -13
- data/lib/generators/locomotive/install/templates/locomotive.rb +7 -2
- data/lib/locomotive.rb +3 -15
- data/lib/locomotive/action_controller/responder.rb +8 -1
- data/lib/locomotive/carrierwave/asset.rb +0 -4
- data/lib/locomotive/configuration.rb +4 -3
- data/lib/locomotive/dragonfly.rb +20 -5
- data/lib/locomotive/liquid/drops/content_entry.rb +1 -1
- data/lib/locomotive/liquid/filters/base.rb +4 -0
- data/lib/locomotive/liquid/filters/translate.rb +4 -0
- data/lib/locomotive/liquid/tags/path_helper.rb +5 -2
- data/lib/locomotive/middlewares.rb +2 -1
- data/lib/locomotive/misc/api_documentation.rb +3 -1
- data/lib/locomotive/render.rb +7 -6
- data/lib/locomotive/version.rb +1 -1
- data/lib/tasks/development.rake +21 -0
- data/spec/dummy/config/initializers/dragonfly.rb +16 -13
- data/spec/dummy/config/initializers/locomotive.rb +9 -5
- data/spec/fixtures/assets/specs.pdf +0 -0
- data/spec/lib/locomotive/liquid/filters/html_spec.rb +22 -13
- data/spec/models/locomotive/content_asset_spec.rb +9 -0
- data/spec/models/locomotive/content_entry_spec.rb +57 -6
- data/spec/models/locomotive/extensions/content_entry/csv_spec.rb +30 -0
- data/spec/support/locomotive.rb +2 -1
- data/vendor/assets/javascripts/locomotive/ICanHandlebarz.js +1 -1
- data/vendor/assets/javascripts/locomotive/backbone.sync.js +14 -1
- metadata +34 -9
- data/lib/locomotive/middlewares/cache.rb +0 -27
@@ -29,7 +29,7 @@ module Locomotive
|
|
29
29
|
# @return [ Array ] The list of hashes (keys: name, getters, setters)
|
30
30
|
#
|
31
31
|
def self.embedded_resources
|
32
|
-
%w(editable_element
|
32
|
+
%w(editable_element editable_text editable_file editable_control content_field).map do |name|
|
33
33
|
klass = "Locomotive::#{name.camelize}Presenter".constantize
|
34
34
|
{
|
35
35
|
name: name,
|
@@ -59,6 +59,8 @@ module Locomotive
|
|
59
59
|
action = route.defaults[:action].to_sym
|
60
60
|
verb = route.verb.inspect.gsub("\/^", '').gsub("$\/", '')
|
61
61
|
|
62
|
+
next if name == 'documentation'
|
63
|
+
|
62
64
|
if resource.nil?
|
63
65
|
resource = controller.description
|
64
66
|
resource[:name] = name
|
data/lib/locomotive/render.rb
CHANGED
@@ -209,12 +209,13 @@ module Locomotive
|
|
209
209
|
#
|
210
210
|
def locomotive_default_registers
|
211
211
|
{
|
212
|
-
controller:
|
213
|
-
site:
|
214
|
-
page:
|
215
|
-
inline_editor:
|
216
|
-
logger:
|
217
|
-
current_locomotive_account: current_locomotive_account
|
212
|
+
controller: self,
|
213
|
+
site: current_site,
|
214
|
+
page: @page,
|
215
|
+
inline_editor: self.editing_page?,
|
216
|
+
logger: Rails.logger,
|
217
|
+
current_locomotive_account: current_locomotive_account,
|
218
|
+
theme_assets_checksum: Locomotive.config.theme_assets_checksum ? current_site.theme_assets.checksums : {}
|
218
219
|
}
|
219
220
|
end
|
220
221
|
|
data/lib/locomotive/version.rb
CHANGED
data/lib/tasks/development.rake
CHANGED
@@ -29,4 +29,25 @@ namespace :development do
|
|
29
29
|
puts "and a sample.example.com site as well. (add them to your /etc/hosts)"
|
30
30
|
puts "You can login with admin@locomotivecms.com and \"locomotive\" password."
|
31
31
|
end
|
32
|
+
|
33
|
+
desc "Change the main domain of all the sites"
|
34
|
+
task change_main_domain: :environment do
|
35
|
+
new_domain_name = ENV['DOMAIN_NAME']
|
36
|
+
|
37
|
+
if new_domain_name.blank?
|
38
|
+
puts "You need to set the DOMAIN_NAME ENV variable"
|
39
|
+
exit
|
40
|
+
end
|
41
|
+
|
42
|
+
puts "Changing to *.#{new_domain_name}"
|
43
|
+
|
44
|
+
Locomotive::Site.all.each do |site|
|
45
|
+
puts "...#{site.name} (#{site.subdomain})"
|
46
|
+
site.domains.each do |domain|
|
47
|
+
domain << "#{site.subdomain}.#{new_domain_name}"
|
48
|
+
end
|
49
|
+
site.save!
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
32
53
|
end
|
@@ -1,21 +1,24 @@
|
|
1
1
|
require 'dragonfly'
|
2
2
|
|
3
|
-
|
3
|
+
# Configure
|
4
|
+
Dragonfly.app.configure do
|
5
|
+
plugin :imagemagick,
|
6
|
+
convert_command: `which convert`.strip.presence || '/usr/local/bin/convert',
|
7
|
+
identify_command: `which identify`.strip.presence || '/usr/local/bin/identify'
|
4
8
|
|
5
|
-
|
6
|
-
app.configure_with(:rails)
|
7
|
-
app.configure_with(:imagemagick)
|
9
|
+
protect_from_dos_attacks true
|
8
10
|
|
9
|
-
|
11
|
+
secret 'a7d8613dc92256d0c0a3665a05d8af1b5efa5f66394ffca74da74eb41cc590e4'
|
10
12
|
|
11
|
-
|
12
|
-
# Convert absolute location needs to be specified
|
13
|
-
# to avoid issues with Phusion Passenger not using $PATH
|
14
|
-
c.convert_command = `which convert`.strip.presence || "/usr/local/bin/convert"
|
15
|
-
c.identify_command = `which identify`.strip.presence || "/usr/local/bin/identify"
|
13
|
+
url_format '/images/dynamic/:job/:basename.:ext'
|
16
14
|
|
17
|
-
|
18
|
-
c.allow_fetch_file = true
|
15
|
+
fetch_file_whitelist /public/
|
19
16
|
|
20
|
-
|
17
|
+
fetch_url_whitelist /.+/
|
21
18
|
end
|
19
|
+
|
20
|
+
# Logger
|
21
|
+
Dragonfly.logger = Rails.logger
|
22
|
+
|
23
|
+
# Mount as middleware
|
24
|
+
Rails.application.middleware.use Dragonfly::Middleware
|
@@ -8,9 +8,8 @@ Locomotive.configure do |config|
|
|
8
8
|
config.multi_sites do |multi_sites|
|
9
9
|
# each new website you add will have a default entry based on a subdomain
|
10
10
|
# and the multi_site_domain value (ex: website_1.locomotivehosting.com).
|
11
|
-
# multi_sites.domain = '
|
12
|
-
multi_sites.domain = '
|
13
|
-
# multi_sites.domain = 'locomotivehosting.fr'
|
11
|
+
# multi_sites.domain = 'example.com'
|
12
|
+
multi_sites.domain = 'lvh.me'
|
14
13
|
|
15
14
|
# define the reserved subdomains
|
16
15
|
# Ex:
|
@@ -34,11 +33,11 @@ Locomotive.configure do |config|
|
|
34
33
|
per_page: 10
|
35
34
|
}
|
36
35
|
|
37
|
-
# default locale (for now, only en, de, fr, pl, pt-BR, it, nl, nb, ja, cs and
|
36
|
+
# default locale (for now, only en, de, fr, pl, pt-BR, it, nl, nb, ja, cs, bg and sk are supported)
|
38
37
|
config.default_locale = :en
|
39
38
|
|
40
39
|
# available locales suggested to "localize" a site. You will have to pick up at least one among that list.
|
41
|
-
# config.site_locales = %w{en de fr pl pt-BR it nl nb es ru ja cs bg}
|
40
|
+
# config.site_locales = %w{en de fr pl pt-BR it nl nb es ru ja cs bg sk}
|
42
41
|
|
43
42
|
# tell if logs are enabled. Useful for debug purpose.
|
44
43
|
config.enable_logs = true
|
@@ -71,6 +70,11 @@ Locomotive.configure do |config|
|
|
71
70
|
#
|
72
71
|
# config.csrf_protection = true
|
73
72
|
|
73
|
+
# Add the checksum of a theme asset at the end of its path to allow public caching.
|
74
|
+
# By default, it's disabled.
|
75
|
+
#
|
76
|
+
# config.theme_assets_checksum = true
|
77
|
+
|
74
78
|
# Rack-cache settings, mainly used for the inline resizing image module. Default options:
|
75
79
|
# config.rack_cache = {
|
76
80
|
# verbose: true,
|
Binary file
|
@@ -19,37 +19,43 @@ describe Locomotive::Liquid::Filters::Html do
|
|
19
19
|
).strip
|
20
20
|
end
|
21
21
|
|
22
|
-
it 'should return
|
22
|
+
it 'should return an url for a stylesheet file' do
|
23
23
|
result = "/sites/000000000000000000000042/theme/stylesheets/main.css"
|
24
24
|
stylesheet_url('main.css').should == result
|
25
25
|
stylesheet_url('main').should == result
|
26
26
|
stylesheet_url(nil).should == ''
|
27
27
|
end
|
28
28
|
|
29
|
-
it 'should
|
29
|
+
it 'should returns an url with the checksum' do
|
30
|
+
@context.registers.merge!(theme_assets_checksum: { 'stylesheets/main.css' => 42 })
|
31
|
+
result = "/sites/000000000000000000000042/theme/stylesheets/main.css?42"
|
32
|
+
stylesheet_url('main.css').should == result
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should return an url for a stylesheet file with folder' do
|
30
36
|
result = "/sites/000000000000000000000042/theme/stylesheets/trash/main.css"
|
31
37
|
stylesheet_url('trash/main.css').should == result
|
32
38
|
end
|
33
39
|
|
34
|
-
it 'should return
|
40
|
+
it 'should return an url for a stylesheet file without touching the url that starts with "/"' do
|
35
41
|
result = "/trash/main.css"
|
36
42
|
stylesheet_url('/trash/main.css').should == result
|
37
43
|
stylesheet_url('/trash/main').should == result
|
38
44
|
end
|
39
45
|
|
40
|
-
it 'should return
|
46
|
+
it 'should return an url for a stylesheet file without touching the url that starts with "http:"' do
|
41
47
|
result = "http://cdn.example.com/trash/main.css"
|
42
48
|
stylesheet_url('http://cdn.example.com/trash/main.css').should == result
|
43
49
|
stylesheet_url('http://cdn.example.com/trash/main').should == result
|
44
50
|
end
|
45
51
|
|
46
|
-
it 'should return
|
52
|
+
it 'should return an url for a stylesheet file without touching the url that starts with "https:"' do
|
47
53
|
result = "https://cdn.example.com/trash/main.css"
|
48
54
|
stylesheet_url('https://cdn.example.com/trash/main.css').should == result
|
49
55
|
stylesheet_url('https://cdn.example.com/trash/main').should == result
|
50
56
|
end
|
51
57
|
|
52
|
-
it 'should return
|
58
|
+
it 'should return an url for a stylesheet file with respect to URL-parameters' do
|
53
59
|
result = "/sites/000000000000000000000042/theme/stylesheets/main.css?v=42"
|
54
60
|
stylesheet_url('main.css?v=42').should == result
|
55
61
|
end
|
@@ -121,38 +127,38 @@ describe Locomotive::Liquid::Filters::Html do
|
|
121
127
|
stylesheet_tag('https://cdn.example.com/trash/main','print').should == result
|
122
128
|
end
|
123
129
|
|
124
|
-
it 'should return
|
130
|
+
it 'should return an url for a javascript file' do
|
125
131
|
result = "/sites/000000000000000000000042/theme/javascripts/main.js"
|
126
132
|
javascript_url('main.js').should == result
|
127
133
|
javascript_url('main').should == result
|
128
134
|
javascript_url(nil).should == ''
|
129
135
|
end
|
130
136
|
|
131
|
-
it 'should return
|
137
|
+
it 'should return an url for a javascript file with folder' do
|
132
138
|
result = "/sites/000000000000000000000042/theme/javascripts/trash/main.js"
|
133
139
|
javascript_url('trash/main.js').should == result
|
134
140
|
javascript_url('trash/main').should == result
|
135
141
|
end
|
136
142
|
|
137
|
-
it 'should return
|
143
|
+
it 'should return an url for a javascript file without touching the url that starts with "/"' do
|
138
144
|
result = "/trash/main.js"
|
139
145
|
javascript_url('/trash/main.js').should == result
|
140
146
|
javascript_url('/trash/main').should == result
|
141
147
|
end
|
142
148
|
|
143
|
-
it 'should return
|
149
|
+
it 'should return an url for a javascript file without touching the url that starts with "http:"' do
|
144
150
|
result = "http://cdn.example.com/trash/main.js"
|
145
151
|
javascript_url('http://cdn.example.com/trash/main.js').should == result
|
146
152
|
javascript_url('http://cdn.example.com/trash/main').should == result
|
147
153
|
end
|
148
154
|
|
149
|
-
it 'should return
|
155
|
+
it 'should return an url for a javascript file without touching the url that starts with "https:"' do
|
150
156
|
result = "https://cdn.example.com/trash/main.js"
|
151
157
|
javascript_url('https://cdn.example.com/trash/main.js').should == result
|
152
158
|
javascript_url('https://cdn.example.com/trash/main').should == result
|
153
159
|
end
|
154
160
|
|
155
|
-
it 'should return
|
161
|
+
it 'should return an url for a javascript file with respect to URL-parameters' do
|
156
162
|
result = "/sites/000000000000000000000042/theme/javascripts/main.js?v=42"
|
157
163
|
javascript_url('main.js?v=42').should == result
|
158
164
|
end
|
@@ -233,7 +239,10 @@ describe Locomotive::Liquid::Filters::Html do
|
|
233
239
|
klass = Class.new
|
234
240
|
klass.class_eval do
|
235
241
|
def registers
|
236
|
-
|
242
|
+
@registers ||= {
|
243
|
+
site: FactoryGirl.build(:site, id: fake_bson_id(42)),
|
244
|
+
theme_assets_checksum: {}
|
245
|
+
}
|
237
246
|
end
|
238
247
|
|
239
248
|
def fake_bson_id(id)
|
@@ -43,4 +43,13 @@ describe Locomotive::ContentAsset do
|
|
43
43
|
|
44
44
|
end
|
45
45
|
|
46
|
+
describe 'attaching a pdf' do
|
47
|
+
|
48
|
+
subject { FactoryGirl.build(:asset, source: FixturedAsset.open('specs.pdf')) }
|
49
|
+
|
50
|
+
its(:pdf?) { should be_true }
|
51
|
+
its(:vignette_url) { should =~ /^\/images\/dynamic\/.*\/specs.png/ }
|
52
|
+
|
53
|
+
end
|
54
|
+
|
46
55
|
end
|
@@ -11,6 +11,7 @@ describe Locomotive::ContentEntry do
|
|
11
11
|
@content_type.entries_custom_fields.build label: 'Description', type: 'text'
|
12
12
|
@content_type.entries_custom_fields.build label: 'Visible ?', type: 'boolean', name: 'visible'
|
13
13
|
@content_type.entries_custom_fields.build label: 'File', type: 'file'
|
14
|
+
@content_type.entries_custom_fields.build label: 'Published at', type: 'date'
|
14
15
|
@content_type.valid?
|
15
16
|
@content_type.send(:set_label_field)
|
16
17
|
end
|
@@ -132,7 +133,7 @@ describe Locomotive::ContentEntry do
|
|
132
133
|
|
133
134
|
subject { build_content_entry.to_values(host: 'example.com') }
|
134
135
|
|
135
|
-
its(:size) { should eq(
|
136
|
+
its(:size) { should eq(6) }
|
136
137
|
|
137
138
|
its(:first) { should eq('Locomotive') }
|
138
139
|
|
@@ -161,9 +162,9 @@ describe Locomotive::ContentEntry do
|
|
161
162
|
|
162
163
|
its(:size) { should eq(4) }
|
163
164
|
|
164
|
-
its(:first) { should eq("Title,Description,Visible ?,File,Created at") }
|
165
|
+
its(:first) { should eq("Title,Description,Visible ?,File,Published at,Created at") }
|
165
166
|
|
166
|
-
its(:last) { should match(/^Locomotive,Lorem ipsum....,false,http:\/\/example.com\/sites\/[0-9a-f]+\/content_entry[0-9a-f]+\/[0-9a-f]+\/files\/5k.png,\"July 05, 2013 00:00\"$/) }
|
167
|
+
its(:last) { should match(/^Locomotive,Lorem ipsum....,false,http:\/\/example.com\/sites\/[0-9a-f]+\/content_entry[0-9a-f]+\/[0-9a-f]+\/files\/5k.png,\"\",\"July 05, 2013 00:00\"$/) }
|
167
168
|
|
168
169
|
end
|
169
170
|
|
@@ -172,11 +173,10 @@ describe Locomotive::ContentEntry do
|
|
172
173
|
describe "#navigation" do
|
173
174
|
|
174
175
|
before(:each) do
|
175
|
-
@content_type.order_by
|
176
|
-
@content_type.save
|
176
|
+
@content_type.update_attribute :order_by, '_position'
|
177
177
|
|
178
178
|
%w(first second third).each_with_index do |item, index|
|
179
|
-
content = build_content_entry(title: item.to_s, _position: index, visible: true)
|
179
|
+
content = build_content_entry(title: item.to_s, _position: index, published_at: (index + 1).days.ago, visible: true)
|
180
180
|
content.save!
|
181
181
|
instance_variable_set "@#{item}", content
|
182
182
|
end
|
@@ -199,6 +199,57 @@ describe Locomotive::ContentEntry do
|
|
199
199
|
it 'should return nil when fetching next item on last in list' do
|
200
200
|
@third.next.should == nil
|
201
201
|
end
|
202
|
+
|
203
|
+
context "ordered by published at" do
|
204
|
+
|
205
|
+
before do
|
206
|
+
@content_type.update_attributes order_by: 'published_at', order_direction: 'asc'
|
207
|
+
|
208
|
+
@very_first = build_content_entry(title: 'very first', _position: 4, published_at: Time.now, visible: true)
|
209
|
+
@very_first.save!
|
210
|
+
end
|
211
|
+
|
212
|
+
it "should find previous item" do
|
213
|
+
@second.previous.title.should == 'third'
|
214
|
+
end
|
215
|
+
|
216
|
+
it "should find next item" do
|
217
|
+
@first.next.title.should == 'very first'
|
218
|
+
end
|
219
|
+
|
220
|
+
it 'should return nil when fetching previous item on first in list' do
|
221
|
+
@third.previous.should == nil
|
222
|
+
end
|
223
|
+
|
224
|
+
it 'should return nil when fetching next item on last in list' do
|
225
|
+
@very_first.next.should == nil
|
226
|
+
end
|
227
|
+
|
228
|
+
context 'with desc direction' do
|
229
|
+
|
230
|
+
before do
|
231
|
+
@content_type.update_attribute :order_direction, 'desc'
|
232
|
+
end
|
233
|
+
|
234
|
+
it "should find previous item" do
|
235
|
+
@second.previous.title.should == 'first'
|
236
|
+
end
|
237
|
+
|
238
|
+
it "should find next item" do
|
239
|
+
@first.next.title.should == 'second'
|
240
|
+
end
|
241
|
+
|
242
|
+
it 'should return nil when fetching previous item on first in list' do
|
243
|
+
@very_first.previous.should == nil
|
244
|
+
end
|
245
|
+
|
246
|
+
it 'should return nil when fetching next item on last in list' do
|
247
|
+
@third.next.should == nil
|
248
|
+
end
|
249
|
+
|
250
|
+
end
|
251
|
+
|
252
|
+
end
|
202
253
|
end
|
203
254
|
|
204
255
|
describe '#permalink' do
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Locomotive
|
4
|
+
module Extensions
|
5
|
+
module ContentEntry
|
6
|
+
describe Csv do
|
7
|
+
before(:each) do
|
8
|
+
Locomotive::Site.any_instance.stubs(:create_default_pages!).returns(true)
|
9
|
+
@content_type = FactoryGirl.build(:content_type)
|
10
|
+
@content_type.entries_custom_fields.build label: 'Title', type: 'string'
|
11
|
+
@content_type.entries_custom_fields.build label: 'Description', type: 'text'
|
12
|
+
@content_type.entries_custom_fields.build label: 'Visible ?', type: 'boolean', name: 'visible'
|
13
|
+
@content_type.valid?
|
14
|
+
@content_type.send(:set_label_field)
|
15
|
+
@content_type.save!
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should export nil fields as empty strings' do
|
19
|
+
@entry = @content_type.entries.create!({
|
20
|
+
title: 'Locomotive',
|
21
|
+
visible: true
|
22
|
+
})
|
23
|
+
|
24
|
+
values = @entry.to_values
|
25
|
+
expect(values).to eq(['Locomotive', '', true, I18n.l(@entry.created_at, format: :long)])
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/spec/support/locomotive.rb
CHANGED
@@ -12,7 +12,6 @@
|
|
12
12
|
# end
|
13
13
|
# end
|
14
14
|
|
15
|
-
|
16
15
|
def Locomotive.configure_for_test(force = false)
|
17
16
|
Locomotive.configure do |config|
|
18
17
|
config.multi_sites do |multi_sites|
|
@@ -24,6 +23,8 @@ def Locomotive.configure_for_test(force = false)
|
|
24
23
|
|
25
24
|
config.csrf_protection = true
|
26
25
|
|
26
|
+
config.theme_assets_checksum = true
|
27
|
+
|
27
28
|
config.enable_admin_ssl = false
|
28
29
|
|
29
30
|
if force
|
@@ -22,9 +22,22 @@
|
|
22
22
|
var params = _.extend({
|
23
23
|
type: type,
|
24
24
|
dataType: 'json',
|
25
|
-
beforeSend:
|
25
|
+
beforeSend: function(xhr, settings) {
|
26
26
|
var token = $('meta[name="csrf-token"]').prop('content');
|
27
27
|
if (token) xhr.setRequestHeader('X-CSRF-Token', token);
|
28
|
+
},
|
29
|
+
xhr: function() {
|
30
|
+
var xhr = new window.XMLHttpRequest();
|
31
|
+
|
32
|
+
xhr.upload.addEventListener('progress', function(evt){
|
33
|
+
if (evt.lengthComputable) {
|
34
|
+
if (options.progress) {
|
35
|
+
options.progress(event.loaded, event.total)
|
36
|
+
}
|
37
|
+
}
|
38
|
+
}, false);
|
39
|
+
|
40
|
+
return xhr;
|
28
41
|
}
|
29
42
|
}, options);
|
30
43
|
|