cmsimple 0.2.0 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/README.md +2 -1
- data/app/assets/javascripts/cmsimple/views/redirects/list.jst.hamlc +0 -1
- data/app/assets/javascripts/cmsimple/views/versions/_item.jst.hamlc +2 -2
- data/app/assets/stylesheets/cmsimple.css +1 -1
- data/app/assets/stylesheets/cmsimple/{forms.css → elements.css} +0 -0
- data/app/assets/stylesheets/cmsimple/panels.css +56 -81
- data/app/assets/stylesheets/cmsimple/toolbar-images.css +0 -1
- data/app/controllers/cmsimple/front_controller.rb +1 -1
- data/app/controllers/cmsimple/pages_controller.rb +1 -1
- data/app/models/cmsimple/path.rb +19 -7
- data/features/create.feature +1 -1
- data/lib/cmsimple/version.rb +1 -1
- data/lib/generators/cmsimple/snippet/templates/options.html.erb +1 -1
- data/spec/models/path_spec.rb +96 -23
- data/spec/spec_helper.rb +1 -1
- metadata +5 -5
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
[![Build Status](https://secure.travis-ci.org/modeset/cmsimple.png?branch=master)](http://travis-ci.org/modeset/cmsimple)
|
4
4
|
[![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/modeset/cmsimple)
|
5
|
+
[![Gem Version](https://badge.fury.io/rb/cmsimple.png)](http://badge.fury.io/rb/cmsimple)
|
5
6
|
|
6
7
|
CMSimple is an easy-to-use but extensible CMS wrapped around the Mercury editor (https://github.com/jejacks0n/mercury), written as a Rails engine.
|
7
8
|
|
@@ -103,7 +104,7 @@ To run the test suite for CMSimple, you will need to do the following:
|
|
103
104
|
1. Configure a `database.yml` in the demo rails app6 (see spec/rails_app/config/database.example.yml)
|
104
105
|
2. Run setup tasks: `rake app:db:setup` and `rake app:db:test:prepare`
|
105
106
|
2. Run specs
|
106
|
-
1. `rake
|
107
|
+
1. `rake`
|
107
108
|
2. Wait.
|
108
109
|
|
109
110
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
%li(id="version_#{@id}" data-id=@id)
|
2
2
|
%article
|
3
3
|
%p.published= moment(@published_at).format('dddd, MMMM Do YYYY, h:mm:ss a')
|
4
|
-
%button.btn.view View
|
5
|
-
%button.btn.
|
4
|
+
%button.btn.btn-primary.view View
|
5
|
+
%button.btn.btn-danger.revert Revert to
|
6
6
|
|
File without changes
|
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
/* Dialogs */
|
3
2
|
.mercury-framed-panel {
|
4
3
|
background-color: #f5f5f5;
|
@@ -8,8 +7,6 @@
|
|
8
7
|
.mercury-framed-panel h1 {
|
9
8
|
color: #f5f5f5;
|
10
9
|
border-bottom: 1px solid #222;
|
11
|
-
-moz-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
|
12
|
-
-webkit-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
|
13
10
|
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
|
14
11
|
}
|
15
12
|
|
@@ -38,8 +35,6 @@
|
|
38
35
|
.mercury-panel .panel-actions {
|
39
36
|
background-color: #eaeaea;
|
40
37
|
border: 1px solid #ccc;
|
41
|
-
-webkit-border-radius: 0.5em;
|
42
|
-
-moz-border-radius: 0.5em;
|
43
38
|
border-radius: 0.5em;
|
44
39
|
padding: 1em;
|
45
40
|
overflow: hidden;
|
@@ -50,9 +45,9 @@
|
|
50
45
|
|
51
46
|
.mercury-panel-pane .loading {
|
52
47
|
text-align: center;
|
53
|
-
width: 100%;
|
54
48
|
float: left;
|
55
|
-
margin-top: 50
|
49
|
+
margin-top: 50%;
|
50
|
+
width: 100%;
|
56
51
|
}
|
57
52
|
|
58
53
|
.mercury-panel .hidden {
|
@@ -62,7 +57,6 @@
|
|
62
57
|
* Image Panel
|
63
58
|
*----------------------------------------------------------------------------*/
|
64
59
|
.mercury-panel .add-image-action {
|
65
|
-
/* margin-top: 50px; */
|
66
60
|
display: none;
|
67
61
|
}
|
68
62
|
|
@@ -85,14 +79,14 @@
|
|
85
79
|
|
86
80
|
.mercury-panel .add-image-action label {
|
87
81
|
font-size: 11px;
|
82
|
+
text-align: left;
|
88
83
|
display: block;
|
84
|
+
overflow: visible;
|
89
85
|
float: none;
|
90
|
-
width: auto;
|
91
|
-
margin-right: 0;
|
92
|
-
text-align: left;
|
93
86
|
line-height: normal;
|
94
|
-
overflow: visible;
|
95
87
|
margin-top: 20px;
|
88
|
+
margin-right: 0;
|
89
|
+
width: auto;
|
96
90
|
}
|
97
91
|
.mercury-panel .add-image-action textarea {
|
98
92
|
font-size: 1em;
|
@@ -100,27 +94,26 @@
|
|
100
94
|
}
|
101
95
|
|
102
96
|
.image-filter input.filter {
|
103
|
-
|
104
|
-
font-size: 1em;
|
105
|
-
border-radius: 30px;
|
106
|
-
moz-border-radius: 30px;
|
107
|
-
box-sizing: border-box;
|
108
|
-
-moz-box-sizing: border-box;
|
109
|
-
-webkit-box-sizing: border-box;
|
110
|
-
width: 100%;
|
111
|
-
padding-left: 20px;
|
112
|
-
background-color: #FFF;
|
113
|
-
background-repeat: no-repeat;
|
97
|
+
background-color: white;
|
114
98
|
background-image: url(/assets/mercury/search-icon.png);
|
115
99
|
background-position: 4px center;
|
116
|
-
|
100
|
+
background-repeat: no-repeat;
|
101
|
+
border-radius: 30px;
|
102
|
+
font-size: 1em;
|
103
|
+
outline: none;
|
104
|
+
margin: 1em 0;
|
105
|
+
padding-left: 20px;
|
106
|
+
width: 100%;
|
107
|
+
-webkit-box-sizing: border-box;
|
108
|
+
-moz-box-sizing: border-box;
|
109
|
+
box-sizing: border-box;
|
117
110
|
}
|
118
111
|
|
119
112
|
.mercury-panel ul.media-grid {
|
120
|
-
width: 400px;
|
121
|
-
padding: 0;
|
122
|
-
overflow: hidden;
|
123
113
|
list-style: none;
|
114
|
+
overflow: hidden;
|
115
|
+
padding: 0;
|
116
|
+
width: 400px;
|
124
117
|
}
|
125
118
|
|
126
119
|
.mercury-panel .media-grid > li {
|
@@ -132,37 +125,35 @@
|
|
132
125
|
}
|
133
126
|
|
134
127
|
.mercury-panel .media-item {
|
135
|
-
position: relative;
|
136
|
-
display: block;
|
137
|
-
padding: 4px;
|
138
|
-
line-height: 1;
|
139
128
|
border: 1px solid #ccc;
|
140
129
|
cursor: default;
|
130
|
+
line-height: 1;
|
131
|
+
display: block;
|
132
|
+
position: relative;
|
133
|
+
padding: 4px;
|
141
134
|
max-width: 182px;
|
142
135
|
}
|
143
136
|
|
144
137
|
.mercury-panel .media-item:hover {
|
145
138
|
border-color: #268bd2;
|
146
|
-
-webkit-box-shadow: 0 0 8px rgba(82, 168, 236, 0.6);
|
147
|
-
-moz-box-shadow: 0 0 8px rgba(82, 168, 236, 0.6);
|
148
139
|
box-shadow: 0 0 8px rgba(82, 168, 236, 0.6);
|
149
140
|
}
|
150
141
|
|
151
142
|
.mercury-panel .media-item > .media-info {
|
152
|
-
position: absolute;
|
153
143
|
background-color: rgba(255,255,255,0.9);
|
154
|
-
|
144
|
+
display: none;
|
145
|
+
overflow: hidden;
|
146
|
+
position: absolute;
|
155
147
|
width: 182px;
|
156
148
|
height: 182px;
|
157
|
-
|
158
|
-
display: none;
|
149
|
+
z-index: 2;
|
159
150
|
}
|
160
151
|
.mercury-panel .media-item > .media-info .close {
|
161
152
|
position: absolute;
|
162
153
|
top: 0;
|
163
154
|
right: 2px;
|
164
155
|
text-decoration: none;
|
165
|
-
color:
|
156
|
+
color: black;
|
166
157
|
}
|
167
158
|
|
168
159
|
.mercury-panel .media-item > .media-info.active {
|
@@ -175,8 +166,8 @@
|
|
175
166
|
}
|
176
167
|
.mercury-panel .media-item > .media-info dt {
|
177
168
|
font-size: .75em;
|
178
|
-
text-transform: uppercase;
|
179
169
|
font-weight: bold;
|
170
|
+
text-transform: uppercase;
|
180
171
|
margin: 1em 0 0.25em;
|
181
172
|
padding: 0;
|
182
173
|
}
|
@@ -187,9 +178,9 @@
|
|
187
178
|
|
188
179
|
.mercury-panel .media-item > img {
|
189
180
|
display: block;
|
190
|
-
max-width: 100%;
|
191
181
|
margin-left: auto;
|
192
182
|
margin-right: auto;
|
183
|
+
max-width: 100%;
|
193
184
|
}
|
194
185
|
|
195
186
|
.mercury-panel .media-caption {
|
@@ -211,16 +202,16 @@
|
|
211
202
|
* Sitemap Panel
|
212
203
|
*----------------------------------------------------------------------------*/
|
213
204
|
.mercury-panel ul.sitemap {
|
214
|
-
width: 400px;
|
215
205
|
padding: 0;
|
206
|
+
width: 400px;
|
216
207
|
}
|
217
208
|
|
218
209
|
.mercury-panel ul.sitemap li {
|
210
|
+
background: url(/assets/tree-line-horizontal.png) no-repeat left 12px;
|
219
211
|
list-style: none;
|
220
|
-
padding: 0;
|
221
212
|
margin: 0;
|
213
|
+
padding: 0;
|
222
214
|
padding-left: 2.5em;
|
223
|
-
background: url(/assets/tree-line-horizontal.png) no-repeat left 12px;
|
224
215
|
}
|
225
216
|
.mercury-panel ul.sitemap li:last-child {
|
226
217
|
background-image: url(/assets/tree-line-horizontal-last.png);
|
@@ -232,14 +223,12 @@
|
|
232
223
|
|
233
224
|
.mercury-panel ul.sitemap > li article {
|
234
225
|
background-color: #666;
|
235
|
-
color: #fff;
|
236
|
-
padding: 0.25em 0.5em;
|
237
|
-
margin-bottom: 2px;
|
238
|
-
-webkit-border-radius: 0.25em;
|
239
|
-
-moz-border-radius: 0.25em;
|
240
226
|
border-radius: 0.25em;
|
241
|
-
cursor: default;
|
242
227
|
border: 1px solid transparent;
|
228
|
+
color: white;
|
229
|
+
cursor: default;
|
230
|
+
margin-bottom: 2px;
|
231
|
+
padding: 0.25em 0.5em;
|
243
232
|
}
|
244
233
|
/* Nested coloring of pages */
|
245
234
|
.mercury-panel ul.sitemap > li ul li article {
|
@@ -254,8 +243,6 @@
|
|
254
243
|
.mercury-panel ul.sitemap > li article:hover {
|
255
244
|
background-color: #444;
|
256
245
|
border-color: #268bd2;
|
257
|
-
-webkit-box-shadow: 0 0 8px rgba(82, 168, 236, 0.6);
|
258
|
-
-moz-box-shadow: 0 0 8px rgba(82, 168, 236, 0.6);
|
259
246
|
box-shadow: 0 0 8px rgba(82, 168, 236, 0.6);
|
260
247
|
}
|
261
248
|
|
@@ -266,12 +253,12 @@
|
|
266
253
|
margin-left: 0.5em;
|
267
254
|
}
|
268
255
|
.mercury-panel ul.sitemap > li article .icon {
|
269
|
-
height: 16px;
|
270
|
-
width: 16px;
|
271
256
|
background: url('/assets/sitemap/unpublished.png') no-repeat left top;
|
272
257
|
background-size: 16px 16px;
|
273
|
-
margin-top: -1px;
|
274
258
|
margin-left: -4px;
|
259
|
+
margin-top: -1px;
|
260
|
+
width: 16px;
|
261
|
+
height: 16px;
|
275
262
|
}
|
276
263
|
.mercury-panel ul.sitemap > li article .icon.has-changes {
|
277
264
|
background-image: url('/assets/sitemap/has-changes.png');
|
@@ -280,24 +267,19 @@
|
|
280
267
|
background-image: url('/assets/sitemap/published.png');
|
281
268
|
}
|
282
269
|
.mercury-panel ul.sitemap .caret {
|
283
|
-
|
284
|
-
vertical-align: middle;
|
285
|
-
zoom: 1;
|
286
|
-
*display: inline;
|
287
|
-
*vertical-align: auto;
|
288
|
-
border-width: 4px;
|
270
|
+
border-color: white transparent transparent transparent;
|
289
271
|
border-style: solid;
|
290
|
-
border-
|
291
|
-
|
292
|
-
height: 0;
|
293
|
-
vertical-align: top;
|
272
|
+
border-width: 4px;
|
273
|
+
display: inline-block;
|
294
274
|
float: right;
|
295
275
|
margin: 0.5em 0;
|
276
|
+
width: 0;
|
277
|
+
height: 0;
|
296
278
|
}
|
297
279
|
|
298
280
|
.mercury-panel ul.sitemap .caret.north {
|
281
|
+
border-color: transparent transparent white transparent;
|
299
282
|
margin: 0.2em 0;
|
300
|
-
border-color: transparent transparent #fff transparent;
|
301
283
|
}
|
302
284
|
|
303
285
|
/* Increase the gap for top level pages */
|
@@ -307,7 +289,6 @@
|
|
307
289
|
|
308
290
|
.mercury-panel ul.sitemap ul {
|
309
291
|
padding: 0;
|
310
|
-
*zoom: 1;
|
311
292
|
}
|
312
293
|
.mercury-panel ul.sitemap ul:before,
|
313
294
|
.mercury-panel ul.sitemap ul:after {
|
@@ -331,21 +312,17 @@
|
|
331
312
|
|
332
313
|
.mercury-panel ul.redirects > li article {
|
333
314
|
background-color: #666;
|
334
|
-
color: #fff;
|
335
|
-
padding: 0 0.5em;
|
336
|
-
margin-bottom: 2px;
|
337
|
-
-webkit-border-radius: 0.25em;
|
338
|
-
-moz-border-radius: 0.25em;
|
339
315
|
border-radius: 0.25em;
|
340
316
|
border: 1px solid transparent;
|
317
|
+
color: white;
|
341
318
|
cursor: default;
|
319
|
+
margin-bottom: 2px;
|
320
|
+
padding: 0 0.5em;
|
342
321
|
}
|
343
322
|
|
344
323
|
.mercury-panel ul.redirects > li article:hover {
|
345
324
|
background-color: #444;
|
346
325
|
border-color: #268bd2;
|
347
|
-
-webkit-box-shadow: 0 0 8px rgba(82, 168, 236, 0.6);
|
348
|
-
-moz-box-shadow: 0 0 8px rgba(82, 168, 236, 0.6);
|
349
326
|
box-shadow: 0 0 8px rgba(82, 168, 236, 0.6);
|
350
327
|
}
|
351
328
|
|
@@ -358,12 +335,12 @@
|
|
358
335
|
}
|
359
336
|
|
360
337
|
.mercury-panel ul.redirects > li article .remove {
|
338
|
+
color: white;
|
339
|
+
font-weight: bold;
|
340
|
+
text-decoration: none;
|
361
341
|
position: absolute;
|
362
342
|
top: 0;
|
363
343
|
right: 5px;
|
364
|
-
color: #fff;
|
365
|
-
text-decoration: none;
|
366
|
-
font-weight: bold;
|
367
344
|
}
|
368
345
|
|
369
346
|
/* Versions panel */
|
@@ -379,14 +356,12 @@
|
|
379
356
|
|
380
357
|
.mercury-panel ul.versions > li article {
|
381
358
|
background-color: #666;
|
382
|
-
color: #fff;
|
383
|
-
padding: 0 0.5em;
|
384
|
-
margin-bottom: 2px;
|
385
|
-
-webkit-border-radius: 0.25em;
|
386
|
-
-moz-border-radius: 0.25em;
|
387
359
|
border-radius: 0.25em;
|
388
360
|
border: 1px solid transparent;
|
361
|
+
color: white;
|
389
362
|
cursor: default;
|
363
|
+
margin-bottom: 2px;
|
364
|
+
padding: 0 0.5em;
|
390
365
|
}
|
391
366
|
.mercury-panel ul.versions > li article .view,
|
392
367
|
.mercury-panel ul.versions > li article .revert {
|
data/app/models/cmsimple/path.rb
CHANGED
@@ -12,16 +12,17 @@ module Cmsimple
|
|
12
12
|
before_validation :downcase_uri
|
13
13
|
|
14
14
|
def self.from_request(request)
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
with_pages.merge(Cmsimple::Page.root).first!
|
20
|
-
else
|
21
|
-
with_pages.where(uri: path).first!
|
15
|
+
if !request.params.has_key?(:path)
|
16
|
+
with_pages.merge(Cmsimple::Page.root).first
|
17
|
+
elsif result = find_from_request(request)
|
18
|
+
result
|
22
19
|
end
|
23
20
|
end
|
24
21
|
|
22
|
+
def self.from_request!(request)
|
23
|
+
from_request(request) || raise(ActiveRecord::RecordNotFound.new)
|
24
|
+
end
|
25
|
+
|
25
26
|
def self.with_pages
|
26
27
|
includes(:page)
|
27
28
|
end
|
@@ -40,6 +41,17 @@ module Cmsimple
|
|
40
41
|
|
41
42
|
protected
|
42
43
|
|
44
|
+
def self.find_from_request(request)
|
45
|
+
if found_with_fullpath = with_pages.where(uri: request.fullpath).first
|
46
|
+
found_with_fullpath
|
47
|
+
else
|
48
|
+
path = request.params[:path]
|
49
|
+
path = "/#{path.gsub(/\/$/,'')}".gsub(/\/+/, '/')
|
50
|
+
path.downcase!
|
51
|
+
with_pages.where(uri: path).first
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
43
55
|
def require_destination
|
44
56
|
unless destination.uri.present?
|
45
57
|
errors[:destination] << 'can\'t be blank'
|
data/features/create.feature
CHANGED
@@ -11,7 +11,7 @@ Feature: As a user I should be able to create pages on the site
|
|
11
11
|
Then I should be redirected to the new page
|
12
12
|
And I should see the page in the sitemap
|
13
13
|
|
14
|
-
Scenario: As a user I add a page from the sitemap panel
|
14
|
+
Scenario: As a user I add a new home page from the sitemap panel
|
15
15
|
When I open the sitemap
|
16
16
|
And I add a new home page
|
17
17
|
Then I should be redirected to the home page
|
data/lib/cmsimple/version.rb
CHANGED
data/spec/models/path_spec.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
|
2
3
|
describe Cmsimple::Path do
|
4
|
+
|
3
5
|
subject { Cmsimple::Path.new }
|
6
|
+
|
4
7
|
it { should validate_presence_of(:uri) }
|
5
8
|
it { should belong_to(:page) }
|
6
9
|
|
@@ -34,38 +37,108 @@ describe Cmsimple::Path do
|
|
34
37
|
subject.destination.should be_a(Cmsimple::Path::Redirect)
|
35
38
|
subject.should be_redirect
|
36
39
|
end
|
37
|
-
|
38
40
|
end
|
39
41
|
|
40
|
-
describe 'from_request' do
|
42
|
+
describe '#from_request' do
|
41
43
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
44
|
+
let(:request) { ActionDispatch::TestRequest.new }
|
45
|
+
|
46
|
+
context "when there is no path to follow" do
|
47
|
+
before do
|
48
|
+
request.stub(:fullpath).and_return('/foo')
|
49
|
+
request.stub(:params).and_return(path: '/path')
|
50
|
+
end
|
51
|
+
it "does not raise an error" do
|
52
|
+
expect(Cmsimple::Path.from_request(request)).to_not raise_error(ActiveRecord::RecordNotFound)
|
53
|
+
end
|
54
|
+
|
55
|
+
it "returns nil" do
|
56
|
+
expect(Cmsimple::Path.from_request(request)).to eq(nil)
|
57
|
+
end
|
47
58
|
end
|
48
59
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
60
|
+
context 'without a path parameter' do
|
61
|
+
it "should send you to Cmsimple root path" do
|
62
|
+
page = Cmsimple::Page.create!(is_root: true, uri: "/foo", slug: "foo", title: "Foo")
|
63
|
+
Cmsimple::Path.should_not_receive(:find_from_request)
|
64
|
+
request.stub(:fullpath).and_return('/editor')
|
65
|
+
request.stub(:params).and_return({})
|
66
|
+
expect(Cmsimple::Path.from_request(request).destination.uri).to eq("/foo")
|
67
|
+
end
|
53
68
|
end
|
54
69
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
70
|
+
context "when a path exists that matches the full request path" do
|
71
|
+
before { request.stub(:params).and_return(path:nil) }
|
72
|
+
|
73
|
+
it "finds the redirect" do
|
74
|
+
request.stub(:fullpath).and_return('/path')
|
75
|
+
subject.uri = '/path'
|
76
|
+
subject.redirect_uri = '/some-other-path'
|
77
|
+
subject.save
|
78
|
+
expect(Cmsimple::Path.from_request(request).destination.uri).to eq('/some-other-path')
|
79
|
+
end
|
80
|
+
|
81
|
+
it "finds the redirect when the path has an extension" do
|
82
|
+
request.stub(:fullpath).and_return('/Legacy.aspx')
|
83
|
+
subject.uri = '/Legacy.aspx'
|
84
|
+
subject.redirect_uri = '/some-other-path'
|
85
|
+
subject.save
|
86
|
+
expect(Cmsimple::Path.from_request(request).destination.uri).to eq('/some-other-path')
|
87
|
+
end
|
59
88
|
end
|
60
89
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
90
|
+
context "when a path exists that matches the globbed request path" do
|
91
|
+
before do
|
92
|
+
request.stub(:fullpath).and_return('/foo')
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'returns the path that has a uri matching the request path' do
|
96
|
+
request.stub(:params).and_return(path: '/path')
|
97
|
+
subject.uri = '/path'
|
98
|
+
subject.redirect_uri = '/some-other-path'
|
99
|
+
subject.save
|
100
|
+
Cmsimple::Path.from_request(request).destination.uri.should == '/some-other-path'
|
101
|
+
end
|
102
|
+
|
103
|
+
it "returns the path with the associated page" do
|
104
|
+
page = Cmsimple::Page.create title: 'About'
|
105
|
+
Cmsimple::Path.create uri: '/about', page: page
|
106
|
+
request.stub(:params).and_return(path: '/about')
|
107
|
+
Cmsimple::Path.from_request(request).destination.title.should == 'About'
|
108
|
+
end
|
109
|
+
|
110
|
+
it "returns the path where the associated page is marked as root" do
|
111
|
+
page = Cmsimple::Page.create title: 'Home', is_root: true
|
112
|
+
Cmsimple::Path.create uri: '/home', page: page
|
113
|
+
request.stub(:params).and_return(path: '/home')
|
114
|
+
Cmsimple::Path.from_request(request).destination.title.should == 'Home'
|
115
|
+
end
|
116
|
+
|
117
|
+
it "normalizes the path before querying" do
|
118
|
+
subject.uri = '/path'
|
119
|
+
subject.redirect_uri = '/some-other-path'
|
120
|
+
subject.save
|
121
|
+
request.stub(:params).and_return(path: '//path')
|
122
|
+
Cmsimple::Path.from_request(request).destination.uri.should == '/some-other-path'
|
123
|
+
request.stub(:params).and_return(path: '//path/')
|
124
|
+
Cmsimple::Path.from_request(request).destination.uri.should == '/some-other-path'
|
125
|
+
request.stub(:params).and_return(path: 'path')
|
126
|
+
Cmsimple::Path.from_request(request).destination.uri.should == '/some-other-path'
|
127
|
+
request.stub(:params).and_return(path: '/Path')
|
128
|
+
Cmsimple::Path.from_request(request).destination.uri.should == '/some-other-path'
|
129
|
+
end
|
69
130
|
end
|
70
131
|
end
|
132
|
+
|
133
|
+
describe "#from_request!" do
|
134
|
+
let(:request) { ActionDispatch::TestRequest.new }
|
135
|
+
|
136
|
+
it "raises ActiveRecord::RecordNotFound when no records are found" do
|
137
|
+
Cmsimple::Path.should_receive(:from_request).with(request).and_return(nil)
|
138
|
+
request.stub(:fullpath).and_return('/foo')
|
139
|
+
request.stub(:params).and_return(path: '/foo')
|
140
|
+
expect { Cmsimple::Path.from_request!(request) }.to raise_error ActiveRecord::RecordNotFound
|
141
|
+
end
|
142
|
+
|
143
|
+
end
|
71
144
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -17,7 +17,7 @@ RSpec.configure do |config|
|
|
17
17
|
# config.mock_with :mocha
|
18
18
|
# config.mock_with :flexmock
|
19
19
|
# config.mock_with :rr
|
20
|
-
|
20
|
+
config.mock_with :rspec
|
21
21
|
|
22
22
|
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
23
23
|
# config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cmsimple
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2013-
|
14
|
+
date: 2013-03-05 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rails
|
@@ -384,7 +384,7 @@ files:
|
|
384
384
|
- app/assets/javascripts/cmsimple/views/versions/_item.jst.hamlc
|
385
385
|
- app/assets/javascripts/cmsimple/views/versions/list.jst.hamlc
|
386
386
|
- app/assets/stylesheets/cmsimple.css
|
387
|
-
- app/assets/stylesheets/cmsimple/
|
387
|
+
- app/assets/stylesheets/cmsimple/elements.css
|
388
388
|
- app/assets/stylesheets/cmsimple/panels.css
|
389
389
|
- app/assets/stylesheets/cmsimple/toolbar-images.css
|
390
390
|
- app/assets/stylesheets/mercury_overrides.css
|
@@ -576,7 +576,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
576
576
|
version: '0'
|
577
577
|
segments:
|
578
578
|
- 0
|
579
|
-
hash:
|
579
|
+
hash: 3036956300692261753
|
580
580
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
581
581
|
none: false
|
582
582
|
requirements:
|
@@ -585,7 +585,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
585
585
|
version: '0'
|
586
586
|
segments:
|
587
587
|
- 0
|
588
|
-
hash:
|
588
|
+
hash: 3036956300692261753
|
589
589
|
requirements: []
|
590
590
|
rubyforge_project:
|
591
591
|
rubygems_version: 1.8.23
|