spreadhead 0.6.0 → 0.6.2
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/Rakefile +37 -5
- data/TUTORIAL.textile +5 -3
- data/VERSION +1 -1
- data/config/database.yml.sample +17 -0
- data/generators/spreadhead/templates/initializer.rb +1 -1
- data/generators/spreadhead/templates/migrations/create_pages.rb +1 -1
- data/generators/spreadhead/templates/migrations/update_pages.rb +1 -1
- data/lib/spreadhead/render.rb +3 -1
- data/lib/tasks/spreadhead_tasks.rake +6 -2
- data/test/controllers/pages_controller_test.rb +43 -0
- data/test/models/page_test.rb +15 -1
- data/test/test_helper.rb +15 -1
- metadata +6 -5
data/Rakefile
CHANGED
@@ -10,9 +10,9 @@ begin
|
|
10
10
|
gem.email = "jeff@socialrange.org"
|
11
11
|
gem.homepage = "http://github.com/jeffrafter/spreadhead"
|
12
12
|
gem.authors = ["Jeff Rafter"]
|
13
|
-
gem.add_dependency "BlueCloth"
|
14
|
-
gem.add_dependency "RedCloth"
|
15
|
-
gem.add_dependency "rsl-stringex"
|
13
|
+
gem.add_dependency "BlueCloth", ">= 1.0.0"
|
14
|
+
gem.add_dependency "RedCloth", ">= 4.1.1"
|
15
|
+
gem.add_dependency "rsl-stringex", ">= 1.0.2"
|
16
16
|
gem.files = FileList["[A-Z]*", "{app,config,generators,lib,rails}/**/*", "test/{controllers,models}/**/*", "test/test_helper.rb"]
|
17
17
|
gem.test_files = FileList["test/{controllers,models}/**/*", "test/test_helper.rb"]
|
18
18
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
@@ -29,6 +29,20 @@ Rake::TestTask.new(:test => ["generator:cleanup", "generator:spreadhead"]) do |t
|
|
29
29
|
task.verbose = true
|
30
30
|
end
|
31
31
|
|
32
|
+
namespace :test do
|
33
|
+
Rake::TestTask.new(:clearance => ["generator:cleanup", "generator:clearance", "generator:spreadhead"]) do |task|
|
34
|
+
task.libs << "lib" << "test"
|
35
|
+
task.pattern = "test/**/*_test.rb"
|
36
|
+
task.verbose = true
|
37
|
+
end
|
38
|
+
|
39
|
+
Rake::TestTask.new(:database => ["generator:cleanup", "generator:database", "generator:spreadhead"]) do |task|
|
40
|
+
task.libs << "lib" << "test"
|
41
|
+
task.pattern = "test/**/*_test.rb"
|
42
|
+
task.verbose = true
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
32
46
|
generators = %w(spreadhead)
|
33
47
|
|
34
48
|
namespace :generator do
|
@@ -44,15 +58,34 @@ namespace :generator do
|
|
44
58
|
system "echo \"config.gem 'thoughtbot-shoulda', :lib => 'shoulda'\" >> test/rails/config/environments/test.rb"
|
45
59
|
system "echo \"config.gem 'thoughtbot-factory_girl', :lib => 'factory_girl'\" >> test/rails/config/environments/test.rb"
|
46
60
|
|
61
|
+
# Make a thing
|
62
|
+
system "cd test/rails && ./script/generate scaffold thing name:string mood:string"
|
63
|
+
|
47
64
|
FileUtils.mkdir_p("test/rails/vendor/plugins")
|
48
65
|
spreadhead_root = File.expand_path(File.dirname(__FILE__))
|
49
66
|
system("ln -s #{spreadhead_root} test/rails/vendor/plugins/spreadhead")
|
50
67
|
end
|
68
|
+
|
69
|
+
desc "Prepares the application with clearance"
|
70
|
+
task :clearance do
|
71
|
+
system "echo \"config.gem 'thoughtbot-clearance', :lib => 'clearance'\" >> test/rails/config/environments/test.rb"
|
72
|
+
system "echo \"HOST = 'spreadhead'\" >> test/rails/config/environments/test.rb"
|
73
|
+
system "echo \"DO_NOT_REPLY = 'donotreply'\" >> test/rails/config/environments/test.rb"
|
74
|
+
system "cd test/rails && ./script/generate clearance && rake db:migrate db:test:prepare"
|
75
|
+
end
|
76
|
+
|
77
|
+
desc "Prepares the application with an alternate database"
|
78
|
+
task :database do
|
79
|
+
puts "== Configuring the database =================================================="
|
80
|
+
system "cp config/database.yml.sample test/rails/config/database.yml"
|
81
|
+
system "cd test/rails && rake db:migrate:reset"
|
82
|
+
end
|
51
83
|
|
52
84
|
desc "Run the spreadhead generator"
|
53
85
|
task :spreadhead do
|
54
86
|
system "cd test/rails && ./script/generate spreadhead && rake db:migrate db:test:prepare"
|
55
87
|
end
|
88
|
+
|
56
89
|
end
|
57
90
|
|
58
91
|
task :default => :test
|
@@ -72,5 +105,4 @@ Rake::RDocTask.new do |rdoc|
|
|
72
105
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
73
106
|
rdoc.rdoc_files.include('app/**/*.rb')
|
74
107
|
rdoc.rdoc_files.include('generators/**/*.rb')
|
75
|
-
end
|
76
|
-
|
108
|
+
end
|
data/TUTORIAL.textile
CHANGED
@@ -13,7 +13,9 @@ By default this should install the RedCloth gem, the BlueCloth gem, and the rsl-
|
|
13
13
|
Rails::Initializer.run do |config|
|
14
14
|
# Specify gems that this application depends on and have them installed with
|
15
15
|
# rake gems:install
|
16
|
-
config.gem "spreadhead",
|
16
|
+
config.gem "jeffrafter-spreadhead",
|
17
|
+
:lib => 'spreadhead',
|
18
|
+
:source => 'http://gems.github.com'
|
17
19
|
|
18
20
|
# Skip frameworks you're not going to use. To use Rails without a database,
|
19
21
|
# you must remove the Active Record framework.
|
@@ -48,7 +50,7 @@ To enable the application you need to modify initializer, where you can control
|
|
48
50
|
module Spreadhead
|
49
51
|
module PagesAuth
|
50
52
|
def self.filter(controller)
|
51
|
-
controller.
|
53
|
+
controller.send(:redirect_to, '/') unless controller.send(:signed_in?)
|
52
54
|
end
|
53
55
|
end
|
54
56
|
end
|
@@ -62,7 +64,7 @@ If you give everyone access, this is probably still a bad idea and you will want
|
|
62
64
|
module Spreadhead
|
63
65
|
module PagesAuth
|
64
66
|
def self.filter(controller)
|
65
|
-
controller.
|
67
|
+
controller.send(:redirect_to, '/') unless controller.send(:admin?)
|
66
68
|
end
|
67
69
|
end
|
68
70
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.6.
|
1
|
+
0.6.2
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# This file is not copied to or used by your rails environment. The only time
|
2
|
+
# these settings are used is when you have executed rake test:database. This
|
3
|
+
# file makes it easy to test alternate database drivers with Spreadhead. The
|
4
|
+
# default testing environment uses the rails default (sqlite3).
|
5
|
+
development:
|
6
|
+
adapter: mysql
|
7
|
+
database: spreadhead_development
|
8
|
+
username: root
|
9
|
+
password:
|
10
|
+
host: localhost
|
11
|
+
|
12
|
+
test:
|
13
|
+
adapter: mysql
|
14
|
+
database: spreadhead_test
|
15
|
+
username: root
|
16
|
+
password:
|
17
|
+
host: localhost
|
@@ -1,8 +1,8 @@
|
|
1
1
|
class SpreadheadCreatePages < ActiveRecord::Migration
|
2
2
|
def self.up
|
3
3
|
create_table(:pages) do |t|
|
4
|
+
t.text :text, :null => false
|
4
5
|
t.string :url, :null => false
|
5
|
-
t.string :text, :null => false
|
6
6
|
t.string :title, :null => false
|
7
7
|
t.string :keywords
|
8
8
|
t.string :description
|
@@ -3,8 +3,8 @@ class SpreadheadUpdatePages < ActiveRecord::Migration
|
|
3
3
|
<%
|
4
4
|
existing_columns = ActiveRecord::Base.connection.columns(:pages).collect { |each| each.name }
|
5
5
|
columns = [
|
6
|
+
[:text, 't.text :text, :null => false'],
|
6
7
|
[:url, 't.string :url, :null => false'],
|
7
|
-
[:text, 't.string :text, :null => false'],
|
8
8
|
[:title, 't.string :title, :null => false'],
|
9
9
|
[:keywords, 't.string :keywords'],
|
10
10
|
[:description, 't.string :description'],
|
data/lib/spreadhead/render.rb
CHANGED
@@ -2,10 +2,14 @@ require 'active_record/fixtures'
|
|
2
2
|
|
3
3
|
namespace :spreadhead do
|
4
4
|
desc "Export a set of fixtures from the current database pages"
|
5
|
-
task :export => [:environment] do
|
5
|
+
task :export => [:environment] do |tasks, args|
|
6
6
|
data = File.join(RAILS_ROOT, 'db', 'data')
|
7
7
|
Dir.mkdir(data) unless File.exists?(data)
|
8
|
-
|
8
|
+
if args.revisions
|
9
|
+
Page.to_fixtures(data);
|
10
|
+
else
|
11
|
+
Page.current.to_fixtures(data)
|
12
|
+
end
|
9
13
|
end
|
10
14
|
|
11
15
|
desc "Import a set of page fixtures into the current database (overwrites existing pages)"
|
@@ -114,5 +114,48 @@ class PagesControllerTest < ActionController::TestCase
|
|
114
114
|
end
|
115
115
|
|
116
116
|
end
|
117
|
+
|
118
|
+
context "routes" do
|
119
|
+
|
120
|
+
should "recognize the page resources" do
|
121
|
+
assert_recognizes({:controller => 'spreadhead/pages', :action => 'index'}, {:path => '/pages', :method => :get})
|
122
|
+
assert_recognizes({:controller => 'spreadhead/pages', :action => 'new'}, {:path => '/pages/new', :method => :get})
|
123
|
+
assert_recognizes({:controller => 'spreadhead/pages', :action => 'create'}, {:path => '/pages', :method => :post})
|
124
|
+
assert_recognizes({:controller => 'spreadhead/pages', :id => '1', :action => 'destroy'}, {:path => '/pages/1', :method => :delete})
|
125
|
+
assert_recognizes({:controller => 'spreadhead/pages', :id => '1', :action => 'update'}, {:path => '/pages/1', :method => :put})
|
126
|
+
assert_recognizes({:controller => 'spreadhead/pages', :id => '1', :action => 'edit'}, {:path => '/pages/1/edit', :method => :get})
|
127
|
+
end
|
128
|
+
|
129
|
+
should "recognize the about path" do
|
130
|
+
assert_recognizes({:controller => 'spreadhead/pages', :action => 'show', :url => ['about']}, {:path => '/about', :method => :get})
|
131
|
+
end
|
132
|
+
|
133
|
+
should "recognize the privacy path" do
|
134
|
+
assert_recognizes({:controller => 'spreadhead/pages', :action => 'show', :url => ['about', 'privacy']}, {:path => '/about/privacy', :method => :get})
|
135
|
+
end
|
136
|
+
|
137
|
+
should "recognize the birthday path" do
|
138
|
+
assert_recognizes({:controller => 'spreadhead/pages', :action => 'show', :url => ['2004', '09', '13', 'birthday']}, {:path => '/2004/09/13/birthday', :method => :get})
|
139
|
+
end
|
140
|
+
|
141
|
+
should "recognize the root path" do
|
142
|
+
assert_recognizes({:controller => 'spreadhead/pages', :action => 'show', :url => []}, {:path => '/', :method => :get})
|
143
|
+
end
|
144
|
+
|
145
|
+
should "not override the things" do
|
146
|
+
assert_recognizes({:controller => 'things', :action => 'index'}, {:path => '/things', :method => :get})
|
147
|
+
assert_recognizes({:controller => 'things', :action => 'new'}, {:path => '/things/new', :method => :get})
|
148
|
+
assert_recognizes({:controller => 'things', :action => 'create'}, {:path => '/things', :method => :post})
|
149
|
+
assert_recognizes({:controller => 'things', :id => '1', :action => 'destroy'}, {:path => '/things/1', :method => :delete})
|
150
|
+
assert_recognizes({:controller => 'things', :id => '1', :action => 'update'}, {:path => '/things/1', :method => :put})
|
151
|
+
assert_recognizes({:controller => 'things', :id => '1', :action => 'edit'}, {:path => '/things/1/edit', :method => :get})
|
152
|
+
end
|
153
|
+
|
154
|
+
if defined?(Clearance)
|
155
|
+
should "not override clearance paths" do
|
156
|
+
assert_recognizes({:controller => 'sessions', :action => 'new'}, {:path => '/session/new', :method => :get})
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
117
160
|
end
|
118
161
|
end
|
data/test/models/page_test.rb
CHANGED
@@ -56,7 +56,21 @@ class PageTest < ActiveSupport::TestCase
|
|
56
56
|
assert dup.update_attributes(:url => nil)
|
57
57
|
assert_equal 'woo', dup.url
|
58
58
|
end
|
59
|
-
|
59
|
+
|
60
|
+
should "allow text to be longer than two-hundred-and-fifty-five characters" do
|
61
|
+
text = <<EOF
|
62
|
+
<h3>3.</h3>
|
63
|
+
<h1>A Quick (and Hopefully Painless) Ride Through Ruby (with Cartoon Foxes)</h1>
|
64
|
+
<p><img src="i/the.foxes-1.png" title="The foxes show up." alt="The foxes show up." /></p>
|
65
|
+
<p>Yeah, these are the two. My asthma’s kickin in so I’ve got to go take a puff of medicated air just now. Be with you in a moment.</p>
|
66
|
+
<p><img src="i/the.foxes-2.png" title="Foxes in boxes." alt="Foxes in boxes." /></p>
|
67
|
+
<p>I’m told that this chapter is best accompanied by a rag. Something you can mop your face with as the sweat pours off your face.</p>
|
68
|
+
<p>Indeed, we’ll be racing through the whole language. Like striking every match in a box as quickly as can be done.</p>
|
69
|
+
EOF
|
70
|
+
page = Factory(:page, :title => '_why', :url => 'poignant-guide', :text => text)
|
71
|
+
page.reload
|
72
|
+
assert_equal text, page.text
|
73
|
+
end
|
60
74
|
end
|
61
75
|
|
62
76
|
context "When retrieving a page" do
|
data/test/test_helper.rb
CHANGED
@@ -1,4 +1,18 @@
|
|
1
|
+
ENV["RAILS_ENV"] = "test"
|
1
2
|
require File.expand_path(File.dirname(__FILE__) + "/rails/config/environment")
|
2
3
|
require 'test_help'
|
3
4
|
require 'factory_girl'
|
4
|
-
require 'shoulda'
|
5
|
+
require 'shoulda'
|
6
|
+
|
7
|
+
if defined?(Clearance)
|
8
|
+
require 'clearance/../../shoulda_macros/clearance'
|
9
|
+
end
|
10
|
+
|
11
|
+
# Name the root_url for testing
|
12
|
+
ActionController::Routing::Routes.add_named_route('root', '/', :controller => 'spreadhead/pages', :action => 'show')
|
13
|
+
|
14
|
+
class ActiveSupport::TestCase
|
15
|
+
self.use_transactional_fixtures = true
|
16
|
+
self.use_instantiated_fixtures = false
|
17
|
+
fixtures :all
|
18
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spreadhead
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.2
|
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-
|
12
|
+
date: 2009-09-07 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - ">="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version:
|
23
|
+
version: 1.0.0
|
24
24
|
version:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: RedCloth
|
@@ -30,7 +30,7 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 4.1.1
|
34
34
|
version:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: rsl-stringex
|
@@ -40,7 +40,7 @@ dependencies:
|
|
40
40
|
requirements:
|
41
41
|
- - ">="
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version:
|
43
|
+
version: 1.0.2
|
44
44
|
version:
|
45
45
|
description: Rails content mangement for pages that shouldn't be views.
|
46
46
|
email: jeff@socialrange.org
|
@@ -65,6 +65,7 @@ files:
|
|
65
65
|
- app/views/spreadhead/pages/index.html.erb
|
66
66
|
- app/views/spreadhead/pages/new.html.erb
|
67
67
|
- app/views/spreadhead/pages/show.html.erb
|
68
|
+
- config/database.yml.sample
|
68
69
|
- config/spreadhead_routes.rb
|
69
70
|
- generators/spreadhead/USAGE
|
70
71
|
- generators/spreadhead/lib/insert_commands.rb
|