beef-acts_as_content_node 0.1.2 → 0.1.3

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.1.2
1
+ 0.1.3
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{acts_as_content_node}
5
- s.version = "0.1.2"
5
+ s.version = "0.1.3"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Steve England"]
9
- s.date = %q{2009-06-25}
9
+ s.date = %q{2009-07-29}
10
10
  s.email = %q{steve@wearebeef.co.uk}
11
11
  s.extra_rdoc_files = [
12
12
  "LICENSE",
@@ -39,7 +39,6 @@ Gem::Specification.new do |s|
39
39
  "init.rb",
40
40
  "lib/acts_as_content_node.rb",
41
41
  "lib/acts_as_content_node/content_node.rb",
42
- "lib/acts_as_content_node/permalinks.rb",
43
42
  "lib/acts_as_content_node/publishable.rb",
44
43
  "rails/init.rb",
45
44
  "tasks/acts_as_content_node_tasks.rake",
@@ -1,3 +1,2 @@
1
1
  require "acts_as_content_node/content_node"
2
2
  require "acts_as_content_node/publishable"
3
- require "acts_as_content_node/permalinks"
@@ -9,7 +9,7 @@ module Beef
9
9
 
10
10
  named_scope :authored_by, lambda { |user|
11
11
  return {} if user.nil?
12
- user = User.find(user) unless user.is_a? User
12
+ user = User.find(user) unless user.is_a? ::User
13
13
  { :conditions => { :created_by_id => user.id } }
14
14
  }
15
15
 
data/rails/init.rb CHANGED
@@ -1,12 +1,9 @@
1
1
  require "acts_as_content_node/content_node"
2
2
  require "acts_as_content_node/publishable"
3
- require "acts_as_content_node/permalinks"
4
3
 
5
4
  config.to_prepare do
6
5
  ApplicationController.helper(ContentNodesHelper)
7
- ApplicationController.helper(Beef::Permalinks)
8
6
  end
9
7
 
10
8
  ActiveRecord::Base.send :include, Beef::Acts::ContentNode
11
9
  ActiveRecord::Base.send :include, Beef::Acts::Publishable
12
- ActionController::Base.send :include, Beef::Permalinks
@@ -12,6 +12,18 @@ class ContentNodeTest < Test::Unit::TestCase
12
12
  end
13
13
 
14
14
  should_validate_uniqueness_of :title, :message => 'has been used before'
15
+
16
+ should "be found by user" do
17
+ assert_equal [@content_node], ContentNode.authored_by(@content_node.created_by)
18
+ end
19
+
20
+ should "be found by user id" do
21
+ assert_equal [@content_node], ContentNode.authored_by(@content_node.created_by.id)
22
+ end
23
+
24
+ should "be found by all if user nil" do
25
+ assert !ContentNode.authored_by(nil).empty?
26
+ end
15
27
 
16
28
  end
17
29
 
data/test/schema.rb CHANGED
@@ -10,4 +10,9 @@ ActiveRecord::Schema.define(:version => 0) do
10
10
  t.datetime :updated_at
11
11
  t.references :updated_by, :created_by
12
12
  end
13
+
14
+ create_table :users, :force => true do |t|
15
+ t.string :name
16
+ t.string :permalink
17
+ end
13
18
  end
data/test/test_helper.rb CHANGED
@@ -16,7 +16,12 @@ $LOAD_PATH.unshift(File.dirname(__FILE__))
16
16
 
17
17
  RAILS_DEFAULT_LOGGER = Logger.new(File.join(File.dirname(__FILE__), "debug.log"))
18
18
 
19
- require File.join(File.dirname(__FILE__), '..', 'init')
19
+ require "acts_as_content_node/content_node"
20
+ require "acts_as_content_node/publishable"
21
+ require "acts_as_content_node/permalinks"
22
+
23
+ ActiveRecord::Base.send :include, Beef::Acts::ContentNode
24
+ ActiveRecord::Base.send :include, Beef::Acts::Publishable
20
25
 
21
26
  ActiveRecord::Base.configurations = YAML::load(IO.read(File.dirname(__FILE__) + "/database.yml"))
22
27
  ActiveRecord::Base.establish_connection(ENV["DB"] || "sqlite3mem")
@@ -27,9 +32,22 @@ class ContentNode < ActiveRecord::Base
27
32
  acts_as_content_node
28
33
  end
29
34
 
35
+ class User < ActiveRecord::Base
36
+ before_save :set_permalink
37
+
38
+ def set_permalink
39
+ self.permalink = name.parameterize
40
+ end
41
+ end
42
+
30
43
  Factory.define(:content_node) do |content_node|
31
44
  content_node.title {Faker::Lorem.words(5).join(' ')}
32
45
  content_node.description {Faker::Lorem.sentence}
33
46
  content_node.body {Faker::Lorem.paragraphs.join}
47
+ content_node.association :created_by, :factory => :user
48
+ end
49
+
50
+ Factory.define :user do |user|
51
+ user.name { Faker::Name.name }
34
52
  end
35
53
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beef-acts_as_content_node
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve England
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-06-25 00:00:00 -07:00
12
+ date: 2009-07-29 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -49,7 +49,6 @@ files:
49
49
  - init.rb
50
50
  - lib/acts_as_content_node.rb
51
51
  - lib/acts_as_content_node/content_node.rb
52
- - lib/acts_as_content_node/permalinks.rb
53
52
  - lib/acts_as_content_node/publishable.rb
54
53
  - rails/init.rb
55
54
  - tasks/acts_as_content_node_tasks.rake
@@ -59,6 +58,7 @@ files:
59
58
  - test/test_helper.rb
60
59
  has_rdoc: false
61
60
  homepage: http://github.com/beef/acts_as_content_node
61
+ licenses:
62
62
  post_install_message:
63
63
  rdoc_options:
64
64
  - --charset=UTF-8
@@ -79,7 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
79
79
  requirements: []
80
80
 
81
81
  rubyforge_project:
82
- rubygems_version: 1.2.0
82
+ rubygems_version: 1.3.5
83
83
  signing_key:
84
84
  specification_version: 3
85
85
  summary: Common functions for an record used as content of a website. Generator for cms and front end
@@ -1,18 +0,0 @@
1
- module Beef
2
- module Permalinks
3
-
4
- def permalink(record, options = {})
5
- record_method_name = record.class.name.underscore
6
- method_name = "#{record_method_name}_permalink"
7
-
8
- if respond_to?(method_name)
9
- send(method_name, record, options)
10
- elsif record.respond_to?('permalink')
11
- send("#{record_method_name}_path", record.permalink, options)
12
- else
13
- record
14
- end
15
- end
16
-
17
- end
18
- end