jeffrafter-spreadhead 0.1.1 → 0.3.0
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.
- data/CHANGELOG.textile +11 -1
- data/VERSION +1 -1
- data/app/controllers/spreadhead/pages_controller.rb +4 -4
- data/app/views/spreadhead/pages/_form.html.erb +4 -0
- data/app/views/spreadhead/pages/index.html.erb +1 -1
- data/lib/spreadhead/page.rb +1 -6
- data/test/controllers/pages_controller_test.rb +5 -5
- data/test/models/page_test.rb +29 -7
- metadata +2 -2
data/CHANGELOG.textile
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
-
h2. 0.
|
1
|
+
h2. 0.3.0
|
2
|
+
|
3
|
+
* Removed to_param behavior for page resource (Jeff Rafter)
|
4
|
+
* Allowed for "/" in urls (Jeff Rafter)
|
5
|
+
* Added a view link (Jeff Rafter)
|
6
|
+
|
7
|
+
h2. 0.2.0 (unreleased)
|
8
|
+
|
9
|
+
* Support for URL editing and overriding (Jeff Rafter)
|
10
|
+
|
11
|
+
h2. 0.1.0
|
2
12
|
|
3
13
|
* Initial Release (Jeff Rafter)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
@@ -11,11 +11,11 @@ module Spreadhead
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def show
|
14
|
-
@page = ::Page.published.find_by_url!(params[:
|
14
|
+
@page = ::Page.published.find_by_url!(params[:url].to_a.join('/'))
|
15
15
|
end
|
16
16
|
|
17
17
|
def edit
|
18
|
-
@page = ::Page.
|
18
|
+
@page = ::Page.find(params[:id])
|
19
19
|
end
|
20
20
|
|
21
21
|
def create
|
@@ -32,7 +32,7 @@ module Spreadhead
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def update
|
35
|
-
@page = ::Page.
|
35
|
+
@page = ::Page.find(params[:id])
|
36
36
|
respond_to do |format|
|
37
37
|
if @page.update_attributes(params[:page])
|
38
38
|
format.html { redirect_to pages_url }
|
@@ -45,7 +45,7 @@ module Spreadhead
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def destroy
|
48
|
-
@page = ::Page.
|
48
|
+
@page = ::Page.find(params[:id])
|
49
49
|
@page.destroy
|
50
50
|
respond_to do |format|
|
51
51
|
format.html { redirect_to pages_url }
|
@@ -12,7 +12,7 @@
|
|
12
12
|
<td class="title"><%= link_to page.title || 'No title', edit_page_url(page) %></td>
|
13
13
|
<td class="path"><%= page.url || 'No url' %></td>
|
14
14
|
<td class="published"><%=h page.published ? 'Y' : 'N' %></td>
|
15
|
-
<td class="commands"><%= link_to 'Destroy', page_url(page), :confirm => 'Are you sure?', :method => :delete %></td>
|
15
|
+
<td class="commands"><%= link_to "View", page.url %> | <%= link_to 'Destroy', page_url(page), :confirm => 'Are you sure?', :method => :delete %></td>
|
16
16
|
</tr>
|
17
17
|
<% end %>
|
18
18
|
</table>
|
data/lib/spreadhead/page.rb
CHANGED
@@ -58,17 +58,12 @@ module Spreadhead
|
|
58
58
|
# :title should act like a url.
|
59
59
|
def self.included(model)
|
60
60
|
model.class_eval do
|
61
|
-
|
62
|
-
acts_as_url :title, :sync_url => true
|
61
|
+
acts_as_url :title, :sync_url => true, :only_when_blank => true
|
63
62
|
end
|
64
63
|
end
|
65
64
|
end
|
66
65
|
|
67
66
|
module InstanceMethods
|
68
|
-
# The default parameter method for pages is the url
|
69
|
-
def to_param
|
70
|
-
url
|
71
|
-
end
|
72
67
|
end
|
73
68
|
|
74
69
|
module ClassMethods
|
@@ -24,7 +24,7 @@ class PagesControllerTest < ActionController::TestCase
|
|
24
24
|
context "on GET to #show" do
|
25
25
|
setup do
|
26
26
|
page = Factory(:page)
|
27
|
-
get :show, :
|
27
|
+
get :show, :url => page.url
|
28
28
|
end
|
29
29
|
|
30
30
|
should_respond_with :success
|
@@ -35,7 +35,7 @@ class PagesControllerTest < ActionController::TestCase
|
|
35
35
|
context "on GET to #edit" do
|
36
36
|
setup do
|
37
37
|
page = Factory(:page)
|
38
|
-
get :edit, :id => page.
|
38
|
+
get :edit, :id => page.id
|
39
39
|
end
|
40
40
|
|
41
41
|
should_respond_with :success
|
@@ -56,7 +56,7 @@ class PagesControllerTest < ActionController::TestCase
|
|
56
56
|
context "on PUT to #update with valid attributes" do
|
57
57
|
setup do
|
58
58
|
page = Factory(:page)
|
59
|
-
put :update, :id => page.
|
59
|
+
put :update, :id => page.id, :page => page.attributes
|
60
60
|
end
|
61
61
|
|
62
62
|
should_respond_with :redirect
|
@@ -66,7 +66,7 @@ class PagesControllerTest < ActionController::TestCase
|
|
66
66
|
context "on DELETE to #destroy with valid attributes" do
|
67
67
|
setup do
|
68
68
|
page = Factory(:page)
|
69
|
-
delete :destroy, :id => page.
|
69
|
+
delete :destroy, :id => page.id
|
70
70
|
end
|
71
71
|
|
72
72
|
should_respond_with :redirect
|
@@ -75,7 +75,7 @@ class PagesControllerTest < ActionController::TestCase
|
|
75
75
|
should "Destroy the page" do
|
76
76
|
count = Page.count
|
77
77
|
page = Factory(:page)
|
78
|
-
delete :destroy, :id => page.
|
78
|
+
delete :destroy, :id => page.id
|
79
79
|
assert_equal Page.count, count
|
80
80
|
end
|
81
81
|
|
data/test/models/page_test.rb
CHANGED
@@ -7,8 +7,7 @@ class PageTest < ActiveSupport::TestCase
|
|
7
7
|
setup { Factory(:page) }
|
8
8
|
|
9
9
|
should_validate_presence_of :text, :title
|
10
|
-
should_validate_uniqueness_of :title
|
11
|
-
should_not_allow_mass_assignment_of :url
|
10
|
+
should_validate_uniqueness_of :title
|
12
11
|
|
13
12
|
should "generate a url" do
|
14
13
|
page = Factory.build(:page, :title => 'smack!')
|
@@ -16,16 +15,39 @@ class PageTest < ActiveSupport::TestCase
|
|
16
15
|
assert_not_nil page.url
|
17
16
|
assert_equal 'smack', page.url
|
18
17
|
end
|
18
|
+
|
19
|
+
should "accept a url" do
|
20
|
+
page = Factory.build(:page, :title => 'smackdown!', :url => 'whammo')
|
21
|
+
assert page.save
|
22
|
+
assert_not_nil page.url
|
23
|
+
assert_equal 'whammo', page.url
|
24
|
+
end
|
25
|
+
|
26
|
+
should "not duplicate urls" do
|
27
|
+
page = Factory.build(:page, :title => 'smurf', :url => 'bunnies')
|
28
|
+
assert page.save
|
29
|
+
assert_not_nil page.url
|
30
|
+
assert_equal 'bunnies', page.url
|
31
|
+
page = Factory.build(:page, :title => 'bunnies', :url => nil)
|
32
|
+
assert page.save
|
33
|
+
assert_not_nil page.url
|
34
|
+
assert_not_equal 'bunnies', page.url
|
35
|
+
end
|
36
|
+
|
37
|
+
should "modify the submitted url and be valid if duplicate url is submitted" do
|
38
|
+
page = Factory(:page, :title => 'smurf', :url => 'bunnies')
|
39
|
+
dup = Factory.build(:page, :title => 'smurffette', :url => 'bunnies')
|
40
|
+
assert dup.valid?
|
41
|
+
assert_not_equal page.url, dup.url
|
42
|
+
assert dup.save
|
43
|
+
assert !dup.errors.on(:url)
|
44
|
+
end
|
45
|
+
|
19
46
|
end
|
20
47
|
|
21
48
|
context "When retrieving a page" do
|
22
49
|
setup { Factory(:page) }
|
23
50
|
|
24
51
|
should_have_named_scope :published
|
25
|
-
|
26
|
-
should "use the url as the default parameter" do
|
27
|
-
page = Factory(:page, :title => 'whammo')
|
28
|
-
assert_equal 'whammo', page.to_param
|
29
|
-
end
|
30
52
|
end
|
31
53
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jeffrafter-spreadhead
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Rafter
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-08-
|
12
|
+
date: 2009-08-16 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|