Skip to content

Commit 1d28bbb

Browse files
committed
Move to Mongoid 5 beta
1 parent b0c8800 commit 1d28bbb

File tree

8 files changed

+110
-98
lines changed

8 files changed

+110
-98
lines changed

Gemfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ gem "carrierwave"
66
gem "carrierwave-mongoid", require: "carrierwave/mongoid"
77
gem "decent_exposure"
88

9-
gem "mongoid", github: "mongoid/mongoid"
9+
gem "mongoid", "~> 5.0.0.beta"
1010

1111
gem 'mimetype-fu', require: 'mimetype_fu'
12+
gem 'responders'
1213

1314
group :development, :test do
1415
gem "fabrication"

Gemfile.lock

Lines changed: 73 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,92 +1,79 @@
1-
GIT
2-
remote: git://github.com/mongoid/mongoid.git
3-
revision: 8333e67b5598252772585efb79801def49b6aa29
4-
specs:
5-
mongoid (5.0.0)
6-
activemodel (~> 4.0)
7-
mongo (~> 2.0)
8-
origin (~> 2.1)
9-
tzinfo (>= 0.3.37)
10-
111
GEM
122
remote: https://rubygems.org/
133
specs:
14-
actionmailer (4.2.1)
15-
actionpack (= 4.2.1)
16-
actionview (= 4.2.1)
17-
activejob (= 4.2.1)
4+
actionmailer (4.2.3)
5+
actionpack (= 4.2.3)
6+
actionview (= 4.2.3)
7+
activejob (= 4.2.3)
188
mail (~> 2.5, >= 2.5.4)
199
rails-dom-testing (~> 1.0, >= 1.0.5)
20-
actionpack (4.2.1)
21-
actionview (= 4.2.1)
22-
activesupport (= 4.2.1)
10+
actionpack (4.2.3)
11+
actionview (= 4.2.3)
12+
activesupport (= 4.2.3)
2313
rack (~> 1.6)
2414
rack-test (~> 0.6.2)
2515
rails-dom-testing (~> 1.0, >= 1.0.5)
26-
rails-html-sanitizer (~> 1.0, >= 1.0.1)
27-
actionview (4.2.1)
28-
activesupport (= 4.2.1)
16+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
17+
actionview (4.2.3)
18+
activesupport (= 4.2.3)
2919
builder (~> 3.1)
3020
erubis (~> 2.7.0)
3121
rails-dom-testing (~> 1.0, >= 1.0.5)
32-
rails-html-sanitizer (~> 1.0, >= 1.0.1)
33-
activejob (4.2.1)
34-
activesupport (= 4.2.1)
22+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
23+
activejob (4.2.3)
24+
activesupport (= 4.2.3)
3525
globalid (>= 0.3.0)
36-
activemodel (4.2.1)
37-
activesupport (= 4.2.1)
26+
activemodel (4.2.3)
27+
activesupport (= 4.2.3)
3828
builder (~> 3.1)
39-
activerecord (4.2.1)
40-
activemodel (= 4.2.1)
41-
activesupport (= 4.2.1)
29+
activerecord (4.2.3)
30+
activemodel (= 4.2.3)
31+
activesupport (= 4.2.3)
4232
arel (~> 6.0)
43-
activesupport (4.2.1)
33+
activesupport (4.2.3)
4434
i18n (~> 0.7)
4535
json (~> 1.7, >= 1.7.7)
4636
minitest (~> 5.1)
4737
thread_safe (~> 0.3, >= 0.3.4)
4838
tzinfo (~> 1.1)
49-
arel (6.0.0)
50-
bson (3.0.4)
39+
arel (6.0.2)
40+
bson (3.1.2)
5141
builder (3.2.2)
5242
carrierwave (0.10.0)
5343
activemodel (>= 3.2.0)
5444
activesupport (>= 3.2.0)
5545
json (>= 1.7)
5646
mime-types (>= 1.16)
57-
carrierwave-mongoid (0.1.0)
58-
carrierwave
59-
mongoid
60-
celluloid (0.16.0)
61-
timers (~> 4.0.0)
47+
carrierwave-mongoid (0.7.1)
48+
carrierwave (>= 0.8.0, < 0.11.0)
49+
mongoid (>= 3.0, < 5.0)
50+
mongoid-grid_fs (>= 1.3, < 3.0)
6251
coderay (1.1.0)
6352
decent_exposure (2.3.2)
6453
diff-lcs (1.2.5)
6554
erubis (2.7.0)
6655
fabrication (2.13.2)
67-
ffi (1.9.8)
56+
ffi (1.9.10)
6857
formatador (0.2.5)
6958
globalid (0.3.5)
7059
activesupport (>= 4.1.0)
71-
guard (2.12.5)
60+
guard (2.12.8)
7261
formatador (>= 0.2.4)
73-
listen (~> 2.7)
62+
listen (>= 2.7, <= 4.0)
7463
lumberjack (~> 1.0)
7564
nenv (~> 0.1)
7665
notiffany (~> 0.0)
7766
pry (>= 0.9.12)
7867
shellany (~> 0.0)
7968
thor (>= 0.18.1)
8069
guard-compat (1.2.1)
81-
guard-rspec (4.5.2)
70+
guard-rspec (4.6.2)
8271
guard (~> 2.1)
8372
guard-compat (~> 1.1)
8473
rspec (>= 2.99.0, < 4.0)
85-
hitimes (1.2.2)
8674
i18n (0.7.0)
8775
json (1.8.3)
88-
listen (2.10.0)
89-
celluloid (~> 0.16.0)
76+
listen (3.0.2)
9077
rb-fsevent (>= 0.9.3)
9178
rb-inotify (>= 0.9)
9279
loofah (2.0.2)
@@ -99,8 +86,16 @@ GEM
9986
mimetype-fu (0.1.2)
10087
mini_portile (0.6.2)
10188
minitest (5.7.0)
102-
mongo (2.0.4)
89+
mongo (2.1.0.beta)
10390
bson (~> 3.0)
91+
mongoid (5.0.0.beta)
92+
activemodel (~> 4.0)
93+
mongo (= 2.1.0.beta)
94+
origin (~> 2.1)
95+
tzinfo (>= 0.3.37)
96+
mongoid-grid_fs (2.1.0)
97+
mime-types (>= 1.0, < 3.0)
98+
mongoid (>= 3.0, < 5.0)
10499
nenv (0.2.0)
105100
nokogiri (1.6.6.2)
106101
mini_portile (~> 0.6.0)
@@ -112,19 +107,19 @@ GEM
112107
coderay (~> 1.1.0)
113108
method_source (~> 0.8.1)
114109
slop (~> 3.4)
115-
rack (1.6.1)
110+
rack (1.6.4)
116111
rack-test (0.6.3)
117112
rack (>= 1.0)
118-
rails (4.2.1)
119-
actionmailer (= 4.2.1)
120-
actionpack (= 4.2.1)
121-
actionview (= 4.2.1)
122-
activejob (= 4.2.1)
123-
activemodel (= 4.2.1)
124-
activerecord (= 4.2.1)
125-
activesupport (= 4.2.1)
113+
rails (4.2.3)
114+
actionmailer (= 4.2.3)
115+
actionpack (= 4.2.3)
116+
actionview (= 4.2.3)
117+
activejob (= 4.2.3)
118+
activemodel (= 4.2.3)
119+
activerecord (= 4.2.3)
120+
activesupport (= 4.2.3)
126121
bundler (>= 1.3.0, < 2.0)
127-
railties (= 4.2.1)
122+
railties (= 4.2.3)
128123
sprockets-rails
129124
rails-deprecated_sanitizer (1.0.3)
130125
activesupport (>= 4.2.0.alpha)
@@ -134,48 +129,48 @@ GEM
134129
rails-deprecated_sanitizer (>= 1.0.1)
135130
rails-html-sanitizer (1.0.2)
136131
loofah (~> 2.0)
137-
railties (4.2.1)
138-
actionpack (= 4.2.1)
139-
activesupport (= 4.2.1)
132+
railties (4.2.3)
133+
actionpack (= 4.2.3)
134+
activesupport (= 4.2.3)
140135
rake (>= 0.8.7)
141136
thor (>= 0.18.1, < 2.0)
142137
rake (10.4.2)
143138
rb-fsevent (0.9.5)
144139
rb-inotify (0.9.5)
145140
ffi (>= 0.5.0)
146-
rspec (3.2.0)
147-
rspec-core (~> 3.2.0)
148-
rspec-expectations (~> 3.2.0)
149-
rspec-mocks (~> 3.2.0)
150-
rspec-core (3.2.3)
151-
rspec-support (~> 3.2.0)
152-
rspec-expectations (3.2.1)
141+
responders (2.1.0)
142+
railties (>= 4.2.0, < 5)
143+
rspec (3.3.0)
144+
rspec-core (~> 3.3.0)
145+
rspec-expectations (~> 3.3.0)
146+
rspec-mocks (~> 3.3.0)
147+
rspec-core (3.3.2)
148+
rspec-support (~> 3.3.0)
149+
rspec-expectations (3.3.1)
153150
diff-lcs (>= 1.2.0, < 2.0)
154-
rspec-support (~> 3.2.0)
155-
rspec-mocks (3.2.1)
151+
rspec-support (~> 3.3.0)
152+
rspec-mocks (3.3.2)
156153
diff-lcs (>= 1.2.0, < 2.0)
157-
rspec-support (~> 3.2.0)
158-
rspec-rails (3.2.2)
154+
rspec-support (~> 3.3.0)
155+
rspec-rails (3.3.3)
159156
actionpack (>= 3.0, < 4.3)
160157
activesupport (>= 3.0, < 4.3)
161158
railties (>= 3.0, < 4.3)
162-
rspec-core (~> 3.2.0)
163-
rspec-expectations (~> 3.2.0)
164-
rspec-mocks (~> 3.2.0)
165-
rspec-support (~> 3.2.0)
166-
rspec-support (3.2.2)
159+
rspec-core (~> 3.3.0)
160+
rspec-expectations (~> 3.3.0)
161+
rspec-mocks (~> 3.3.0)
162+
rspec-support (~> 3.3.0)
163+
rspec-support (3.3.0)
167164
shellany (0.0.1)
168165
slop (3.6.0)
169166
sprockets (3.2.0)
170167
rack (~> 1.0)
171-
sprockets-rails (2.3.1)
168+
sprockets-rails (2.3.2)
172169
actionpack (>= 3.0)
173170
activesupport (>= 3.0)
174171
sprockets (>= 2.8, < 4.0)
175172
thor (0.19.1)
176173
thread_safe (0.3.5)
177-
timers (4.0.1)
178-
hitimes
179174
tzinfo (1.2.2)
180175
thread_safe (~> 0.1)
181176

