publish 0.0.1 → 0.0.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/Gemfile +3 -1
- data/Gemfile.lock +44 -44
- data/README.rdoc +5 -4
- data/lib/mongoid/publish.rb +6 -3
- data/lib/mongoid/version.rb +1 -1
- data/publish.gemspec +2 -2
- data/test/dummy/app/controllers/posts_controller.rb +83 -0
- data/test/dummy/app/helpers/posts_helper.rb +2 -0
- data/test/dummy/app/views/posts/_form.html.erb +36 -0
- data/test/dummy/app/views/posts/edit.html.erb +6 -0
- data/test/dummy/app/views/posts/index.html.erb +27 -0
- data/test/dummy/app/views/posts/new.html.erb +5 -0
- data/test/dummy/app/views/posts/show.html.erb +22 -0
- data/test/dummy/config/routes.rb +4 -57
- data/test/dummy/public/stylesheets/scaffold.css +56 -0
- data/test/publish/mongoid/post_test.rb +18 -0
- metadata +21 -18
data/Gemfile
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
source "http://rubygems.org"
|
|
2
2
|
|
|
3
|
-
gem "rails", "3.0.
|
|
3
|
+
gem "rails", "3.0.9"
|
|
4
4
|
gem "capybara", ">= 0.4.0"
|
|
5
5
|
|
|
6
6
|
gem 'simplecov', :require => false
|
|
@@ -8,6 +8,8 @@ gem 'factory_girl_rails'
|
|
|
8
8
|
gem 'ffaker'
|
|
9
9
|
gem 'colorific'
|
|
10
10
|
|
|
11
|
+
gem "mongoid"
|
|
12
|
+
|
|
11
13
|
# To use debugger (ruby-debug for Ruby 1.8.7+, ruby-debug19 for Ruby 1.9.2+)
|
|
12
14
|
# gem 'ruby-debug'
|
|
13
15
|
# gem 'ruby-debug19'
|
data/Gemfile.lock
CHANGED
|
@@ -2,42 +2,41 @@ PATH
|
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
4
|
publish (0.0.1)
|
|
5
|
-
bson_ext (~> 1.3
|
|
6
|
-
mongoid (~> 2.0.1)
|
|
5
|
+
bson_ext (~> 1.3)
|
|
7
6
|
|
|
8
7
|
GEM
|
|
9
8
|
remote: http://rubygems.org/
|
|
10
9
|
specs:
|
|
11
10
|
abstract (1.0.0)
|
|
12
|
-
actionmailer (3.0.
|
|
13
|
-
actionpack (= 3.0.
|
|
14
|
-
mail (~> 2.2.
|
|
15
|
-
actionpack (3.0.
|
|
16
|
-
activemodel (= 3.0.
|
|
17
|
-
activesupport (= 3.0.
|
|
11
|
+
actionmailer (3.0.9)
|
|
12
|
+
actionpack (= 3.0.9)
|
|
13
|
+
mail (~> 2.2.19)
|
|
14
|
+
actionpack (3.0.9)
|
|
15
|
+
activemodel (= 3.0.9)
|
|
16
|
+
activesupport (= 3.0.9)
|
|
18
17
|
builder (~> 2.1.2)
|
|
19
18
|
erubis (~> 2.6.6)
|
|
20
|
-
i18n (~> 0.
|
|
19
|
+
i18n (~> 0.5.0)
|
|
21
20
|
rack (~> 1.2.1)
|
|
22
|
-
rack-mount (~> 0.6.
|
|
21
|
+
rack-mount (~> 0.6.14)
|
|
23
22
|
rack-test (~> 0.5.7)
|
|
24
23
|
tzinfo (~> 0.3.23)
|
|
25
|
-
activemodel (3.0.
|
|
26
|
-
activesupport (= 3.0.
|
|
24
|
+
activemodel (3.0.9)
|
|
25
|
+
activesupport (= 3.0.9)
|
|
27
26
|
builder (~> 2.1.2)
|
|
28
|
-
i18n (~> 0.
|
|
29
|
-
activerecord (3.0.
|
|
30
|
-
activemodel (= 3.0.
|
|
31
|
-
activesupport (= 3.0.
|
|
32
|
-
arel (~> 2.0.
|
|
27
|
+
i18n (~> 0.5.0)
|
|
28
|
+
activerecord (3.0.9)
|
|
29
|
+
activemodel (= 3.0.9)
|
|
30
|
+
activesupport (= 3.0.9)
|
|
31
|
+
arel (~> 2.0.10)
|
|
33
32
|
tzinfo (~> 0.3.23)
|
|
34
|
-
activeresource (3.0.
|
|
35
|
-
activemodel (= 3.0.
|
|
36
|
-
activesupport (= 3.0.
|
|
37
|
-
activesupport (3.0.
|
|
38
|
-
arel (2.0.
|
|
39
|
-
bson (1.3.
|
|
40
|
-
bson_ext (1.3.
|
|
33
|
+
activeresource (3.0.9)
|
|
34
|
+
activemodel (= 3.0.9)
|
|
35
|
+
activesupport (= 3.0.9)
|
|
36
|
+
activesupport (3.0.9)
|
|
37
|
+
arel (2.0.10)
|
|
38
|
+
bson (1.3.1)
|
|
39
|
+
bson_ext (1.3.1)
|
|
41
40
|
builder (2.1.2)
|
|
42
41
|
capybara (0.4.1.2)
|
|
43
42
|
celerity (>= 0.7.9)
|
|
@@ -66,41 +65,42 @@ GEM
|
|
|
66
65
|
rake (>= 0.8.7)
|
|
67
66
|
i18n (0.5.0)
|
|
68
67
|
json_pure (1.5.1)
|
|
69
|
-
mail (2.2.
|
|
68
|
+
mail (2.2.19)
|
|
70
69
|
activesupport (>= 2.3.6)
|
|
71
70
|
i18n (>= 0.4.0)
|
|
72
71
|
mime-types (~> 1.16)
|
|
73
72
|
treetop (~> 1.4.8)
|
|
74
73
|
mime-types (1.16)
|
|
75
74
|
minitest (2.0.2)
|
|
76
|
-
mongo (1.3.
|
|
77
|
-
bson (>= 1.3.
|
|
78
|
-
mongoid (2.0.
|
|
75
|
+
mongo (1.3.1)
|
|
76
|
+
bson (>= 1.3.1)
|
|
77
|
+
mongoid (2.0.2)
|
|
79
78
|
activemodel (~> 3.0)
|
|
80
79
|
mongo (~> 1.3)
|
|
81
80
|
tzinfo (~> 0.3.22)
|
|
82
|
-
will_paginate (~> 3.0.pre)
|
|
83
81
|
nokogiri (1.4.4)
|
|
84
82
|
polyglot (0.3.1)
|
|
85
|
-
rack (1.2.
|
|
83
|
+
rack (1.2.3)
|
|
86
84
|
rack-mount (0.6.14)
|
|
87
85
|
rack (>= 1.0.0)
|
|
88
86
|
rack-test (0.5.7)
|
|
89
87
|
rack (>= 1.0)
|
|
90
|
-
rails (3.0.
|
|
91
|
-
actionmailer (= 3.0.
|
|
92
|
-
actionpack (= 3.0.
|
|
93
|
-
activerecord (= 3.0.
|
|
94
|
-
activeresource (= 3.0.
|
|
95
|
-
activesupport (= 3.0.
|
|
88
|
+
rails (3.0.9)
|
|
89
|
+
actionmailer (= 3.0.9)
|
|
90
|
+
actionpack (= 3.0.9)
|
|
91
|
+
activerecord (= 3.0.9)
|
|
92
|
+
activeresource (= 3.0.9)
|
|
93
|
+
activesupport (= 3.0.9)
|
|
96
94
|
bundler (~> 1.0)
|
|
97
|
-
railties (= 3.0.
|
|
98
|
-
railties (3.0.
|
|
99
|
-
actionpack (= 3.0.
|
|
100
|
-
activesupport (= 3.0.
|
|
95
|
+
railties (= 3.0.9)
|
|
96
|
+
railties (3.0.9)
|
|
97
|
+
actionpack (= 3.0.9)
|
|
98
|
+
activesupport (= 3.0.9)
|
|
101
99
|
rake (>= 0.8.7)
|
|
100
|
+
rdoc (~> 3.4)
|
|
102
101
|
thor (~> 0.14.4)
|
|
103
|
-
rake (0.
|
|
102
|
+
rake (0.9.2)
|
|
103
|
+
rdoc (3.8)
|
|
104
104
|
ruby-progressbar (0.0.9)
|
|
105
105
|
rubyzip (0.9.4)
|
|
106
106
|
selenium-webdriver (0.1.4)
|
|
@@ -114,8 +114,7 @@ GEM
|
|
|
114
114
|
thor (0.14.6)
|
|
115
115
|
treetop (1.4.9)
|
|
116
116
|
polyglot (>= 0.3.1)
|
|
117
|
-
tzinfo (0.3.
|
|
118
|
-
will_paginate (3.0.pre2)
|
|
117
|
+
tzinfo (0.3.29)
|
|
119
118
|
xpath (0.1.3)
|
|
120
119
|
nokogiri (~> 1.3)
|
|
121
120
|
|
|
@@ -127,6 +126,7 @@ DEPENDENCIES
|
|
|
127
126
|
colorific
|
|
128
127
|
factory_girl_rails
|
|
129
128
|
ffaker
|
|
129
|
+
mongoid
|
|
130
130
|
publish!
|
|
131
|
-
rails (= 3.0.
|
|
131
|
+
rails (= 3.0.9)
|
|
132
132
|
simplecov
|
data/README.rdoc
CHANGED
|
@@ -7,7 +7,7 @@ Now, supports just Mongoid. Support to Activerecord is comming soon.
|
|
|
7
7
|
|
|
8
8
|
Add to Gemfile
|
|
9
9
|
|
|
10
|
-
gem 'publish',
|
|
10
|
+
gem 'publish', '0.0.1'
|
|
11
11
|
|
|
12
12
|
Then run
|
|
13
13
|
|
|
@@ -32,9 +32,10 @@ Include Publish Module to your model
|
|
|
32
32
|
p.published? #false
|
|
33
33
|
p.published_at #nil
|
|
34
34
|
|
|
35
|
-
p.published = true
|
|
36
|
-
p.save
|
|
35
|
+
p.publish! #p.published = true
|
|
37
36
|
|
|
38
37
|
p.published? #true
|
|
39
38
|
|
|
40
|
-
Post.published.count #1
|
|
39
|
+
Post.published.count #1
|
|
40
|
+
|
|
41
|
+
p.publication_status #Date.today or 'draft'
|
data/lib/mongoid/publish.rb
CHANGED
|
@@ -5,6 +5,8 @@ module Mongoid
|
|
|
5
5
|
included do
|
|
6
6
|
field :published_at, :type => Date
|
|
7
7
|
field :published, :type => Boolean, :default => false
|
|
8
|
+
|
|
9
|
+
scope :published, where(:published => true, :published_at.lte => Date.today).desc(:published_at, :created_at)
|
|
8
10
|
|
|
9
11
|
before_save :set_published_at
|
|
10
12
|
end
|
|
@@ -23,6 +25,10 @@ module Mongoid
|
|
|
23
25
|
self.published_at = Date.today
|
|
24
26
|
self.save
|
|
25
27
|
end
|
|
28
|
+
|
|
29
|
+
def publication_status
|
|
30
|
+
self.published? ? self.published_at : "draft"
|
|
31
|
+
end
|
|
26
32
|
|
|
27
33
|
private
|
|
28
34
|
def set_published_at
|
|
@@ -31,9 +37,6 @@ module Mongoid
|
|
|
31
37
|
end
|
|
32
38
|
|
|
33
39
|
module ClassMethods
|
|
34
|
-
def published
|
|
35
|
-
where(:published => true, :published_at.lte => Date.today).desc(:published_at, :created_at)
|
|
36
|
-
end
|
|
37
40
|
end
|
|
38
41
|
|
|
39
42
|
end
|
data/lib/mongoid/version.rb
CHANGED
data/publish.gemspec
CHANGED
|
@@ -20,6 +20,6 @@ Gem::Specification.new do |s|
|
|
|
20
20
|
s.require_paths = ["lib"]
|
|
21
21
|
|
|
22
22
|
#s.add_dependency 'activesupport', '~> 3.0.5'
|
|
23
|
-
s.add_dependency 'mongoid', '~> 2.0.1'
|
|
24
|
-
s.add_dependency 'bson_ext', '~> 1.3
|
|
23
|
+
#s.add_dependency 'mongoid', '~> 2.0.1'
|
|
24
|
+
s.add_dependency 'bson_ext', '~> 1.3'
|
|
25
25
|
end
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
class PostsController < ApplicationController
|
|
2
|
+
# GET /posts
|
|
3
|
+
# GET /posts.xml
|
|
4
|
+
def index
|
|
5
|
+
@posts = Post.all
|
|
6
|
+
|
|
7
|
+
respond_to do |format|
|
|
8
|
+
format.html # index.html.erb
|
|
9
|
+
format.xml { render :xml => @posts }
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# GET /posts/1
|
|
14
|
+
# GET /posts/1.xml
|
|
15
|
+
def show
|
|
16
|
+
@post = Post.find(params[:id])
|
|
17
|
+
|
|
18
|
+
respond_to do |format|
|
|
19
|
+
format.html # show.html.erb
|
|
20
|
+
format.xml { render :xml => @post }
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# GET /posts/new
|
|
25
|
+
# GET /posts/new.xml
|
|
26
|
+
def new
|
|
27
|
+
@post = Post.new
|
|
28
|
+
|
|
29
|
+
respond_to do |format|
|
|
30
|
+
format.html # new.html.erb
|
|
31
|
+
format.xml { render :xml => @post }
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# GET /posts/1/edit
|
|
36
|
+
def edit
|
|
37
|
+
@post = Post.find(params[:id])
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# POST /posts
|
|
41
|
+
# POST /posts.xml
|
|
42
|
+
def create
|
|
43
|
+
@post = Post.new(params[:post])
|
|
44
|
+
|
|
45
|
+
respond_to do |format|
|
|
46
|
+
if @post.save
|
|
47
|
+
format.html { redirect_to(@post, :notice => 'Post was successfully created.') }
|
|
48
|
+
format.xml { render :xml => @post, :status => :created, :location => @post }
|
|
49
|
+
else
|
|
50
|
+
format.html { render :action => "new" }
|
|
51
|
+
format.xml { render :xml => @post.errors, :status => :unprocessable_entity }
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# PUT /posts/1
|
|
57
|
+
# PUT /posts/1.xml
|
|
58
|
+
def update
|
|
59
|
+
@post = Post.find(params[:id])
|
|
60
|
+
|
|
61
|
+
respond_to do |format|
|
|
62
|
+
if @post.update_attributes(params[:post])
|
|
63
|
+
format.html { redirect_to(@post, :notice => 'Post was successfully updated.') }
|
|
64
|
+
format.xml { head :ok }
|
|
65
|
+
else
|
|
66
|
+
format.html { render :action => "edit" }
|
|
67
|
+
format.xml { render :xml => @post.errors, :status => :unprocessable_entity }
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# DELETE /posts/1
|
|
73
|
+
# DELETE /posts/1.xml
|
|
74
|
+
def destroy
|
|
75
|
+
@post = Post.find(params[:id])
|
|
76
|
+
@post.destroy
|
|
77
|
+
|
|
78
|
+
respond_to do |format|
|
|
79
|
+
format.html { redirect_to(posts_url) }
|
|
80
|
+
format.xml { head :ok }
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<%= form_for(@post) do |f| %>
|
|
2
|
+
<% if @post.errors.any? %>
|
|
3
|
+
<div id="error_explanation">
|
|
4
|
+
<h2><%= pluralize(@post.errors.count, "error") %> prohibited this post from being saved:</h2>
|
|
5
|
+
|
|
6
|
+
<ul>
|
|
7
|
+
<% @post.errors.full_messages.each do |msg| %>
|
|
8
|
+
<li><%= msg %></li>
|
|
9
|
+
<% end %>
|
|
10
|
+
</ul>
|
|
11
|
+
</div>
|
|
12
|
+
<% end %>
|
|
13
|
+
|
|
14
|
+
<div class="field">
|
|
15
|
+
<%= f.label :title %><br />
|
|
16
|
+
<%= f.text_field :title %>
|
|
17
|
+
</div>
|
|
18
|
+
<div class="field">
|
|
19
|
+
<%= f.label :text %><br />
|
|
20
|
+
<%= f.text_area :text %>
|
|
21
|
+
</div>
|
|
22
|
+
<div class="field">
|
|
23
|
+
<label>Status</label><br />
|
|
24
|
+
<%= f.radio_button :published, false %><%= f.label :published, " draft", :value => false %>
|
|
25
|
+
<br />
|
|
26
|
+
<%= f.radio_button :published, true %><%= f.label :published, " published", :value => true %>
|
|
27
|
+
</div>
|
|
28
|
+
<div class="field">
|
|
29
|
+
<%= f.label :published_at %><br />
|
|
30
|
+
<%= f.text_field :published_at %>
|
|
31
|
+
</div>
|
|
32
|
+
|
|
33
|
+
<div class="actions">
|
|
34
|
+
<%= f.submit %>
|
|
35
|
+
</div>
|
|
36
|
+
<% end %>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<h1>Listing posts</h1>
|
|
2
|
+
|
|
3
|
+
<table>
|
|
4
|
+
<tr>
|
|
5
|
+
<th>Title</th>
|
|
6
|
+
<th>Text</th>
|
|
7
|
+
<th>Status</th>
|
|
8
|
+
<th></th>
|
|
9
|
+
<th></th>
|
|
10
|
+
<th></th>
|
|
11
|
+
</tr>
|
|
12
|
+
|
|
13
|
+
<% @posts.each do |post| %>
|
|
14
|
+
<tr>
|
|
15
|
+
<td><%= post.title %></td>
|
|
16
|
+
<td><%= post.text %></td>
|
|
17
|
+
<td><%= post.publication_status %></td>
|
|
18
|
+
<td><%= link_to 'Show', post %></td>
|
|
19
|
+
<td><%= link_to 'Edit', edit_post_path(post) %></td>
|
|
20
|
+
<td><%= link_to 'Destroy', post, :confirm => 'Are you sure?', :method => :delete %></td>
|
|
21
|
+
</tr>
|
|
22
|
+
<% end %>
|
|
23
|
+
</table>
|
|
24
|
+
|
|
25
|
+
<br />
|
|
26
|
+
|
|
27
|
+
<%= link_to 'New Post', new_post_path %>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<p id="notice"><%= notice %></p>
|
|
2
|
+
|
|
3
|
+
<p>
|
|
4
|
+
<b>Title:</b>
|
|
5
|
+
<%= @post.title %>
|
|
6
|
+
</p>
|
|
7
|
+
|
|
8
|
+
<p>
|
|
9
|
+
<b>Text:</b>
|
|
10
|
+
<%= @post.text %>
|
|
11
|
+
</p>
|
|
12
|
+
|
|
13
|
+
<% if @post.published? %>
|
|
14
|
+
<p>
|
|
15
|
+
<b>Published at:</b>
|
|
16
|
+
<%= @post.published_at %>
|
|
17
|
+
</p>
|
|
18
|
+
<% end %>
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
<%= link_to 'Edit', edit_post_path(@post) %> |
|
|
22
|
+
<%= link_to 'Back', posts_path %>
|
data/test/dummy/config/routes.rb
CHANGED
|
@@ -1,58 +1,5 @@
|
|
|
1
1
|
Dummy::Application.routes.draw do
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
# match 'products/:id' => 'catalog#view'
|
|
7
|
-
# Keep in mind you can assign values other than :controller and :action
|
|
8
|
-
|
|
9
|
-
# Sample of named route:
|
|
10
|
-
# match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
|
|
11
|
-
# This route can be invoked with purchase_url(:id => product.id)
|
|
12
|
-
|
|
13
|
-
# Sample resource route (maps HTTP verbs to controller actions automatically):
|
|
14
|
-
# resources :products
|
|
15
|
-
|
|
16
|
-
# Sample resource route with options:
|
|
17
|
-
# resources :products do
|
|
18
|
-
# member do
|
|
19
|
-
# get 'short'
|
|
20
|
-
# post 'toggle'
|
|
21
|
-
# end
|
|
22
|
-
#
|
|
23
|
-
# collection do
|
|
24
|
-
# get 'sold'
|
|
25
|
-
# end
|
|
26
|
-
# end
|
|
27
|
-
|
|
28
|
-
# Sample resource route with sub-resources:
|
|
29
|
-
# resources :products do
|
|
30
|
-
# resources :comments, :sales
|
|
31
|
-
# resource :seller
|
|
32
|
-
# end
|
|
33
|
-
|
|
34
|
-
# Sample resource route with more complex sub-resources
|
|
35
|
-
# resources :products do
|
|
36
|
-
# resources :comments
|
|
37
|
-
# resources :sales do
|
|
38
|
-
# get 'recent', :on => :collection
|
|
39
|
-
# end
|
|
40
|
-
# end
|
|
41
|
-
|
|
42
|
-
# Sample resource route within a namespace:
|
|
43
|
-
# namespace :admin do
|
|
44
|
-
# # Directs /admin/products/* to Admin::ProductsController
|
|
45
|
-
# # (app/controllers/admin/products_controller.rb)
|
|
46
|
-
# resources :products
|
|
47
|
-
# end
|
|
48
|
-
|
|
49
|
-
# You can have the root of your site routed with "root"
|
|
50
|
-
# just remember to delete public/index.html.
|
|
51
|
-
# root :to => "welcome#index"
|
|
52
|
-
|
|
53
|
-
# See how all your routes lay out with "rake routes"
|
|
54
|
-
|
|
55
|
-
# This is a legacy wild controller route that's not recommended for RESTful applications.
|
|
56
|
-
# Note: This route will make all actions in every controller accessible via GET requests.
|
|
57
|
-
# match ':controller(/:action(/:id(.:format)))'
|
|
58
|
-
end
|
|
2
|
+
resources :posts
|
|
3
|
+
|
|
4
|
+
root :to => "posts#index"
|
|
5
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
body { background-color: #fff; color: #333; }
|
|
2
|
+
|
|
3
|
+
body, p, ol, ul, td {
|
|
4
|
+
font-family: verdana, arial, helvetica, sans-serif;
|
|
5
|
+
font-size: 13px;
|
|
6
|
+
line-height: 18px;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
pre {
|
|
10
|
+
background-color: #eee;
|
|
11
|
+
padding: 10px;
|
|
12
|
+
font-size: 11px;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
a { color: #000; }
|
|
16
|
+
a:visited { color: #666; }
|
|
17
|
+
a:hover { color: #fff; background-color:#000; }
|
|
18
|
+
|
|
19
|
+
div.field, div.actions {
|
|
20
|
+
margin-bottom: 10px;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
#notice {
|
|
24
|
+
color: green;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.field_with_errors {
|
|
28
|
+
padding: 2px;
|
|
29
|
+
background-color: red;
|
|
30
|
+
display: table;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
#error_explanation {
|
|
34
|
+
width: 450px;
|
|
35
|
+
border: 2px solid red;
|
|
36
|
+
padding: 7px;
|
|
37
|
+
padding-bottom: 0;
|
|
38
|
+
margin-bottom: 20px;
|
|
39
|
+
background-color: #f0f0f0;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
#error_explanation h2 {
|
|
43
|
+
text-align: left;
|
|
44
|
+
font-weight: bold;
|
|
45
|
+
padding: 5px 5px 5px 15px;
|
|
46
|
+
font-size: 12px;
|
|
47
|
+
margin: -7px;
|
|
48
|
+
margin-bottom: 0px;
|
|
49
|
+
background-color: #c00;
|
|
50
|
+
color: #fff;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
#error_explanation ul li {
|
|
54
|
+
font-size: 12px;
|
|
55
|
+
list-style: square;
|
|
56
|
+
}
|
|
@@ -46,5 +46,23 @@ class PostTest < ActiveSupport::TestCase
|
|
|
46
46
|
assert post.published?
|
|
47
47
|
assert_equal Post.published.size, 1
|
|
48
48
|
end
|
|
49
|
+
|
|
50
|
+
test "should concat with criteria methods" do
|
|
51
|
+
Factory.create(:post, :published => true, :title => "normal post")
|
|
52
|
+
Factory.create(:post, :published => true, :title => "my special post")
|
|
53
|
+
|
|
54
|
+
assert_equal Post.where(:title => /special/).published.count, 1
|
|
55
|
+
assert_equal Post.published.where(:title => /special/).count, 1
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
test "should return publication status as draft if is not published yet" do
|
|
59
|
+
assert_equal Post.last.publication_status, "draft"
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
test "should return published at date if is published" do
|
|
63
|
+
@post.publish!
|
|
64
|
+
|
|
65
|
+
assert_equal Post.last.publication_status, Date.today
|
|
66
|
+
end
|
|
49
67
|
|
|
50
68
|
end
|
metadata
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name: publish
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease:
|
|
5
|
-
version: 0.0.
|
|
5
|
+
version: 0.0.2
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
8
8
|
- Lucas Renan
|
|
@@ -11,31 +11,19 @@ autorequire:
|
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain: []
|
|
13
13
|
|
|
14
|
-
date: 2011-
|
|
15
|
-
default_executable:
|
|
14
|
+
date: 2011-08-31 00:00:00 Z
|
|
16
15
|
dependencies:
|
|
17
16
|
- !ruby/object:Gem::Dependency
|
|
18
|
-
name:
|
|
17
|
+
name: bson_ext
|
|
19
18
|
prerelease: false
|
|
20
19
|
requirement: &id001 !ruby/object:Gem::Requirement
|
|
21
20
|
none: false
|
|
22
21
|
requirements:
|
|
23
22
|
- - ~>
|
|
24
23
|
- !ruby/object:Gem::Version
|
|
25
|
-
version:
|
|
24
|
+
version: "1.3"
|
|
26
25
|
type: :runtime
|
|
27
26
|
version_requirements: *id001
|
|
28
|
-
- !ruby/object:Gem::Dependency
|
|
29
|
-
name: bson_ext
|
|
30
|
-
prerelease: false
|
|
31
|
-
requirement: &id002 !ruby/object:Gem::Requirement
|
|
32
|
-
none: false
|
|
33
|
-
requirements:
|
|
34
|
-
- - ~>
|
|
35
|
-
- !ruby/object:Gem::Version
|
|
36
|
-
version: 1.3.0
|
|
37
|
-
type: :runtime
|
|
38
|
-
version_requirements: *id002
|
|
39
27
|
description: Adds the functionality to publish/unpublish
|
|
40
28
|
email:
|
|
41
29
|
- contato@lucasrenan.com
|
|
@@ -59,9 +47,16 @@ files:
|
|
|
59
47
|
- publish.gemspec
|
|
60
48
|
- test/dummy/Rakefile
|
|
61
49
|
- test/dummy/app/controllers/application_controller.rb
|
|
50
|
+
- test/dummy/app/controllers/posts_controller.rb
|
|
62
51
|
- test/dummy/app/helpers/application_helper.rb
|
|
52
|
+
- test/dummy/app/helpers/posts_helper.rb
|
|
63
53
|
- test/dummy/app/models/post.rb
|
|
64
54
|
- test/dummy/app/views/layouts/application.html.erb
|
|
55
|
+
- test/dummy/app/views/posts/_form.html.erb
|
|
56
|
+
- test/dummy/app/views/posts/edit.html.erb
|
|
57
|
+
- test/dummy/app/views/posts/index.html.erb
|
|
58
|
+
- test/dummy/app/views/posts/new.html.erb
|
|
59
|
+
- test/dummy/app/views/posts/show.html.erb
|
|
65
60
|
- test/dummy/config.ru
|
|
66
61
|
- test/dummy/config/application.rb
|
|
67
62
|
- test/dummy/config/boot.rb
|
|
@@ -88,6 +83,7 @@ files:
|
|
|
88
83
|
- test/dummy/public/javascripts/prototype.js
|
|
89
84
|
- test/dummy/public/javascripts/rails.js
|
|
90
85
|
- test/dummy/public/stylesheets/.gitkeep
|
|
86
|
+
- test/dummy/public/stylesheets/scaffold.css
|
|
91
87
|
- test/dummy/script/rails
|
|
92
88
|
- test/factories/posts.rb
|
|
93
89
|
- test/integration/navigation_test.rb
|
|
@@ -95,7 +91,6 @@ files:
|
|
|
95
91
|
- test/publish_test.rb
|
|
96
92
|
- test/support/integration_case.rb
|
|
97
93
|
- test/test_helper.rb
|
|
98
|
-
has_rdoc: true
|
|
99
94
|
homepage: https://github.com/lucasrenan/publish
|
|
100
95
|
licenses: []
|
|
101
96
|
|
|
@@ -119,16 +114,23 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
119
114
|
requirements: []
|
|
120
115
|
|
|
121
116
|
rubyforge_project: publish
|
|
122
|
-
rubygems_version: 1.
|
|
117
|
+
rubygems_version: 1.8.10
|
|
123
118
|
signing_key:
|
|
124
119
|
specification_version: 3
|
|
125
120
|
summary: Adds the functionality to publish/unpublish
|
|
126
121
|
test_files:
|
|
127
122
|
- test/dummy/Rakefile
|
|
128
123
|
- test/dummy/app/controllers/application_controller.rb
|
|
124
|
+
- test/dummy/app/controllers/posts_controller.rb
|
|
129
125
|
- test/dummy/app/helpers/application_helper.rb
|
|
126
|
+
- test/dummy/app/helpers/posts_helper.rb
|
|
130
127
|
- test/dummy/app/models/post.rb
|
|
131
128
|
- test/dummy/app/views/layouts/application.html.erb
|
|
129
|
+
- test/dummy/app/views/posts/_form.html.erb
|
|
130
|
+
- test/dummy/app/views/posts/edit.html.erb
|
|
131
|
+
- test/dummy/app/views/posts/index.html.erb
|
|
132
|
+
- test/dummy/app/views/posts/new.html.erb
|
|
133
|
+
- test/dummy/app/views/posts/show.html.erb
|
|
132
134
|
- test/dummy/config.ru
|
|
133
135
|
- test/dummy/config/application.rb
|
|
134
136
|
- test/dummy/config/boot.rb
|
|
@@ -155,6 +157,7 @@ test_files:
|
|
|
155
157
|
- test/dummy/public/javascripts/prototype.js
|
|
156
158
|
- test/dummy/public/javascripts/rails.js
|
|
157
159
|
- test/dummy/public/stylesheets/.gitkeep
|
|
160
|
+
- test/dummy/public/stylesheets/scaffold.css
|
|
158
161
|
- test/dummy/script/rails
|
|
159
162
|
- test/factories/posts.rb
|
|
160
163
|
- test/integration/navigation_test.rb
|