locomotivecms_steam 1.1.2 → 1.2.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -2
- data/Gemfile.lock +41 -52
- data/lib/locomotive/steam/adapters/filesystem/sanitizers/page.rb +30 -35
- data/lib/locomotive/steam/adapters/filesystem.rb +8 -0
- data/lib/locomotive/steam/adapters/mongodb/command.rb +8 -1
- data/lib/locomotive/steam/adapters/mongodb.rb +10 -1
- data/lib/locomotive/steam/entities/content_entry.rb +13 -6
- data/lib/locomotive/steam/entities/page.rb +4 -0
- data/lib/locomotive/steam/entities/site.rb +1 -0
- data/lib/locomotive/steam/errors.rb +3 -0
- data/lib/locomotive/steam/initializers/dragonfly.rb +3 -5
- data/lib/locomotive/steam/initializers/sprockets.rb +10 -0
- data/lib/locomotive/steam/liquid/drops/content_entry.rb +8 -0
- data/lib/locomotive/steam/liquid/drops/content_entry_collection.rb +1 -1
- data/lib/locomotive/steam/liquid/tags/action.rb +59 -0
- data/lib/locomotive/steam/middlewares/entry_submission.rb +1 -1
- data/lib/locomotive/steam/middlewares/helpers.rb +8 -0
- data/lib/locomotive/steam/middlewares/locale.rb +1 -5
- data/lib/locomotive/steam/middlewares/locale_redirection.rb +1 -7
- data/lib/locomotive/steam/middlewares/renderer.rb +6 -3
- data/lib/locomotive/steam/middlewares/site.rb +12 -5
- data/lib/locomotive/steam/middlewares/sitemap.rb +6 -2
- data/lib/locomotive/steam/middlewares/thread_safe.rb +0 -4
- data/lib/locomotive/steam/models/associations/many_to_many.rb +1 -1
- data/lib/locomotive/steam/models/entity.rb +5 -0
- data/lib/locomotive/steam/models/repository.rb +4 -0
- data/lib/locomotive/steam/repositories/content_entry_repository.rb +23 -4
- data/lib/locomotive/steam/repositories/content_type_field_repository.rb +4 -0
- data/lib/locomotive/steam/services/action_service.rb +92 -0
- data/lib/locomotive/steam/services/content_entry_service.rb +114 -0
- data/lib/locomotive/steam/services/email_service.rb +102 -0
- data/lib/locomotive/steam/services/entry_submission_service.rb +6 -58
- data/lib/locomotive/steam/services/liquid_parser_service.rb +6 -0
- data/lib/locomotive/steam/services/url_builder_service.rb +5 -2
- data/lib/locomotive/steam/services.rb +13 -1
- data/lib/locomotive/steam/version.rb +1 -1
- data/lib/locomotive/steam.rb +5 -3
- data/locomotivecms_steam.gemspec +2 -0
- data/spec/fixtures/default/data/messages.yml +0 -0
- data/spec/integration/services/content_entry_service_spec.rb +110 -0
- data/spec/unit/adapters/filesystem_adapter_spec.rb +10 -0
- data/spec/unit/adapters/mongodb_adapter_spec.rb +18 -0
- data/spec/unit/entities/content_entry_spec.rb +34 -0
- data/spec/unit/entities/editable_element_spec.rb +19 -0
- data/spec/unit/entities/page_spec.rb +29 -0
- data/spec/unit/liquid/drops/content_entry_collection_spec.rb +4 -0
- data/spec/unit/liquid/drops/content_entry_spec.rb +5 -2
- data/spec/unit/liquid/tags/action_spec.rb +23 -0
- data/spec/unit/liquid/tags/link_to_spec.rb +12 -4
- data/spec/unit/liquid/tags/locale_switcher_spec.rb +15 -7
- data/spec/unit/liquid/tags/nav_spec.rb +19 -11
- data/spec/unit/liquid/tags/path_to_spec.rb +12 -4
- data/spec/unit/middlewares/helpers_spec.rb +29 -0
- data/spec/unit/middlewares/locale_redirection_spec.rb +11 -29
- data/spec/unit/middlewares/site_spec.rb +66 -13
- data/spec/unit/middlewares/sitemap_spec.rb +44 -0
- data/spec/unit/models/i18n_field_spec.rb +23 -0
- data/spec/unit/repositories/content_entry_repository_spec.rb +39 -7
- data/spec/unit/repositories/content_type_field_repository_spec.rb +10 -0
- data/spec/unit/services/action_service_spec.rb +173 -0
- data/spec/unit/services/content_entry_service_spec.rb +63 -0
- data/spec/unit/services/email_service_spec.rb +198 -0
- data/spec/unit/services/entry_submission_service_spec.rb +28 -112
- data/spec/unit/services/url_builder_service_spec.rb +14 -5
- metadata +50 -6
- data/spec/unit/middlewares/locale_spec.rb +0 -52
@@ -0,0 +1,198 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Locomotive::Steam::EmailService do
|
4
|
+
|
5
|
+
let(:page) { nil }
|
6
|
+
let(:page_finder) { instance_double('PageFinder', by_handle: page) }
|
7
|
+
let(:liquid_parser) { Locomotive::Steam::LiquidParserService.new(nil, nil) }
|
8
|
+
let(:asset_host) { instance_double('AssetHost') }
|
9
|
+
let(:simulation) { false }
|
10
|
+
let(:service) { described_class.new(page_finder, liquid_parser, asset_host, simulation) }
|
11
|
+
|
12
|
+
# uncomment the line below for DEBUG purpose
|
13
|
+
before { allow(service.logger).to receive(:info).and_return(true) }
|
14
|
+
|
15
|
+
describe '#send' do
|
16
|
+
|
17
|
+
let(:smtp_options) { { address: 'smtp.example.com', user_name: 'user', password: 'password' } }
|
18
|
+
let(:options) { { to: 'john@doe.net', from: 'me@locomotivecms.com', subject: 'Hello world', body: 'Hello {{ to }}', smtp: smtp_options, html: false } }
|
19
|
+
let(:context) { ::Liquid::Context.new({ 'name' => 'John', 'to' => 'john@doe.net' }, {}, {}) }
|
20
|
+
|
21
|
+
subject { service.send_email(options, context) }
|
22
|
+
|
23
|
+
it 'sends the email over Pony' do
|
24
|
+
expect(Pony).to receive(:mail).with(
|
25
|
+
to: 'john@doe.net',
|
26
|
+
from: 'me@locomotivecms.com',
|
27
|
+
subject: 'Hello world',
|
28
|
+
body: 'Hello john@doe.net',
|
29
|
+
via: :smtp,
|
30
|
+
via_options: {
|
31
|
+
address: 'smtp.example.com',
|
32
|
+
user_name: 'user',
|
33
|
+
password: 'password'
|
34
|
+
}
|
35
|
+
)
|
36
|
+
subject
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'simulation mode' do
|
40
|
+
|
41
|
+
let(:simulation) { true }
|
42
|
+
|
43
|
+
it "doesn't call Pony.mail" do
|
44
|
+
expect(Pony).not_to receive(:mail)
|
45
|
+
subject
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
describe 'no body, no page handle' do
|
51
|
+
|
52
|
+
let(:options) { { to: 'john@doe.net', from: 'me@locomotivecms.com', subject: 'Hello world', smtp: smtp_options, html: false } }
|
53
|
+
|
54
|
+
it { expect { subject }.to raise_error('[EmailService] the body or page_handle options are missing.')}
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
describe 'use a page as the body of the email' do
|
59
|
+
|
60
|
+
let(:page) { instance_double('Page', liquid_source: '<html><body><h1>Hello {{ name }}</h1></body></html>') }
|
61
|
+
let(:options) { { to: 'john@doe.net', from: 'me@locomotivecms.com', subject: 'Hello world', page_handle: 'notification-email', smtp: smtp_options, html: true } }
|
62
|
+
|
63
|
+
it 'sends the email over Pony' do
|
64
|
+
expect(Pony).to receive(:mail).with(
|
65
|
+
to: 'john@doe.net',
|
66
|
+
from: 'me@locomotivecms.com',
|
67
|
+
subject: 'Hello world',
|
68
|
+
html_body: '<html><body><h1>Hello John</h1></body></html>',
|
69
|
+
via: :smtp,
|
70
|
+
via_options: {
|
71
|
+
address: 'smtp.example.com',
|
72
|
+
user_name: 'user',
|
73
|
+
password: 'password'
|
74
|
+
}
|
75
|
+
)
|
76
|
+
subject
|
77
|
+
end
|
78
|
+
|
79
|
+
context "the page doesn't exist" do
|
80
|
+
|
81
|
+
let(:page) { nil }
|
82
|
+
|
83
|
+
it { expect { subject }.to raise_error('[EmailService] No page found with the following handle: notification-email') }
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
describe 'with attachments' do
|
90
|
+
|
91
|
+
let(:options) { { to: 'john@doe.net', from: 'me@locomotivecms.com', subject: 'Hello world', body: 'Hello {{ to }}', smtp: smtp_options, attachments: attachments, html: false } }
|
92
|
+
|
93
|
+
context 'local attachment' do
|
94
|
+
|
95
|
+
let(:attachments) { { 'foo.txt' => '/local/foo.txt' } }
|
96
|
+
|
97
|
+
before do
|
98
|
+
expect(asset_host).to receive(:compute).with('/local/foo.txt', false).and_return('http://acme.org/local/foo.txt')
|
99
|
+
expect(Net::HTTP).to receive(:get).with(URI('http://acme.org/local/foo.txt')).and_return('Foo')
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'sends the email over Pony' do
|
103
|
+
expect(Pony).to receive(:mail).with(
|
104
|
+
to: 'john@doe.net',
|
105
|
+
from: 'me@locomotivecms.com',
|
106
|
+
subject: 'Hello world',
|
107
|
+
body: 'Hello john@doe.net',
|
108
|
+
attachments: { 'foo.txt' => 'Foo' },
|
109
|
+
via: :smtp,
|
110
|
+
via_options: {
|
111
|
+
address: 'smtp.example.com',
|
112
|
+
user_name: 'user',
|
113
|
+
password: 'password'
|
114
|
+
}
|
115
|
+
)
|
116
|
+
subject
|
117
|
+
end
|
118
|
+
|
119
|
+
end
|
120
|
+
|
121
|
+
context 'remote attachment' do
|
122
|
+
|
123
|
+
let(:attachments) { { 'bar.txt' => 'http://acme.org/bar.txt' } }
|
124
|
+
|
125
|
+
it 'sends the email over Pony' do
|
126
|
+
expect(Net::HTTP).to receive(:get).with(URI('http://acme.org/bar.txt')).and_return('Bar')
|
127
|
+
expect(Pony).to receive(:mail).with(
|
128
|
+
to: 'john@doe.net',
|
129
|
+
from: 'me@locomotivecms.com',
|
130
|
+
subject: 'Hello world',
|
131
|
+
body: 'Hello john@doe.net',
|
132
|
+
attachments: { 'bar.txt' => 'Bar' },
|
133
|
+
via: :smtp,
|
134
|
+
via_options: {
|
135
|
+
address: 'smtp.example.com',
|
136
|
+
user_name: 'user',
|
137
|
+
password: 'password'
|
138
|
+
}
|
139
|
+
)
|
140
|
+
subject
|
141
|
+
end
|
142
|
+
|
143
|
+
context 'attachment not found' do
|
144
|
+
|
145
|
+
it "doesn't send the email" do
|
146
|
+
expect(Net::HTTP).to receive(:get).with(URI('http://acme.org/bar.txt')).and_raise('URL not responding')
|
147
|
+
expect(Pony).to receive(:mail).with(
|
148
|
+
to: 'john@doe.net',
|
149
|
+
from: 'me@locomotivecms.com',
|
150
|
+
subject: 'Hello world',
|
151
|
+
body: 'Hello john@doe.net',
|
152
|
+
attachments: { 'bar.txt' => nil },
|
153
|
+
via: :smtp,
|
154
|
+
via_options: {
|
155
|
+
address: 'smtp.example.com',
|
156
|
+
user_name: 'user',
|
157
|
+
password: 'password'
|
158
|
+
}
|
159
|
+
)
|
160
|
+
subject
|
161
|
+
end
|
162
|
+
|
163
|
+
end
|
164
|
+
|
165
|
+
end
|
166
|
+
|
167
|
+
context 'inline string' do
|
168
|
+
|
169
|
+
let(:attachments) { { 'bar.txt' => 'Bar' } }
|
170
|
+
|
171
|
+
it 'sends the email over Pony' do
|
172
|
+
expect(Pony).to receive(:mail).with(
|
173
|
+
to: 'john@doe.net',
|
174
|
+
from: 'me@locomotivecms.com',
|
175
|
+
subject: 'Hello world',
|
176
|
+
body: 'Hello john@doe.net',
|
177
|
+
attachments: { 'bar.txt' => 'Bar' },
|
178
|
+
via: :smtp,
|
179
|
+
via_options: {
|
180
|
+
address: 'smtp.example.com',
|
181
|
+
user_name: 'user',
|
182
|
+
password: 'password'
|
183
|
+
}
|
184
|
+
)
|
185
|
+
subject
|
186
|
+
end
|
187
|
+
|
188
|
+
end
|
189
|
+
|
190
|
+
end
|
191
|
+
|
192
|
+
end
|
193
|
+
|
194
|
+
def default_options
|
195
|
+
|
196
|
+
end
|
197
|
+
|
198
|
+
end
|
@@ -2,148 +2,64 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Locomotive::Steam::EntrySubmissionService do
|
4
4
|
|
5
|
-
let(:
|
6
|
-
let(:
|
7
|
-
let(:type_repository) { instance_double('ContentTypeRepository') }
|
8
|
-
let(:entry_repository) { instance_double('Repository', site: site, locale: locale, content_type_repository: type_repository) }
|
9
|
-
let(:service) { described_class.new(type_repository, entry_repository, locale) }
|
10
|
-
|
11
|
-
before { allow(entry_repository).to receive(:with).and_return(entry_repository) }
|
5
|
+
let(:entry_service) { instance_double('ContentEntryService') }
|
6
|
+
let(:service) { described_class.new(entry_service) }
|
12
7
|
|
13
8
|
describe '#find' do
|
14
9
|
|
15
|
-
|
16
|
-
let(:slug) { 'hello-world' }
|
17
|
-
subject { service.find(type_slug, slug) }
|
18
|
-
|
19
|
-
context 'unknown content type' do
|
20
|
-
|
21
|
-
before { allow(type_repository).to receive(:by_slug).and_return(nil) }
|
22
|
-
it { is_expected.to eq nil }
|
23
|
-
|
24
|
-
end
|
25
|
-
|
26
|
-
context 'existing content type' do
|
27
|
-
|
28
|
-
let(:type) { instance_double('Articles') }
|
29
|
-
let(:entry) { instance_double('Entry', title: 'Hello world', content_type: type, attributes: { title: 'Hello world' }, localized_attributes: []) }
|
30
|
-
|
31
|
-
before do
|
32
|
-
allow(type_repository).to receive(:by_slug).and_return(type)
|
33
|
-
allow(entry_repository).to receive(:by_slug).with('hello-world').and_return(entry)
|
34
|
-
end
|
35
|
-
|
36
|
-
it { is_expected.to eq entry }
|
37
|
-
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
41
|
-
|
42
|
-
describe '#to_json' do
|
43
|
-
|
44
|
-
let(:entry) { nil }
|
45
|
-
subject { service.to_json(entry) }
|
46
|
-
|
47
|
-
it { is_expected.to eq nil }
|
48
|
-
|
49
|
-
context 'existing content entry' do
|
50
|
-
|
51
|
-
let(:field) { instance_double('TitleField', name: :title, type: :string) }
|
52
|
-
let(:fields) { [field] }
|
53
|
-
let(:type) { instance_double('Articles', slug: 'articles', label_field_name: :title, fields_by_name: { title: field }, persisted_field_names: [:title]) }
|
54
|
-
let(:entry) { Locomotive::Steam::ContentEntry.new(_slug: 'hello-world', title: 'Hello world', content_type: type) }
|
55
|
-
|
56
|
-
before { allow(type).to receive(:fields).and_return(instance_double('FieldRepository', all: fields)) }
|
57
|
-
|
58
|
-
it { is_expected.to match %r{{"_id":null,"_slug":"hello-world","_label":"Hello world","_visible":true,"_position":0,"content_type_slug":"articles","created_at":"[^\"]+","updated_at":"[^\"]+","title":"Hello world"}} }
|
10
|
+
subject { service.find('messages', '42') }
|
59
11
|
|
60
|
-
|
61
|
-
|
62
|
-
before { entry.errors.add(:title, "can't be blank") }
|
63
|
-
|
64
|
-
it { is_expected.to match %r{,\"errors\":\{\"title\":\[\"can't be blank\"\]\}} }
|
65
|
-
|
66
|
-
end
|
67
|
-
|
68
|
-
end
|
12
|
+
it { expect(entry_service).to receive(:find).with('messages', '42'); subject }
|
69
13
|
|
70
14
|
end
|
71
15
|
|
72
16
|
describe '#submit' do
|
73
17
|
|
74
|
-
let(:
|
75
|
-
let(:attributes) { { title: 'Hello world' } }
|
76
|
-
subject { service.submit(slug, attributes) }
|
18
|
+
let(:content_type) { instance_double('ContentType', public_submission_enabled: public_submission_enabled) }
|
77
19
|
|
78
|
-
|
20
|
+
before { allow(entry_service).to receive(:get_type).with('messages').and_return(content_type) }
|
79
21
|
|
80
|
-
|
22
|
+
subject { service.submit('messages', { name: 'John Doe', body: 'Lorem ipsum' }) }
|
81
23
|
|
82
|
-
|
83
|
-
|
84
|
-
before { allow(type_repository).to receive(:by_slug).with('articles').and_return nil }
|
24
|
+
context "the content type doesn't exist" do
|
85
25
|
|
26
|
+
let(:public_submission_enabled) { true }
|
27
|
+
let(:content_type) { nil }
|
86
28
|
it { is_expected.to eq nil }
|
87
29
|
|
88
30
|
end
|
89
31
|
|
90
|
-
context
|
91
|
-
|
92
|
-
let(:unique_fields) { {} }
|
93
|
-
let(:first_validation) { false }
|
94
|
-
let(:errors) { [:title] }
|
95
|
-
let(:enabled) { true }
|
96
|
-
let(:type) { instance_double('Comments', public_submission_enabled: enabled) }
|
97
|
-
let(:entry) { instance_double('Entry', title: 'Hello world', content_type: type, valid?: first_validation, errors: errors, attributes: { title: 'Hello world' }, localized_attributes: []) }
|
98
|
-
let(:slug) { 'comments' }
|
99
|
-
|
100
|
-
before do
|
101
|
-
allow(type_repository).to receive(:by_slug).and_return(type)
|
102
|
-
allow(type_repository).to receive(:look_for_unique_fields).and_return(unique_fields)
|
103
|
-
allow(entry_repository).to receive(:build).with(attributes).and_return(entry)
|
104
|
-
end
|
105
|
-
|
106
|
-
context 'public submission disabled' do
|
107
|
-
|
108
|
-
let(:enabled) { false }
|
109
|
-
it { is_expected.to eq nil }
|
32
|
+
context "the content type exists but it's not enabled for public submission" do
|
110
33
|
|
111
|
-
|
112
|
-
|
113
|
-
context 'valid' do
|
114
|
-
|
115
|
-
before { expect(entry_repository).to receive(:create) }
|
34
|
+
let(:public_submission_enabled) { false }
|
35
|
+
it { is_expected.to eq nil }
|
116
36
|
|
117
|
-
|
118
|
-
let(:errors) { {} }
|
37
|
+
end
|
119
38
|
|
120
|
-
|
121
|
-
it { expect(subject.errors.empty?).to eq true }
|
39
|
+
context 'the content type exists and is enabled for public submission' do
|
122
40
|
|
41
|
+
let(:public_submission_enabled) { true }
|
42
|
+
it 'calls the entry service to create the message' do
|
43
|
+
expect(entry_service).to receive(:create).with(content_type, { name: 'John Doe', body: 'Lorem ipsum' })
|
44
|
+
subject
|
123
45
|
end
|
124
46
|
|
125
|
-
|
126
|
-
|
127
|
-
before { expect(entry_repository).not_to receive(:create) }
|
47
|
+
end
|
128
48
|
|
129
|
-
|
130
|
-
it { expect(subject.errors).to eq([:title]) }
|
49
|
+
end
|
131
50
|
|
132
|
-
|
51
|
+
describe '#to_json' do
|
133
52
|
|
134
|
-
|
53
|
+
let(:entry) { instance_double('Entry', to_json: "{'name':'John'}") }
|
135
54
|
|
136
|
-
|
137
|
-
allow(entry_repository).to receive(:exists?).with(title: 'Hello world').and_return(true)
|
138
|
-
expect(entry.errors).to receive(:add).with(:title, :unique).and_return(true)
|
139
|
-
end
|
55
|
+
subject { service.to_json(entry) }
|
140
56
|
|
141
|
-
|
142
|
-
it { expect(subject.errors).to eq([:title]) }
|
57
|
+
it { is_expected.to eq("{'name':'John'}") }
|
143
58
|
|
144
|
-
|
59
|
+
context 'entry is nil' do
|
145
60
|
|
146
|
-
|
61
|
+
let(:entry) { nil }
|
62
|
+
it { is_expected.to eq nil }
|
147
63
|
|
148
64
|
end
|
149
65
|
|
@@ -2,11 +2,12 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Locomotive::Steam::UrlBuilderService do
|
4
4
|
|
5
|
-
let(:
|
6
|
-
let(:
|
7
|
-
let(:
|
8
|
-
let(:
|
9
|
-
let(:
|
5
|
+
let(:prefix_default) { false }
|
6
|
+
let(:mounted_on) { nil }
|
7
|
+
let(:request) { instance_double('Request', env: { 'steam.mounted_on' => mounted_on }) }
|
8
|
+
let(:site) { instance_double('Site', default_locale: 'en', prefix_default_locale: prefix_default) }
|
9
|
+
let(:locale) { 'en' }
|
10
|
+
let(:service) { described_class.new(site, locale, request) }
|
10
11
|
|
11
12
|
describe '#url_for' do
|
12
13
|
|
@@ -16,6 +17,14 @@ describe Locomotive::Steam::UrlBuilderService do
|
|
16
17
|
|
17
18
|
it { is_expected.to eq '/about-us' }
|
18
19
|
|
20
|
+
describe 'the prefix_default_locale site property is enabled' do
|
21
|
+
|
22
|
+
let(:prefix_default) { true }
|
23
|
+
|
24
|
+
it { is_expected.to eq '/en/about-us' }
|
25
|
+
|
26
|
+
end
|
27
|
+
|
19
28
|
describe 'a locale different from the default one' do
|
20
29
|
|
21
30
|
let(:locale) { 'fr' }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: locomotivecms_steam
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Didier Lafforgue
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2016-05-25 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: bundler
|
@@ -349,6 +349,34 @@ dependencies:
|
|
349
349
|
- - "~>"
|
350
350
|
- !ruby/object:Gem::Version
|
351
351
|
version: 2.6.1
|
352
|
+
- !ruby/object:Gem::Dependency
|
353
|
+
name: duktape
|
354
|
+
requirement: !ruby/object:Gem::Requirement
|
355
|
+
requirements:
|
356
|
+
- - "~>"
|
357
|
+
- !ruby/object:Gem::Version
|
358
|
+
version: 1.3.0.6
|
359
|
+
type: :runtime
|
360
|
+
prerelease: false
|
361
|
+
version_requirements: !ruby/object:Gem::Requirement
|
362
|
+
requirements:
|
363
|
+
- - "~>"
|
364
|
+
- !ruby/object:Gem::Version
|
365
|
+
version: 1.3.0.6
|
366
|
+
- !ruby/object:Gem::Dependency
|
367
|
+
name: pony
|
368
|
+
requirement: !ruby/object:Gem::Requirement
|
369
|
+
requirements:
|
370
|
+
- - "~>"
|
371
|
+
- !ruby/object:Gem::Version
|
372
|
+
version: '1.11'
|
373
|
+
type: :runtime
|
374
|
+
prerelease: false
|
375
|
+
version_requirements: !ruby/object:Gem::Requirement
|
376
|
+
requirements:
|
377
|
+
- - "~>"
|
378
|
+
- !ruby/object:Gem::Version
|
379
|
+
version: '1.11'
|
352
380
|
- !ruby/object:Gem::Dependency
|
353
381
|
name: locomotivecms-solid
|
354
382
|
requirement: !ruby/object:Gem::Requirement
|
@@ -479,6 +507,7 @@ files:
|
|
479
507
|
- lib/locomotive/steam/liquid/filters/text.rb
|
480
508
|
- lib/locomotive/steam/liquid/filters/translate.rb
|
481
509
|
- lib/locomotive/steam/liquid/patches.rb
|
510
|
+
- lib/locomotive/steam/liquid/tags/action.rb
|
482
511
|
- lib/locomotive/steam/liquid/tags/concerns/i18n_page.rb
|
483
512
|
- lib/locomotive/steam/liquid/tags/concerns/path.rb
|
484
513
|
- lib/locomotive/steam/liquid/tags/consume.rb
|
@@ -554,10 +583,13 @@ files:
|
|
554
583
|
- lib/locomotive/steam/repositories/translation_repository.rb
|
555
584
|
- lib/locomotive/steam/server.rb
|
556
585
|
- lib/locomotive/steam/services.rb
|
586
|
+
- lib/locomotive/steam/services/action_service.rb
|
557
587
|
- lib/locomotive/steam/services/asset_host_service.rb
|
558
588
|
- lib/locomotive/steam/services/concerns/decorator.rb
|
589
|
+
- lib/locomotive/steam/services/content_entry_service.rb
|
559
590
|
- lib/locomotive/steam/services/csrf_protection_service.rb
|
560
591
|
- lib/locomotive/steam/services/editable_element_service.rb
|
592
|
+
- lib/locomotive/steam/services/email_service.rb
|
561
593
|
- lib/locomotive/steam/services/entry_submission_service.rb
|
562
594
|
- lib/locomotive/steam/services/external_api_service.rb
|
563
595
|
- lib/locomotive/steam/services/image_resizer_service.rb
|
@@ -626,6 +658,7 @@ files:
|
|
626
658
|
- spec/fixtures/default/config/translations.yml
|
627
659
|
- spec/fixtures/default/data/bands.yml
|
628
660
|
- spec/fixtures/default/data/events.yml
|
661
|
+
- spec/fixtures/default/data/messages.yml
|
629
662
|
- spec/fixtures/default/data/songs.yml
|
630
663
|
- spec/fixtures/default/data/updates.yml
|
631
664
|
- spec/fixtures/default/public/fonts/chunkfive-webfont.eot
|
@@ -689,6 +722,7 @@ files:
|
|
689
722
|
- spec/integration/server/session_spec.rb
|
690
723
|
- spec/integration/server/sitemap_spec.rb
|
691
724
|
- spec/integration/server/with_scope_spec.rb
|
725
|
+
- spec/integration/services/content_entry_service_spec.rb
|
692
726
|
- spec/integration/services/external_api_service_spec.rb
|
693
727
|
- spec/locales/locales_spec.rb
|
694
728
|
- spec/spec_helper.rb
|
@@ -750,6 +784,7 @@ files:
|
|
750
784
|
- spec/unit/liquid/filters/text_spec.rb
|
751
785
|
- spec/unit/liquid/filters/translate_spec.rb
|
752
786
|
- spec/unit/liquid/patches_spec.rb
|
787
|
+
- spec/unit/liquid/tags/action_spec.rb
|
753
788
|
- spec/unit/liquid/tags/consume_spec.rb
|
754
789
|
- spec/unit/liquid/tags/csrf_spec.rb
|
755
790
|
- spec/unit/liquid/tags/editable/control_spec.rb
|
@@ -773,10 +808,10 @@ files:
|
|
773
808
|
- spec/unit/middlewares/dynamic_assets_spec.rb
|
774
809
|
- spec/unit/middlewares/helpers_spec.rb
|
775
810
|
- spec/unit/middlewares/locale_redirection_spec.rb
|
776
|
-
- spec/unit/middlewares/locale_spec.rb
|
777
811
|
- spec/unit/middlewares/private_access_spec.rb
|
778
812
|
- spec/unit/middlewares/renderer_spec.rb
|
779
813
|
- spec/unit/middlewares/site_spec.rb
|
814
|
+
- spec/unit/middlewares/sitemap_spec.rb
|
780
815
|
- spec/unit/middlewares/stack_proxy_spec.rb
|
781
816
|
- spec/unit/middlewares/url_redirection_spec.rb
|
782
817
|
- spec/unit/models/concerns/to_json_spec.rb
|
@@ -793,7 +828,10 @@ files:
|
|
793
828
|
- spec/unit/repositories/snippet_repository_spec.rb
|
794
829
|
- spec/unit/repositories/theme_asset_repository_spec.rb
|
795
830
|
- spec/unit/repositories/translation_repository_spec.rb
|
831
|
+
- spec/unit/services/action_service_spec.rb
|
796
832
|
- spec/unit/services/asset_host_service_spec.rb
|
833
|
+
- spec/unit/services/content_entry_service_spec.rb
|
834
|
+
- spec/unit/services/email_service_spec.rb
|
797
835
|
- spec/unit/services/entry_submission_service_spec.rb
|
798
836
|
- spec/unit/services/external_api_service_spec.rb
|
799
837
|
- spec/unit/services/image_resizer_service_spec.rb
|
@@ -818,9 +856,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
818
856
|
version: '2.0'
|
819
857
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
820
858
|
requirements:
|
821
|
-
- - "
|
859
|
+
- - ">"
|
822
860
|
- !ruby/object:Gem::Version
|
823
|
-
version:
|
861
|
+
version: 1.3.1
|
824
862
|
requirements: []
|
825
863
|
rubyforge_project:
|
826
864
|
rubygems_version: 2.4.5.1
|
@@ -879,6 +917,7 @@ test_files:
|
|
879
917
|
- spec/fixtures/default/config/translations.yml
|
880
918
|
- spec/fixtures/default/data/bands.yml
|
881
919
|
- spec/fixtures/default/data/events.yml
|
920
|
+
- spec/fixtures/default/data/messages.yml
|
882
921
|
- spec/fixtures/default/data/songs.yml
|
883
922
|
- spec/fixtures/default/data/updates.yml
|
884
923
|
- spec/fixtures/default/public/fonts/chunkfive-webfont.eot
|
@@ -942,6 +981,7 @@ test_files:
|
|
942
981
|
- spec/integration/server/session_spec.rb
|
943
982
|
- spec/integration/server/sitemap_spec.rb
|
944
983
|
- spec/integration/server/with_scope_spec.rb
|
984
|
+
- spec/integration/services/content_entry_service_spec.rb
|
945
985
|
- spec/integration/services/external_api_service_spec.rb
|
946
986
|
- spec/locales/locales_spec.rb
|
947
987
|
- spec/spec_helper.rb
|
@@ -1003,6 +1043,7 @@ test_files:
|
|
1003
1043
|
- spec/unit/liquid/filters/text_spec.rb
|
1004
1044
|
- spec/unit/liquid/filters/translate_spec.rb
|
1005
1045
|
- spec/unit/liquid/patches_spec.rb
|
1046
|
+
- spec/unit/liquid/tags/action_spec.rb
|
1006
1047
|
- spec/unit/liquid/tags/consume_spec.rb
|
1007
1048
|
- spec/unit/liquid/tags/csrf_spec.rb
|
1008
1049
|
- spec/unit/liquid/tags/editable/control_spec.rb
|
@@ -1026,10 +1067,10 @@ test_files:
|
|
1026
1067
|
- spec/unit/middlewares/dynamic_assets_spec.rb
|
1027
1068
|
- spec/unit/middlewares/helpers_spec.rb
|
1028
1069
|
- spec/unit/middlewares/locale_redirection_spec.rb
|
1029
|
-
- spec/unit/middlewares/locale_spec.rb
|
1030
1070
|
- spec/unit/middlewares/private_access_spec.rb
|
1031
1071
|
- spec/unit/middlewares/renderer_spec.rb
|
1032
1072
|
- spec/unit/middlewares/site_spec.rb
|
1073
|
+
- spec/unit/middlewares/sitemap_spec.rb
|
1033
1074
|
- spec/unit/middlewares/stack_proxy_spec.rb
|
1034
1075
|
- spec/unit/middlewares/url_redirection_spec.rb
|
1035
1076
|
- spec/unit/models/concerns/to_json_spec.rb
|
@@ -1046,7 +1087,10 @@ test_files:
|
|
1046
1087
|
- spec/unit/repositories/snippet_repository_spec.rb
|
1047
1088
|
- spec/unit/repositories/theme_asset_repository_spec.rb
|
1048
1089
|
- spec/unit/repositories/translation_repository_spec.rb
|
1090
|
+
- spec/unit/services/action_service_spec.rb
|
1049
1091
|
- spec/unit/services/asset_host_service_spec.rb
|
1092
|
+
- spec/unit/services/content_entry_service_spec.rb
|
1093
|
+
- spec/unit/services/email_service_spec.rb
|
1050
1094
|
- spec/unit/services/entry_submission_service_spec.rb
|
1051
1095
|
- spec/unit/services/external_api_service_spec.rb
|
1052
1096
|
- spec/unit/services/image_resizer_service_spec.rb
|
@@ -1,52 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
require_relative '../../../lib/locomotive/steam/middlewares/thread_safe'
|
4
|
-
require_relative '../../../lib/locomotive/steam/middlewares/helpers'
|
5
|
-
require_relative '../../../lib/locomotive/steam/middlewares/locale'
|
6
|
-
|
7
|
-
describe Locomotive::Steam::Middlewares::Locale do
|
8
|
-
|
9
|
-
let(:site) { instance_double('Site', default_locale: :de, locales: %w(de fr)) }
|
10
|
-
let(:url) { 'http://models.example.com' }
|
11
|
-
let(:app) { ->(env) { [200, env, 'app'] } }
|
12
|
-
let(:services) { instance_double('Services', :locale= => 'en') }
|
13
|
-
let(:middleware) { Locomotive::Steam::Middlewares::Locale.new(app) }
|
14
|
-
|
15
|
-
subject do
|
16
|
-
env = env_for(url, 'steam.site' => site)
|
17
|
-
env['steam.request'] = Rack::Request.new(env)
|
18
|
-
env['steam.services'] = services
|
19
|
-
code, env = middleware.call(env)
|
20
|
-
env['steam.locale']
|
21
|
-
end
|
22
|
-
|
23
|
-
describe 'locale asked in the request params' do
|
24
|
-
|
25
|
-
context 'the locale is blank' do
|
26
|
-
|
27
|
-
let(:url) { 'http://models.example.com?locale=' }
|
28
|
-
|
29
|
-
it { is_expected.to eq :de }
|
30
|
-
|
31
|
-
end
|
32
|
-
|
33
|
-
context 'the locale exists' do
|
34
|
-
|
35
|
-
let(:url) { 'http://models.example.com?locale=fr' }
|
36
|
-
|
37
|
-
it { is_expected.to eq 'fr' }
|
38
|
-
|
39
|
-
end
|
40
|
-
|
41
|
-
context 'the locale is unknown' do
|
42
|
-
|
43
|
-
let(:url) { 'http://models.example.com?locale=onload' }
|
44
|
-
|
45
|
-
it { is_expected.to eq :de }
|
46
|
-
|
47
|
-
end
|
48
|
-
|
49
|
-
|
50
|
-
end
|
51
|
-
|
52
|
-
end
|