sitepress-rails 2.0.0 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -19
- data/bin/rails +2 -2
- data/lib/sitepress/engine.rb +2 -0
- data/lib/sitepress/model.rb +68 -0
- data/lib/sitepress/models/collection.rb +34 -0
- data/lib/sitepress/rails.rb +14 -1
- data/lib/sitepress/rails_configuration.rb +1 -4
- data/lib/sitepress/route_constraint.rb +3 -1
- data/lib/sitepress/routing_mapper.rb +31 -0
- data/rails/app/controllers/concerns/sitepress/site_pages.rb +2 -1
- data/rails/lib/generators/sitepress/controller/USAGE +8 -0
- data/rails/lib/generators/sitepress/controller/controller_generator.rb +19 -0
- data/rails/lib/generators/sitepress/controller/templates/controllers/site_controller.rb +17 -0
- data/rails/lib/generators/sitepress/install/USAGE +10 -0
- data/rails/lib/generators/sitepress/install/install_generator.rb +14 -0
- data/rails/lib/generators/sitepress/install/templates/helpers/page_helper.rb +29 -0
- data/rails/lib/generators/sitepress/install/templates/models/page_model.rb +4 -0
- data/rails/lib/generators/sitepress/install/templates/pages/index.html.erb +43 -0
- data/rails/test/lib/generators/sitepress/controller_generator_test.rb +14 -0
- data/rails/test/lib/generators/sitepress/install_generator_test.rb +14 -0
- data/sitepress-rails.gemspec +3 -2
- data/spec/dummy/app/content/models/page_model.rb +4 -0
- data/spec/dummy/config/routes.rb +1 -0
- data/spec/dummy/log/test.log +175 -81066
- data/spec/sitepress/model_spec.rb +35 -0
- data/spec/sitepress/routes_spec.rb +7 -22
- data/spec/sitepress-rails_spec.rb +7 -22
- data/spec/spec_helper.rb +15 -0
- metadata +24 -12
- data/rails/config/routes.rb +0 -12
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/production.log +0 -1976
@@ -0,0 +1,35 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "tmpdir"
|
3
|
+
require "fileutils"
|
4
|
+
|
5
|
+
describe Sitepress::Model do
|
6
|
+
let(:model) { PageModel }
|
7
|
+
|
8
|
+
describe "#all" do
|
9
|
+
subject { model.all }
|
10
|
+
context "models" do
|
11
|
+
it "has correct count" do
|
12
|
+
expect(subject.count).to eql 3
|
13
|
+
end
|
14
|
+
it "is instances of model" do
|
15
|
+
expect(subject.first).to be_instance_of PageModel
|
16
|
+
end
|
17
|
+
end
|
18
|
+
describe "#resources" do
|
19
|
+
subject { model.all.resources }
|
20
|
+
it "has correct count" do
|
21
|
+
expect(subject.count).to eql 3
|
22
|
+
end
|
23
|
+
it "is instances of pages" do
|
24
|
+
expect(subject.first).to be_instance_of Sitepress::Resource
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe ".data" do
|
30
|
+
subject { model.first }
|
31
|
+
it "defines #title method" do
|
32
|
+
expect(subject).to respond_to :title
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -1,28 +1,13 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe "Sitepress routes", type: :routing do
|
4
|
-
|
5
|
-
|
6
|
-
Sitepress.configuration.routes = true
|
7
|
-
Rails.application.reload_routes!
|
8
|
-
end
|
9
|
-
it "generates link" do
|
10
|
-
expect(page_path("hi")).to eql("/hi")
|
11
|
-
end
|
12
|
-
it "is routable" do
|
13
|
-
expect(get("/hi")).to route_to(controller: "sitepress/site", action: "show", resource_path: "hi")
|
14
|
-
end
|
4
|
+
before do
|
5
|
+
Rails.application.reload_routes!
|
15
6
|
end
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
it "is not routable" do
|
22
|
-
expect(get("/hi")).to_not be_routable
|
23
|
-
end
|
24
|
-
it "does not generate link" do
|
25
|
-
expect{page_path("hi")}.to raise_exception(NoMethodError)
|
26
|
-
end
|
7
|
+
it "generates link" do
|
8
|
+
expect(page_path("hi")).to eql("/hi")
|
9
|
+
end
|
10
|
+
it "is routable" do
|
11
|
+
expect(get("/hi")).to route_to(controller: "sitepress/site", action: "show", resource_path: "hi")
|
27
12
|
end
|
28
13
|
end
|
@@ -2,31 +2,16 @@ require "spec_helper"
|
|
2
2
|
require "sitepress-rails"
|
3
3
|
|
4
4
|
describe "Sitepress.configuration" do
|
5
|
+
let(:app) { Rails.application }
|
5
6
|
subject { Sitepress.configuration }
|
6
|
-
|
7
|
-
before do
|
8
|
-
# Why set to true? Because according to Rails:
|
9
|
-
#
|
10
|
-
# .config.eager_load is set to nil. Please update your config/environments/*.rb files accordingly:
|
11
|
-
#
|
12
|
-
# * development - set it to false
|
13
|
-
# * test - set it to false (unless you use a tool that preloads your test environment)
|
14
|
-
# * production - set it to true
|
15
|
-
#
|
16
|
-
# The view initializer for haml runs in a `ActiveSupport.on_load(:action_view)`, which requires
|
17
|
-
# `eager_load = true` to test.
|
18
|
-
app.config.eager_load = true
|
19
|
-
end
|
7
|
+
|
20
8
|
it "has Rails.application as parent engine" do
|
21
|
-
app.initialize!
|
22
9
|
expect(subject.parent_engine).to eql(app)
|
23
10
|
end
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
app.initialize!
|
30
|
-
expect(Sitepress::Path.handler_extensions).to eql([:raw, :erb, :html, :builder, :ruby])
|
11
|
+
|
12
|
+
describe "Sitepress::Path.template_extensions" do
|
13
|
+
subject { Sitepress::Path.handler_extensions }
|
14
|
+
it { is_expected.to eql ActionView::Template::Handlers.extensions }
|
15
|
+
it { is_expected.to_not be_empty }
|
31
16
|
end
|
32
17
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -6,6 +6,21 @@ require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
|
6
6
|
require "rspec/rails"
|
7
7
|
require "pry"
|
8
8
|
|
9
|
+
Rails.application.configure do
|
10
|
+
# Why set to true? Because according to Rails:
|
11
|
+
#
|
12
|
+
# .config.eager_load is set to nil. Please update your config/environments/*.rb files accordingly:
|
13
|
+
#
|
14
|
+
# * development - set it to false
|
15
|
+
# * test - set it to false (unless you use a tool that preloads your test environment)
|
16
|
+
# * production - set it to true
|
17
|
+
#
|
18
|
+
# The view initializer for haml runs in a `ActiveSupport.on_load(:action_view)`, which requires
|
19
|
+
# `eager_load = true` to test.
|
20
|
+
config.eager_load = true
|
21
|
+
end
|
22
|
+
|
23
|
+
# Suppress error output during testing.
|
9
24
|
Rails.backtrace_cleaner.remove_silencers!
|
10
25
|
|
11
26
|
# Load support files
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sitepress-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brad Gessler
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-07-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec-rails
|
@@ -44,28 +44,28 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '6.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '6.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: sitepress-core
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - '='
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 3.0.1
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - '='
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 3.0.1
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: railties
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -125,16 +125,28 @@ files:
|
|
125
125
|
- lib/sitepress/build_paths/root_path.rb
|
126
126
|
- lib/sitepress/compiler.rb
|
127
127
|
- lib/sitepress/engine.rb
|
128
|
+
- lib/sitepress/model.rb
|
129
|
+
- lib/sitepress/models/collection.rb
|
128
130
|
- lib/sitepress/rails.rb
|
129
131
|
- lib/sitepress/rails_configuration.rb
|
130
132
|
- lib/sitepress/renderers/controller.rb
|
131
133
|
- lib/sitepress/renderers/server.rb
|
132
134
|
- lib/sitepress/rendition.rb
|
133
135
|
- lib/sitepress/route_constraint.rb
|
136
|
+
- lib/sitepress/routing_mapper.rb
|
134
137
|
- lib/tasks/sitepress_tasks.rake
|
135
138
|
- rails/app/controllers/concerns/sitepress/site_pages.rb
|
136
139
|
- rails/app/controllers/sitepress/site_controller.rb
|
137
|
-
- rails/
|
140
|
+
- rails/lib/generators/sitepress/controller/USAGE
|
141
|
+
- rails/lib/generators/sitepress/controller/controller_generator.rb
|
142
|
+
- rails/lib/generators/sitepress/controller/templates/controllers/site_controller.rb
|
143
|
+
- rails/lib/generators/sitepress/install/USAGE
|
144
|
+
- rails/lib/generators/sitepress/install/install_generator.rb
|
145
|
+
- rails/lib/generators/sitepress/install/templates/helpers/page_helper.rb
|
146
|
+
- rails/lib/generators/sitepress/install/templates/models/page_model.rb
|
147
|
+
- rails/lib/generators/sitepress/install/templates/pages/index.html.erb
|
148
|
+
- rails/test/lib/generators/sitepress/controller_generator_test.rb
|
149
|
+
- rails/test/lib/generators/sitepress/install_generator_test.rb
|
138
150
|
- sitepress-rails.gemspec
|
139
151
|
- spec/dummy/Rakefile
|
140
152
|
- spec/dummy/app/assets/config/manifest.js
|
@@ -143,6 +155,7 @@ files:
|
|
143
155
|
- spec/dummy/app/assets/stylesheets/application.css
|
144
156
|
- spec/dummy/app/content/helpers/sample_helper.rb
|
145
157
|
- spec/dummy/app/content/layouts/sitepress_test_layout.html.erb
|
158
|
+
- spec/dummy/app/content/models/page_model.rb
|
146
159
|
- spec/dummy/app/content/pages/_stupid.html.erb
|
147
160
|
- spec/dummy/app/content/pages/all_pages.html.erb
|
148
161
|
- spec/dummy/app/content/pages/hi.html
|
@@ -186,8 +199,6 @@ files:
|
|
186
199
|
- spec/dummy/config/routes.rb
|
187
200
|
- spec/dummy/config/secrets.yml
|
188
201
|
- spec/dummy/config/spring.rb
|
189
|
-
- spec/dummy/db/test.sqlite3
|
190
|
-
- spec/dummy/log/production.log
|
191
202
|
- spec/dummy/log/test.log
|
192
203
|
- spec/dummy/public/404.html
|
193
204
|
- spec/dummy/public/422.html
|
@@ -197,6 +208,7 @@ files:
|
|
197
208
|
- spec/dummy/public/favicon.ico
|
198
209
|
- spec/sitepress-rails_spec.rb
|
199
210
|
- spec/sitepress/compiler_spec.rb
|
211
|
+
- spec/sitepress/model_spec.rb
|
200
212
|
- spec/sitepress/rails_configuration_spec.rb
|
201
213
|
- spec/sitepress/route_constraint_spec.rb
|
202
214
|
- spec/sitepress/routes_spec.rb
|
@@ -227,7 +239,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
227
239
|
- !ruby/object:Gem::Version
|
228
240
|
version: '0'
|
229
241
|
requirements: []
|
230
|
-
rubygems_version: 3.
|
242
|
+
rubygems_version: 3.3.7
|
231
243
|
signing_key:
|
232
244
|
specification_version: 4
|
233
245
|
summary: Sitepress rails integration.
|
@@ -239,6 +251,7 @@ test_files:
|
|
239
251
|
- spec/dummy/app/assets/stylesheets/application.css
|
240
252
|
- spec/dummy/app/content/helpers/sample_helper.rb
|
241
253
|
- spec/dummy/app/content/layouts/sitepress_test_layout.html.erb
|
254
|
+
- spec/dummy/app/content/models/page_model.rb
|
242
255
|
- spec/dummy/app/content/pages/_stupid.html.erb
|
243
256
|
- spec/dummy/app/content/pages/all_pages.html.erb
|
244
257
|
- spec/dummy/app/content/pages/hi.html
|
@@ -282,8 +295,6 @@ test_files:
|
|
282
295
|
- spec/dummy/config/secrets.yml
|
283
296
|
- spec/dummy/config/spring.rb
|
284
297
|
- spec/dummy/config.ru
|
285
|
-
- spec/dummy/db/test.sqlite3
|
286
|
-
- spec/dummy/log/production.log
|
287
298
|
- spec/dummy/log/test.log
|
288
299
|
- spec/dummy/public/404.html
|
289
300
|
- spec/dummy/public/422.html
|
@@ -292,6 +303,7 @@ test_files:
|
|
292
303
|
- spec/dummy/public/apple-touch-icon.png
|
293
304
|
- spec/dummy/public/favicon.ico
|
294
305
|
- spec/sitepress/compiler_spec.rb
|
306
|
+
- spec/sitepress/model_spec.rb
|
295
307
|
- spec/sitepress/rails_configuration_spec.rb
|
296
308
|
- spec/sitepress/route_constraint_spec.rb
|
297
309
|
- spec/sitepress/routes_spec.rb
|
data/rails/config/routes.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
Sitepress.configuration.parent_engine.routes.draw do
|
2
|
-
if Sitepress.configuration.routes
|
3
|
-
constraints Sitepress::RouteConstraint.new do
|
4
|
-
get "*resource_path", controller: "sitepress/site", action: "show", as: :page, format: false
|
5
|
-
if has_named_route? :root
|
6
|
-
Rails.logger.warn 'Sitepress tried to configure `root to: "sitepress/site#show"`, but a root route was already defined.'
|
7
|
-
else
|
8
|
-
root to: "sitepress/site#show"
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
data/spec/dummy/db/test.sqlite3
DELETED
File without changes
|