@@ -190,6 +185,7 @@ DEPENDENCIES
190185
guard-rspec
191186
jruby-openssl
192187
mimetype-fu
193-
mongoid!
188+
mongoid (~> 5.0.0.beta)
194189
rails (~> 4.2)
190+
responders
195191
rspec-rails

app/models/reference/role.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class Role
3434
# Reference::Role.visitors
3535
#
3636
# @return [ Array<Reference::Role> ] The matching roles.
37-
scope "#{name}s", where(name: name)
37+
scope "#{name}s", ->{ where(name: name) }
3838

3939
# Since there is only one of each role, this provides a convenience for
4040
# getting the only role for the provided name.

app/models/user.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class User
6969
# User.subscribers
7070
#
7171
# @return [ Array<User> ] The matching users.
72-
scope "#{name}s", where("role.name" => name.to_s)
72+
scope "#{name}s", ->{ where("role.name" => name.to_s) }
7373
end
7474

7575
# Does the user have the ability to perform the supplied action?

app/workers/mongoid_worker.rb

Lines changed: 0 additions & 11 deletions
This file was deleted.

config/mongoid.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ development:
2222
# mode: :secondary_preferred
2323

2424
# The name of the user for authentication.
25-
# user: 'user'
25+
user: echo-user
2626

2727
# The password of the user for authentication.
28-
# password: 'password'
28+
password: password
2929

3030
# The user's database roles.
3131
# roles:
@@ -37,7 +37,7 @@ development:
3737
# auth_mech: :scram
3838

3939
# The database or source to authenticate the user against. (default: admin)
40-
# auth_source: admin
40+
auth_source: admin
4141

4242
# Force a the driver cluster to behave in a certain manner instead of auto-
4343
# discovering. Can be one of: :direct, :replica_set, :sharded. Set to :direct
@@ -108,7 +108,7 @@ development:
108108

109109
# Preload all models in development, needed when models use
110110
# inheritance. (default: false)
111-
# preload_models: false
111+
preload_models: true
112112

113113
# Raise an error when performing a #find and the document is not found.
114114
# (default: true)
@@ -131,5 +131,8 @@ test:
131131
- localhost:27017
132132
options:
133133
read:
134-
mode: primary
134+
mode: :primary
135135
max_pool_size: 1
136+
user: echo-user
137+
password: password
138+
auth_source: admin

spec/models/user_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@
272272
end
273273

274274
it "returns true" do
275-
subscribe.should be_true
275+
subscribe.should be true
276276
end
277277
end
278278
end

spec/spec_helper.rb

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
require "rubygems"
2-
require "spork"
32

43
ENV["RAILS_ENV"] ||= "test"
54

@@ -10,7 +9,31 @@
109
# in spec/support/ and its subdirectories.
1110
Dir[Rails.root.join("spec/support/**/*.rb")].each{ |f| require f }
1211

12+
ECHO_USER = Mongo::Auth::User.new(
13+
database: Mongo::Database::ADMIN,
14+
user: 'echo-user',
15+
password: 'password',
16+
roles: [
17+
Mongo::Auth::Roles::USER_ADMIN_ANY_DATABASE,
18+
Mongo::Auth::Roles::DATABASE_ADMIN_ANY_DATABASE,
19+
Mongo::Auth::Roles::READ_WRITE_ANY_DATABASE,
20+
Mongo::Auth::Roles::HOST_MANAGER
21+
]
22+
)
23+
1324
RSpec.configure do |config|
25+
26+
config.before(:suite) do
27+
client = Mongo::Client.new(["127.0.0.1:27017"])
28+
begin
29+
# Create the root user administrator as the first user to be added to the
30+
# database. This user will need to be authenticated in order to add any
31+
# more users to any other databases.
32+
client.database.users.create(ECHO_USER)
33+
rescue Exception => e
34+
end
35+
end
36+
1437
# Clean up all collections before each spec runs.
1538
config.before do
1639
Mongoid.purge!

0 commit comments

Comments
 (0)