contentable 0.3.0 → 0.3.1

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.3.1
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{contentable}
8
- s.version = "0.3.0"
8
+ s.version = "0.3.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["metasoarous"]
12
- s.date = %q{2011-01-17}
12
+ s.date = %q{2011-01-20}
13
13
  s.description = %q{Contentable allows rails developers to place chunks of content in "content_items" whcih store content text, titles and descriptions in order to make content more easily updateable manageable.}
14
14
  s.email = %q{metasoarous@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -24,7 +24,7 @@ module Contentable
24
24
  # Model module in the model class
25
25
  module Helpers
26
26
  def display_textile(text)
27
- RedCloth.new(text).to_html
27
+ RedCloth.new(text).to_html.html_safe
28
28
  end
29
29
  def display_content(content_item, edit = false)
30
30
  html = display_textile(content_item.text)
@@ -85,6 +85,7 @@ module Contentable
85
85
  else
86
86
  @content_item = ContentItem.safe_find_by_name("content_missing")
87
87
  end
88
+ return @content_item
88
89
  end
89
90
  end
90
91
 
@@ -13,7 +13,16 @@ class ContentItemsController < ApplicationController
13
13
  # GET /content_items/1
14
14
  # GET /content_items/1.xml
15
15
  def show
16
- @content_item = ContentItem.find(params[:id])
16
+ find_content_item
17
+
18
+ respond_to do |format|
19
+ format.html # show.html.erb
20
+ format.xml { render :xml => @content_item }
21
+ end
22
+ end
23
+
24
+ def show_with_direct_attribute_assign
25
+ @content_item = find_content_item
17
26
 
18
27
  respond_to do |format|
19
28
  format.html # show.html.erb
@@ -34,7 +43,7 @@ class ContentItemsController < ApplicationController
34
43
 
35
44
  # GET /content_items/1/edit
36
45
  def edit
37
- @content_item = ContentItem.find(params[:id])
46
+ find_content_item
38
47
  end
39
48
 
40
49
  # POST /content_items
@@ -1,60 +1,61 @@
1
1
  AppRoot::Application.routes.draw do
2
- resources :content_items
3
-
4
- # The priority is based upon order of creation:
5
- # first created -> highest priority.
6
-
7
- # Sample of regular route:
8
- # match 'products/:id' => 'catalog#view'
9
- # Keep in mind you can assign values other than :controller and :action
10
-
11
- # Sample of named route:
12
- # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
13
- # This route can be invoked with purchase_url(:id => product.id)
14
-
15
- # Sample resource route (maps HTTP verbs to controller actions automatically):
16
- # resources :products
17
-
18
- # Sample resource route with options:
19
- # resources :products do
20
- # member do
21
- # get 'short'
22
- # post 'toggle'
23
- # end
24
- #
25
- # collection do
26
- # get 'sold'
27
- # end
28
- # end
29
-
30
- # Sample resource route with sub-resources:
31
- # resources :products do
32
- # resources :comments, :sales
33
- # resource :seller
34
- # end
35
-
36
- # Sample resource route with more complex sub-resources
37
- # resources :products do
38
- # resources :comments
39
- # resources :sales do
40
- # get 'recent', :on => :collection
41
- # end
42
- # end
43
-
44
- # Sample resource route within a namespace:
45
- # namespace :admin do
46
- # # Directs /admin/products/* to Admin::ProductsController
47
- # # (app/controllers/admin/products_controller.rb)
48
- # resources :products
49
- # end
50
-
51
- # You can have the root of your site routed with "root"
52
- # just remember to delete public/index.html.
53
- # root :to => "welcome#index"
54
-
55
- # See how all your routes lay out with "rake routes"
56
-
57
- # This is a legacy wild controller route that's not recommended for RESTful applications.
58
- # Note: This route will make all actions in every controller accessible via GET requests.
59
- # match ':controller(/:action(/:id(.:format)))'
2
+ resources :content_items
3
+
4
+ match "content/:name" => "content_items#view"
5
+ # The priority is based upon order of creation:
6
+ # first created -> highest priority.
7
+
8
+ # Sample of regular route:
9
+ # match 'products/:id' => 'catalog#view'
10
+ # Keep in mind you can assign values other than :controller and :action
11
+
12
+ # Sample of named route:
13
+ # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
14
+ # This route can be invoked with purchase_url(:id => product.id)
15
+
16
+ # Sample resource route (maps HTTP verbs to controller actions automatically):
17
+ # resources :products
18
+
19
+ # Sample resource route with options:
20
+ # resources :products do
21
+ # member do
22
+ # get 'short'
23
+ # post 'toggle'
24
+ # end
25
+ #
26
+ # collection do
27
+ # get 'sold'
28
+ # end
29
+ # end
30
+
31
+ # Sample resource route with sub-resources:
32
+ # resources :products do
33
+ # resources :comments, :sales
34
+ # resource :seller
35
+ # end
36
+
37
+ # Sample resource route with more complex sub-resources
38
+ # resources :products do
39
+ # resources :comments
40
+ # resources :sales do
41
+ # get 'recent', :on => :collection
42
+ # end
43
+ # end
44
+
45
+ # Sample resource route within a namespace:
46
+ # namespace :admin do
47
+ # # Directs /admin/products/* to Admin::ProductsController
48
+ # # (app/controllers/admin/products_controller.rb)
49
+ # resources :products
50
+ # end
51
+
52
+ # You can have the root of your site routed with "root"
53
+ # just remember to delete public/index.html.
54
+ # root :to => "welcome#index"
55
+
56
+ # See how all your routes lay out with "rake routes"
57
+
58
+ # This is a legacy wild controller route that's not recommended for RESTful applications.
59
+ # Note: This route will make all actions in every controller accessible via GET requests.
60
+ # match ':controller(/:action(/:id(.:format)))'
60
61
  end
@@ -28,4 +28,33 @@ A paragraph
28
28
  result.should include "<p>"
29
29
  end
30
30
  end
31
- end
31
+ end
32
+
33
+ describe ContentItemsController do
34
+ before :all do
35
+ @content = Factory :content_item, :name => "some_content"
36
+ end
37
+
38
+ describe "find_content_item method" do
39
+ it "should assign a content item to @content_item implicitly" do
40
+ get "content/some_content"
41
+ assigns[:content_item].should.be_a_kind_of ContentItem
42
+ end
43
+ it "should assign the correct content item to @content_item" do
44
+ get "content/some_content"
45
+ assigns[:content_item].should == @content
46
+ end
47
+ it "should assign a content item to @content_item explicitly" do
48
+
49
+ end
50
+ end
51
+ end
52
+
53
+
54
+ # Things to spec:
55
+ #
56
+ # Make sure that the find_content_item method doesn't return a string
57
+ # This is sure to be confusing to people
58
+ #
59
+ # Spec out the way it is written to respond here though (that is, by
60
+ # assigning directly to the attribute within the method)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: contentable
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 0
10
- version: 0.3.0
9
+ - 1
10
+ version: 0.3.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - metasoarous
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-01-17 00:00:00 -08:00
18
+ date: 2011-01-20 00:00:00 -08:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency