publish 0.0.6 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +1 -4
- data/CHANGELOG.md +15 -0
- data/Gemfile +3 -15
- data/Gemfile.lock +104 -82
- data/README.md +43 -0
- data/lib/mongoid/publish/version.rb +1 -1
- data/publish.gemspec +21 -16
- data/test/dummy/app/views/layouts/application.html.erb +2 -2
- data/test/dummy/config/application.rb +0 -1
- data/test/dummy/config/environments/development.rb +8 -4
- data/test/dummy/config/environments/test.rb +8 -9
- data/test/dummy/config/mongoid.yml +65 -20
- data/test/publish/mongoid/post_test.rb +9 -9
- data/test/support/factories/posts.rb +5 -3
- data/test/test_helper.rb +5 -10
- metadata +99 -13
- data/README.rdoc +0 -41
- data/test/dummy/config/environments/production.rb +0 -49
data/.travis.yml
CHANGED
data/CHANGELOG.md
ADDED
data/Gemfile
CHANGED
@@ -1,18 +1,6 @@
|
|
1
1
|
source "http://rubygems.org"
|
2
2
|
|
3
|
-
|
4
|
-
gem "capybara"
|
3
|
+
gemspec
|
5
4
|
|
6
|
-
gem "
|
7
|
-
|
8
|
-
gem "simplecov", :require => false
|
9
|
-
gem "factory_girl_rails"
|
10
|
-
gem "ffaker"
|
11
|
-
gem "colorific"
|
12
|
-
|
13
|
-
|
14
|
-
# To use debugger (ruby-debug for Ruby 1.8.7+, ruby-debug19 for Ruby 1.9.2+)
|
15
|
-
# gem "ruby-debug"
|
16
|
-
# gem "ruby-debug19"
|
17
|
-
|
18
|
-
gemspec
|
5
|
+
gem "factory_girl_rails", "~> 3.5.0"
|
6
|
+
gem "colorific", "~> 1.0.2"
|
data/Gemfile.lock
CHANGED
@@ -1,44 +1,42 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
publish (0.0.
|
5
|
-
mongoid (
|
4
|
+
publish (0.0.6)
|
5
|
+
mongoid (~> 3.0.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: http://rubygems.org/
|
9
9
|
specs:
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
rack (~> 1.2
|
21
|
-
rack-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
bson (= 1.6.0)
|
41
|
-
builder (2.1.2)
|
10
|
+
actionmailer (3.2.6)
|
11
|
+
actionpack (= 3.2.6)
|
12
|
+
mail (~> 2.4.4)
|
13
|
+
actionpack (3.2.6)
|
14
|
+
activemodel (= 3.2.6)
|
15
|
+
activesupport (= 3.2.6)
|
16
|
+
builder (~> 3.0.0)
|
17
|
+
erubis (~> 2.7.0)
|
18
|
+
journey (~> 1.0.1)
|
19
|
+
rack (~> 1.4.0)
|
20
|
+
rack-cache (~> 1.2)
|
21
|
+
rack-test (~> 0.6.1)
|
22
|
+
sprockets (~> 2.1.3)
|
23
|
+
activemodel (3.2.6)
|
24
|
+
activesupport (= 3.2.6)
|
25
|
+
builder (~> 3.0.0)
|
26
|
+
activerecord (3.2.6)
|
27
|
+
activemodel (= 3.2.6)
|
28
|
+
activesupport (= 3.2.6)
|
29
|
+
arel (~> 3.0.2)
|
30
|
+
tzinfo (~> 0.3.29)
|
31
|
+
activeresource (3.2.6)
|
32
|
+
activemodel (= 3.2.6)
|
33
|
+
activesupport (= 3.2.6)
|
34
|
+
activesupport (3.2.6)
|
35
|
+
i18n (~> 0.6)
|
36
|
+
multi_json (~> 1.0)
|
37
|
+
addressable (2.2.8)
|
38
|
+
arel (3.0.2)
|
39
|
+
builder (3.0.0)
|
42
40
|
capybara (1.1.2)
|
43
41
|
mime-types (>= 1.16)
|
44
42
|
nokogiri (>= 1.3.3)
|
@@ -46,76 +44,100 @@ GEM
|
|
46
44
|
rack-test (>= 0.5.4)
|
47
45
|
selenium-webdriver (~> 2.0)
|
48
46
|
xpath (~> 0.1.4)
|
49
|
-
childprocess (0.3.
|
47
|
+
childprocess (0.3.3)
|
50
48
|
ffi (~> 1.0.6)
|
51
49
|
colorific (1.0.2)
|
52
50
|
minitest (~> 2.8.0)
|
53
51
|
ruby-progressbar (~> 0.0.10)
|
54
|
-
|
55
|
-
|
56
|
-
factory_girl (
|
57
|
-
activesupport (>=
|
58
|
-
factory_girl_rails (
|
59
|
-
factory_girl (~>
|
52
|
+
diff-lcs (1.1.3)
|
53
|
+
erubis (2.7.0)
|
54
|
+
factory_girl (3.5.0)
|
55
|
+
activesupport (>= 3.0.0)
|
56
|
+
factory_girl_rails (3.5.0)
|
57
|
+
factory_girl (~> 3.5.0)
|
60
58
|
railties (>= 3.0.0)
|
61
|
-
ffaker (1.13.0)
|
62
59
|
ffi (1.0.11)
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
60
|
+
hike (1.2.1)
|
61
|
+
i18n (0.6.0)
|
62
|
+
journey (1.0.4)
|
63
|
+
json (1.7.3)
|
64
|
+
libwebsocket (0.1.3)
|
65
|
+
addressable
|
66
|
+
mail (2.4.4)
|
67
67
|
i18n (>= 0.4.0)
|
68
68
|
mime-types (~> 1.16)
|
69
69
|
treetop (~> 1.4.8)
|
70
|
-
mime-types (1.
|
70
|
+
mime-types (1.19)
|
71
71
|
minitest (2.8.1)
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
mongo (~> 1.3)
|
72
|
+
mongoid (3.0.0)
|
73
|
+
activemodel (~> 3.1)
|
74
|
+
moped (~> 1.1.1)
|
75
|
+
origin (~> 1.0.3)
|
77
76
|
tzinfo (~> 0.3.22)
|
78
|
-
|
79
|
-
|
77
|
+
moped (1.1.1)
|
78
|
+
multi_json (1.3.6)
|
79
|
+
nokogiri (1.5.5)
|
80
|
+
origin (1.0.4)
|
80
81
|
polyglot (0.3.3)
|
81
|
-
rack (1.
|
82
|
-
rack-
|
83
|
-
rack (>=
|
84
|
-
rack-
|
82
|
+
rack (1.4.1)
|
83
|
+
rack-cache (1.2)
|
84
|
+
rack (>= 0.4)
|
85
|
+
rack-ssl (1.3.2)
|
86
|
+
rack
|
87
|
+
rack-test (0.6.1)
|
85
88
|
rack (>= 1.0)
|
86
|
-
rails (3.
|
87
|
-
actionmailer (= 3.
|
88
|
-
actionpack (= 3.
|
89
|
-
activerecord (= 3.
|
90
|
-
activeresource (= 3.
|
91
|
-
activesupport (= 3.
|
89
|
+
rails (3.2.6)
|
90
|
+
actionmailer (= 3.2.6)
|
91
|
+
actionpack (= 3.2.6)
|
92
|
+
activerecord (= 3.2.6)
|
93
|
+
activeresource (= 3.2.6)
|
94
|
+
activesupport (= 3.2.6)
|
92
95
|
bundler (~> 1.0)
|
93
|
-
railties (= 3.
|
94
|
-
railties (3.
|
95
|
-
actionpack (= 3.
|
96
|
-
activesupport (= 3.
|
96
|
+
railties (= 3.2.6)
|
97
|
+
railties (3.2.6)
|
98
|
+
actionpack (= 3.2.6)
|
99
|
+
activesupport (= 3.2.6)
|
100
|
+
rack-ssl (~> 1.3.2)
|
97
101
|
rake (>= 0.8.7)
|
98
102
|
rdoc (~> 3.4)
|
99
|
-
thor (
|
103
|
+
thor (>= 0.14.6, < 2.0)
|
100
104
|
rake (0.9.2.2)
|
101
105
|
rdoc (3.12)
|
102
106
|
json (~> 1.4)
|
107
|
+
rspec (2.10.0)
|
108
|
+
rspec-core (~> 2.10.0)
|
109
|
+
rspec-expectations (~> 2.10.0)
|
110
|
+
rspec-mocks (~> 2.10.0)
|
111
|
+
rspec-core (2.10.1)
|
112
|
+
rspec-expectations (2.10.0)
|
113
|
+
diff-lcs (~> 1.1.3)
|
114
|
+
rspec-mocks (2.10.1)
|
115
|
+
rspec-rails (2.10.1)
|
116
|
+
actionpack (>= 3.0)
|
117
|
+
activesupport (>= 3.0)
|
118
|
+
railties (>= 3.0)
|
119
|
+
rspec (~> 2.10.0)
|
103
120
|
ruby-progressbar (0.0.10)
|
104
|
-
rubyzip (0.9.
|
105
|
-
selenium-webdriver (2.
|
121
|
+
rubyzip (0.9.9)
|
122
|
+
selenium-webdriver (2.24.0)
|
106
123
|
childprocess (>= 0.2.5)
|
107
|
-
|
124
|
+
libwebsocket (~> 0.1.3)
|
108
125
|
multi_json (~> 1.0)
|
109
126
|
rubyzip
|
110
|
-
simplecov (0.6.
|
127
|
+
simplecov (0.6.4)
|
111
128
|
multi_json (~> 1.0)
|
112
129
|
simplecov-html (~> 0.5.3)
|
113
130
|
simplecov-html (0.5.3)
|
114
|
-
|
131
|
+
sprockets (2.1.3)
|
132
|
+
hike (~> 1.2)
|
133
|
+
rack (~> 1.0)
|
134
|
+
tilt (~> 1.1, != 1.3.0)
|
135
|
+
thor (0.15.4)
|
136
|
+
tilt (1.3.3)
|
115
137
|
treetop (1.4.10)
|
116
138
|
polyglot
|
117
139
|
polyglot (>= 0.3.1)
|
118
|
-
tzinfo (0.3.
|
140
|
+
tzinfo (0.3.33)
|
119
141
|
xpath (0.1.4)
|
120
142
|
nokogiri (~> 1.3)
|
121
143
|
|
@@ -123,11 +145,11 @@ PLATFORMS
|
|
123
145
|
ruby
|
124
146
|
|
125
147
|
DEPENDENCIES
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
factory_girl_rails
|
130
|
-
ffaker
|
148
|
+
capybara (~> 1.1.2)
|
149
|
+
colorific (~> 1.0.2)
|
150
|
+
factory_girl_rails (~> 3.5.0)
|
131
151
|
publish!
|
132
|
-
rails (
|
133
|
-
|
152
|
+
rails (~> 3.2.0)
|
153
|
+
rake (~> 0.9)
|
154
|
+
rspec-rails (~> 2.10.1)
|
155
|
+
simplecov (~> 0.6.1)
|
data/README.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# Publish [![Build Status](https://secure.travis-ci.org/lucasrenan/publish.png?branch=master)](http://travis-ci.org/lucasrenan/publish) [![Build Status](https://gemnasium.com/lucasrenan/publish.png)](http://gemnasium.com/lucasrenan/publish) [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/lucasrenan/publish)
|
2
|
+
|
3
|
+
|
4
|
+
Publish is a gem that adds the common functionality to publish (or set as draft) a document using Mongoid.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add to Gemfile
|
9
|
+
|
10
|
+
gem "publish", "~> 0.1.0"
|
11
|
+
|
12
|
+
Then run
|
13
|
+
|
14
|
+
bundle install
|
15
|
+
|
16
|
+
## Getting started
|
17
|
+
|
18
|
+
|
19
|
+
Include Publish Module to your model
|
20
|
+
|
21
|
+
``` ruby
|
22
|
+
class Post
|
23
|
+
include Mongoid::Document
|
24
|
+
include Mongoid::Publish
|
25
|
+
|
26
|
+
field :title
|
27
|
+
field :text
|
28
|
+
end
|
29
|
+
|
30
|
+
Post.published.count #0
|
31
|
+
|
32
|
+
p = Post.new
|
33
|
+
p.published? #false
|
34
|
+
p.published_at #nil
|
35
|
+
|
36
|
+
p.publish! #p.published = true
|
37
|
+
|
38
|
+
p.published? #true
|
39
|
+
|
40
|
+
Post.published.count #1
|
41
|
+
|
42
|
+
p.publication_status #Date.today or 'draft'
|
43
|
+
```
|
data/publish.gemspec
CHANGED
@@ -1,23 +1,28 @@
|
|
1
1
|
$:.push File.expand_path("../lib", __FILE__)
|
2
2
|
require "mongoid/publish/version"
|
3
3
|
|
4
|
-
Gem::Specification.new do |
|
5
|
-
s.name = "publish"
|
6
|
-
s.summary = "Adds the functionality to publish/unpublish"
|
7
|
-
s.description = "Adds the functionality to publish/unpublish"
|
8
|
-
#s.files = Dir["{app,lib,config}/**/*"] + ["MIT-LICENSE", "Rakefile", "Gemfile", "README.rdoc"]
|
9
|
-
s.version = Mongoid::Publish::VERSION
|
10
|
-
s.platform = Gem::Platform::RUBY
|
11
|
-
s.authors = ["Lucas Renan", "Marco Singer"]
|
12
|
-
s.email = ["contato@lucasrenan.com", "markaum@gmail.com"]
|
13
|
-
s.homepage = "https://github.com/lucasrenan/publish"
|
4
|
+
Gem::Specification.new do |gem|
|
14
5
|
|
15
|
-
|
6
|
+
gem.name = "publish"
|
7
|
+
gem.authors = ["Lucas Renan", "Tiago Rafael Godinho", "Marco Singer"]
|
8
|
+
gem.email = ["contato@lucasrenan.com", "tiagogodinho3@gmail.com", "markaum@gmail.com"]
|
9
|
+
gem.description = %q{Adds the functionality to publish/unpublish mongoid docs}
|
10
|
+
gem.summary = %q{Adds the functionality to publish/unpublish mongoid docs}
|
11
|
+
gem.homepage = "https://github.com/lucasrenan/publish"
|
16
12
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
13
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
14
|
+
gem.files = `git ls-files`.split("\n")
|
15
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
|
+
gem.require_paths = ["lib"]
|
17
|
+
gem.version = Mongoid::Publish::VERSION
|
18
|
+
gem.platform = Gem::Platform::RUBY
|
21
19
|
|
22
|
-
|
20
|
+
|
21
|
+
gem.add_dependency "mongoid", "~> 3.0.0"
|
22
|
+
|
23
|
+
gem.add_development_dependency "rails", "~> 3.2.0"
|
24
|
+
gem.add_development_dependency "rake", "~> 0.9"
|
25
|
+
gem.add_development_dependency "rspec-rails", "~> 2.10.1"
|
26
|
+
gem.add_development_dependency "simplecov", "~> 0.6.1"
|
27
|
+
gem.add_development_dependency "capybara", "~> 1.1.2"
|
23
28
|
end
|
@@ -2,8 +2,8 @@ Dummy::Application.configure do
|
|
2
2
|
# Settings specified here will take precedence over those in config/application.rb
|
3
3
|
|
4
4
|
# In the development environment your application's code is reloaded on
|
5
|
-
# every request.
|
6
|
-
# since you don't have to restart the
|
5
|
+
# every request. This slows down response time but is perfect for development
|
6
|
+
# since you don't have to restart the web server when you make code changes.
|
7
7
|
config.cache_classes = false
|
8
8
|
|
9
9
|
# Log error messages when you accidentally call methods on nil.
|
@@ -11,7 +11,6 @@ Dummy::Application.configure do
|
|
11
11
|
|
12
12
|
# Show full error reports and disable caching
|
13
13
|
config.consider_all_requests_local = true
|
14
|
-
config.action_view.debug_rjs = true
|
15
14
|
config.action_controller.perform_caching = false
|
16
15
|
|
17
16
|
# Don't care if the mailer can't send
|
@@ -22,5 +21,10 @@ Dummy::Application.configure do
|
|
22
21
|
|
23
22
|
# Only use best-standards-support built into browsers
|
24
23
|
config.action_dispatch.best_standards_support = :builtin
|
25
|
-
end
|
26
24
|
|
25
|
+
# Do not compress assets
|
26
|
+
config.assets.compress = false
|
27
|
+
|
28
|
+
# Expands the lines which load the assets
|
29
|
+
config.assets.debug = true
|
30
|
+
end
|
@@ -2,12 +2,16 @@ Dummy::Application.configure do
|
|
2
2
|
# Settings specified here will take precedence over those in config/application.rb
|
3
3
|
|
4
4
|
# The test environment is used exclusively to run your application's
|
5
|
-
# test suite.
|
5
|
+
# test suite. You never need to work with it otherwise. Remember that
|
6
6
|
# your test database is "scratch space" for the test suite and is wiped
|
7
|
-
# and recreated between test runs.
|
7
|
+
# and recreated between test runs. Don't rely on the data there!
|
8
8
|
config.cache_classes = true
|
9
9
|
|
10
|
-
#
|
10
|
+
# Configure static asset server for tests with Cache-Control for performance
|
11
|
+
config.serve_static_assets = true
|
12
|
+
config.static_cache_control = "public, max-age=3600"
|
13
|
+
|
14
|
+
# Log error messages when you accidentally call methods on nil
|
11
15
|
config.whiny_nils = true
|
12
16
|
|
13
17
|
# Show full error reports and disable caching
|
@@ -25,11 +29,6 @@ Dummy::Application.configure do
|
|
25
29
|
# ActionMailer::Base.deliveries array.
|
26
30
|
config.action_mailer.delivery_method = :test
|
27
31
|
|
28
|
-
# Use SQL instead of Active Record's schema dumper when creating the test database.
|
29
|
-
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
30
|
-
# like if you have constraints or database-specific column types
|
31
|
-
# config.active_record.schema_format = :sql
|
32
|
-
|
33
32
|
# Print deprecation notices to the stderr
|
34
33
|
config.active_support.deprecation = :stderr
|
35
|
-
end
|
34
|
+
end
|
@@ -1,23 +1,68 @@
|
|
1
|
-
defaults: &defaults
|
2
|
-
host: localhost
|
3
|
-
# slaves:
|
4
|
-
# - host: slave1.local
|
5
|
-
# port: 27018
|
6
|
-
# - host: slave2.local
|
7
|
-
# port: 27019
|
8
|
-
|
9
1
|
development:
|
10
|
-
|
11
|
-
|
2
|
+
# Configure available database sessions. (required)
|
3
|
+
sessions:
|
4
|
+
# Defines the default session. (required)
|
5
|
+
default:
|
6
|
+
# Defines the name of the default database that Mongoid can connect to.
|
7
|
+
# (required).
|
8
|
+
database: publish_dummy__development
|
9
|
+
# Provides the hosts the default session can connect to. Must be an array
|
10
|
+
# of host:port pairs. (required)
|
11
|
+
hosts:
|
12
|
+
- localhost:27017
|
13
|
+
options:
|
14
|
+
# Change whether the session persists in safe mode by default.
|
15
|
+
# (default: false)
|
16
|
+
# safe: false
|
17
|
+
|
18
|
+
# Change the default consistency model to :eventual or :strong.
|
19
|
+
# :eventual will send reads to secondaries, :strong sends everything
|
20
|
+
# to master. (default: :eventual)
|
21
|
+
consistency: :strong
|
22
|
+
# Configure Mongoid specific options. (optional)
|
23
|
+
options:
|
24
|
+
# Configuration for whether or not to allow access to fields that do
|
25
|
+
# not have a field definition on the model. (default: true)
|
26
|
+
# allow_dynamic_fields: true
|
27
|
+
|
28
|
+
# Enable the identity map, needed for eager loading. (default: false)
|
29
|
+
# identity_map_enabled: false
|
30
|
+
|
31
|
+
# Includes the root model name in json serialization. (default: false)
|
32
|
+
# include_root_in_json: false
|
33
|
+
|
34
|
+
# Include the _type field in serializaion. (default: false)
|
35
|
+
# include_type_for_serialization: false
|
36
|
+
|
37
|
+
# Preload all models in development, needed when models use
|
38
|
+
# inheritance. (default: false)
|
39
|
+
# preload_models: false
|
40
|
+
|
41
|
+
# Protect id and type from mass assignment. (default: true)
|
42
|
+
# protect_sensitive_fields: true
|
43
|
+
|
44
|
+
# Raise an error when performing a #find and the document is not found.
|
45
|
+
# (default: true)
|
46
|
+
# raise_not_found_error: true
|
47
|
+
|
48
|
+
# Raise an error when defining a scope with the same name as an
|
49
|
+
# existing method. (default: false)
|
50
|
+
# scope_overwrite_exception: false
|
51
|
+
|
52
|
+
# Skip the database version check, used when connecting to a db without
|
53
|
+
# admin access. (default: false)
|
54
|
+
# skip_version_check: false
|
55
|
+
|
56
|
+
# User Active Support's time zone in conversions. (default: true)
|
57
|
+
# use_activesupport_time_zone: true
|
12
58
|
|
59
|
+
# Ensure all times are UTC in the app side. (default: false)
|
60
|
+
# use_utc: false
|
13
61
|
test:
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
username: <%= ENV['MONGOID_USERNAME'] %>
|
22
|
-
password: <%= ENV['MONGOID_PASSWORD'] %>
|
23
|
-
database: <%= ENV['MONGOID_DATABASE'] %>
|
62
|
+
sessions:
|
63
|
+
default:
|
64
|
+
database: publish_dummy__test
|
65
|
+
hosts:
|
66
|
+
- localhost:27017
|
67
|
+
options:
|
68
|
+
consistency: :strong
|
@@ -3,7 +3,7 @@ require File.expand_path("../../../test_helper", __FILE__)
|
|
3
3
|
class PostTest < ActiveSupport::TestCase
|
4
4
|
|
5
5
|
setup do
|
6
|
-
@post =
|
6
|
+
@post = FactoryGirl.create(:post)
|
7
7
|
end
|
8
8
|
|
9
9
|
test "should create published at field" do
|
@@ -17,7 +17,7 @@ class PostTest < ActiveSupport::TestCase
|
|
17
17
|
end
|
18
18
|
|
19
19
|
test "should be unpublished if published at is not setted" do
|
20
|
-
post =
|
20
|
+
post = FactoryGirl.build(:post)
|
21
21
|
post.published = true
|
22
22
|
|
23
23
|
assert_equal post.published?, false
|
@@ -33,21 +33,21 @@ class PostTest < ActiveSupport::TestCase
|
|
33
33
|
end
|
34
34
|
|
35
35
|
test "should return published posts" do
|
36
|
-
2.times {
|
36
|
+
2.times { FactoryGirl.create(:post, :published => true) }
|
37
37
|
|
38
38
|
assert_equal Post.published.size, 2
|
39
39
|
end
|
40
40
|
|
41
41
|
test "should return orderly published posts" do
|
42
|
-
|
43
|
-
|
44
|
-
|
42
|
+
FactoryGirl.create(:post, :title => "2", :published => true, :published_at => 1.month.ago)
|
43
|
+
FactoryGirl.create(:post, :title => "3", :published => true, :published_at => 1.year.ago)
|
44
|
+
FactoryGirl.create(:post, :title => "1", :published => true, :published_at => 1.day.ago)
|
45
45
|
|
46
46
|
assert_equal Post.published_and_orderly.map(&:title), ["1", "2", "3"]
|
47
47
|
end
|
48
48
|
|
49
49
|
test "should publish a post" do
|
50
|
-
post =
|
50
|
+
post = FactoryGirl.build(:post)
|
51
51
|
post.publish!
|
52
52
|
post.reload
|
53
53
|
|
@@ -56,8 +56,8 @@ class PostTest < ActiveSupport::TestCase
|
|
56
56
|
end
|
57
57
|
|
58
58
|
test "should concat with criteria methods" do
|
59
|
-
|
60
|
-
|
59
|
+
FactoryGirl.create(:post, :published => true, :title => "normal post")
|
60
|
+
FactoryGirl.create(:post, :published => true, :title => "my special post")
|
61
61
|
|
62
62
|
assert_equal Post.where(:title => /special/).published.count, 1
|
63
63
|
assert_equal Post.published.where(:title => /special/).count, 1
|
data/test/test_helper.rb
CHANGED
@@ -1,10 +1,7 @@
|
|
1
1
|
#generates coverage report
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
add_filter '/vendor/'
|
6
|
-
end
|
7
|
-
rescue
|
2
|
+
require 'simplecov'
|
3
|
+
SimpleCov.start('rails') do
|
4
|
+
add_filter '/vendor/'
|
8
5
|
end
|
9
6
|
|
10
7
|
# Configure Rails Envinronment
|
@@ -24,20 +21,18 @@ require "capybara/rails"
|
|
24
21
|
Capybara.default_driver = :rack_test
|
25
22
|
Capybara.default_selector = :css
|
26
23
|
|
27
|
-
# Run any available migration
|
28
|
-
#ActiveRecord::Migrator.migrate File.expand_path("../dummy/db/migrate/", __FILE__)
|
29
24
|
|
30
25
|
# Load support files
|
31
26
|
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
32
27
|
|
33
28
|
class ActiveSupport::TestCase
|
34
29
|
teardown do
|
35
|
-
Mongoid.
|
30
|
+
Mongoid.default_session.collections.select {|c| c.name !~ /system/ }.each(&:drop)
|
36
31
|
end
|
37
32
|
end
|
38
33
|
|
39
34
|
class ActionController::TestCase
|
40
35
|
teardown do
|
41
|
-
Mongoid.
|
36
|
+
Mongoid.default_session.collections.select {|c| c.name !~ /system/ }.each(&:drop)
|
42
37
|
end
|
43
38
|
end
|
metadata
CHANGED
@@ -1,31 +1,118 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: publish
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Lucas Renan
|
9
|
+
- Tiago Rafael Godinho
|
9
10
|
- Marco Singer
|
10
11
|
autorequire:
|
11
12
|
bindir: bin
|
12
13
|
cert_chain: []
|
13
|
-
date: 2012-
|
14
|
+
date: 2012-09-04 00:00:00.000000000 Z
|
14
15
|
dependencies:
|
15
16
|
- !ruby/object:Gem::Dependency
|
16
17
|
name: mongoid
|
17
|
-
requirement:
|
18
|
+
requirement: !ruby/object:Gem::Requirement
|
18
19
|
none: false
|
19
20
|
requirements:
|
20
|
-
- -
|
21
|
+
- - ~>
|
21
22
|
- !ruby/object:Gem::Version
|
22
|
-
version:
|
23
|
+
version: 3.0.0
|
23
24
|
type: :runtime
|
24
25
|
prerelease: false
|
25
|
-
version_requirements:
|
26
|
-
|
26
|
+
version_requirements: !ruby/object:Gem::Requirement
|
27
|
+
none: false
|
28
|
+
requirements:
|
29
|
+
- - ~>
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: 3.0.0
|
32
|
+
- !ruby/object:Gem::Dependency
|
33
|
+
name: rails
|
34
|
+
requirement: !ruby/object:Gem::Requirement
|
35
|
+
none: false
|
36
|
+
requirements:
|
37
|
+
- - ~>
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: 3.2.0
|
40
|
+
type: :development
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
none: false
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 3.2.0
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: rake
|
50
|
+
requirement: !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ~>
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0.9'
|
56
|
+
type: :development
|
57
|
+
prerelease: false
|
58
|
+
version_requirements: !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
60
|
+
requirements:
|
61
|
+
- - ~>
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0.9'
|
64
|
+
- !ruby/object:Gem::Dependency
|
65
|
+
name: rspec-rails
|
66
|
+
requirement: !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
68
|
+
requirements:
|
69
|
+
- - ~>
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: 2.10.1
|
72
|
+
type: :development
|
73
|
+
prerelease: false
|
74
|
+
version_requirements: !ruby/object:Gem::Requirement
|
75
|
+
none: false
|
76
|
+
requirements:
|
77
|
+
- - ~>
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: 2.10.1
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: simplecov
|
82
|
+
requirement: !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ~>
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: 0.6.1
|
88
|
+
type: :development
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: !ruby/object:Gem::Requirement
|
91
|
+
none: false
|
92
|
+
requirements:
|
93
|
+
- - ~>
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: 0.6.1
|
96
|
+
- !ruby/object:Gem::Dependency
|
97
|
+
name: capybara
|
98
|
+
requirement: !ruby/object:Gem::Requirement
|
99
|
+
none: false
|
100
|
+
requirements:
|
101
|
+
- - ~>
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 1.1.2
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
none: false
|
108
|
+
requirements:
|
109
|
+
- - ~>
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: 1.1.2
|
112
|
+
description: Adds the functionality to publish/unpublish mongoid docs
|
27
113
|
email:
|
28
114
|
- contato@lucasrenan.com
|
115
|
+
- tiagogodinho3@gmail.com
|
29
116
|
- markaum@gmail.com
|
30
117
|
executables: []
|
31
118
|
extensions: []
|
@@ -33,10 +120,11 @@ extra_rdoc_files: []
|
|
33
120
|
files:
|
34
121
|
- .gitignore
|
35
122
|
- .travis.yml
|
123
|
+
- CHANGELOG.md
|
36
124
|
- Gemfile
|
37
125
|
- Gemfile.lock
|
38
126
|
- MIT-LICENSE
|
39
|
-
- README.
|
127
|
+
- README.md
|
40
128
|
- Rakefile
|
41
129
|
- lib/mongoid/publish.rb
|
42
130
|
- lib/mongoid/publish/version.rb
|
@@ -59,7 +147,6 @@ files:
|
|
59
147
|
- test/dummy/config/boot.rb
|
60
148
|
- test/dummy/config/environment.rb
|
61
149
|
- test/dummy/config/environments/development.rb
|
62
|
-
- test/dummy/config/environments/production.rb
|
63
150
|
- test/dummy/config/environments/test.rb
|
64
151
|
- test/dummy/config/initializers/backtrace_silencers.rb
|
65
152
|
- test/dummy/config/initializers/inflections.rb
|
@@ -106,11 +193,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
193
|
- !ruby/object:Gem::Version
|
107
194
|
version: '0'
|
108
195
|
requirements: []
|
109
|
-
rubyforge_project:
|
110
|
-
rubygems_version: 1.8.
|
196
|
+
rubyforge_project:
|
197
|
+
rubygems_version: 1.8.24
|
111
198
|
signing_key:
|
112
199
|
specification_version: 3
|
113
|
-
summary: Adds the functionality to publish/unpublish
|
200
|
+
summary: Adds the functionality to publish/unpublish mongoid docs
|
114
201
|
test_files:
|
115
202
|
- test/dummy/Rakefile
|
116
203
|
- test/dummy/app/controllers/application_controller.rb
|
@@ -129,7 +216,6 @@ test_files:
|
|
129
216
|
- test/dummy/config/boot.rb
|
130
217
|
- test/dummy/config/environment.rb
|
131
218
|
- test/dummy/config/environments/development.rb
|
132
|
-
- test/dummy/config/environments/production.rb
|
133
219
|
- test/dummy/config/environments/test.rb
|
134
220
|
- test/dummy/config/initializers/backtrace_silencers.rb
|
135
221
|
- test/dummy/config/initializers/inflections.rb
|
data/README.rdoc
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
== Publish
|
2
|
-
|
3
|
-
Publish is a gem that adds the common functionality to publish and unpublish in the rails models.
|
4
|
-
Now, supports just Mongoid. Support to Activerecord is comming soon.
|
5
|
-
|
6
|
-
== Installation
|
7
|
-
|
8
|
-
Add to Gemfile
|
9
|
-
|
10
|
-
gem 'publish', '0.0.1'
|
11
|
-
|
12
|
-
Then run
|
13
|
-
|
14
|
-
bundle install
|
15
|
-
|
16
|
-
== Getting started
|
17
|
-
|
18
|
-
|
19
|
-
Include Publish Module to your model
|
20
|
-
|
21
|
-
class Post
|
22
|
-
include Mongoid::Document
|
23
|
-
include Mongoid::Publish
|
24
|
-
|
25
|
-
field :title
|
26
|
-
field :text
|
27
|
-
end
|
28
|
-
|
29
|
-
Post.published.count #0
|
30
|
-
|
31
|
-
p = Post.new
|
32
|
-
p.published? #false
|
33
|
-
p.published_at #nil
|
34
|
-
|
35
|
-
p.publish! #p.published = true
|
36
|
-
|
37
|
-
p.published? #true
|
38
|
-
|
39
|
-
Post.published.count #1
|
40
|
-
|
41
|
-
p.publication_status #Date.today or 'draft'
|
@@ -1,49 +0,0 @@
|
|
1
|
-
Dummy::Application.configure do
|
2
|
-
# Settings specified here will take precedence over those in config/application.rb
|
3
|
-
|
4
|
-
# The production environment is meant for finished, "live" apps.
|
5
|
-
# Code is not reloaded between requests
|
6
|
-
config.cache_classes = true
|
7
|
-
|
8
|
-
# Full error reports are disabled and caching is turned on
|
9
|
-
config.consider_all_requests_local = false
|
10
|
-
config.action_controller.perform_caching = true
|
11
|
-
|
12
|
-
# Specifies the header that your server uses for sending files
|
13
|
-
config.action_dispatch.x_sendfile_header = "X-Sendfile"
|
14
|
-
|
15
|
-
# For nginx:
|
16
|
-
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
|
17
|
-
|
18
|
-
# If you have no front-end server that supports something like X-Sendfile,
|
19
|
-
# just comment this out and Rails will serve the files
|
20
|
-
|
21
|
-
# See everything in the log (default is :info)
|
22
|
-
# config.log_level = :debug
|
23
|
-
|
24
|
-
# Use a different logger for distributed setups
|
25
|
-
# config.logger = SyslogLogger.new
|
26
|
-
|
27
|
-
# Use a different cache store in production
|
28
|
-
# config.cache_store = :mem_cache_store
|
29
|
-
|
30
|
-
# Disable Rails's static asset server
|
31
|
-
# In production, Apache or nginx will already do this
|
32
|
-
config.serve_static_assets = false
|
33
|
-
|
34
|
-
# Enable serving of images, stylesheets, and javascripts from an asset server
|
35
|
-
# config.action_controller.asset_host = "http://assets.example.com"
|
36
|
-
|
37
|
-
# Disable delivery errors, bad email addresses will be ignored
|
38
|
-
# config.action_mailer.raise_delivery_errors = false
|
39
|
-
|
40
|
-
# Enable threaded mode
|
41
|
-
# config.threadsafe!
|
42
|
-
|
43
|
-
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
44
|
-
# the I18n.default_locale when a translation can not be found)
|
45
|
-
config.i18n.fallbacks = true
|
46
|
-
|
47
|
-
# Send deprecation notices to registered listeners
|
48
|
-
config.active_support.deprecation = :notify
|
49
|
-
end
|