mongoid-paranoia 1.3.0 → 2.0.0

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.
@@ -1,54 +1,44 @@
1
- require "spec_helper"
1
+ require 'spec_helper'
2
2
 
3
3
  describe Mongoid::Criteria::Scopable do
4
-
5
- context "when the document is paranoid" do
6
-
7
- context "when calling a class method" do
8
-
4
+ context 'when the document is paranoid' do
5
+ context 'when calling a class method' do
9
6
  let(:criteria) do
10
7
  Fish.fresh
11
8
  end
12
9
 
13
- it "includes the deleted_at criteria in the selector" do
14
- expect(criteria.selector).to eq({
15
- "deleted_at" => nil, "fresh" => true
16
- })
10
+ it 'includes the deleted_at criteria in the selector' do
11
+ expect(criteria.selector).to eq('deleted_at' => nil, 'fresh' => true)
17
12
  end
18
13
  end
19
14
 
20
- context "when chaining a class method to unscoped" do
21
-
15
+ context 'when chaining a class method to unscoped' do
22
16
  let(:criteria) do
23
17
  Fish.unscoped.fresh
24
18
  end
25
19
 
26
- it "does not include the deleted_at in the selector" do
27
- expect(criteria.selector).to eq({ "fresh" => true })
20
+ it 'does not include the deleted_at in the selector' do
21
+ expect(criteria.selector).to eq('fresh' => true)
28
22
  end
29
23
  end
30
24
 
31
- context "when chaining a class method to deleted" do
32
-
25
+ context 'when chaining a class method to deleted' do
33
26
  let(:criteria) do
34
27
  Fish.deleted.fresh
35
28
  end
36
29
 
37
- it "includes the deleted_at $ne criteria in the selector" do
38
- expect(criteria.selector).to eq({
39
- "deleted_at" => { "$ne" => nil }, "fresh" => true
40
- })
30
+ it 'includes the deleted_at $ne criteria in the selector' do
31
+ expect(criteria.selector).to eq('deleted_at' => { '$ne' => nil }, 'fresh' => true)
41
32
  end
42
33
  end
43
34
 
44
- context "when chaining a where to unscoped" do
45
-
35
+ context 'when chaining a where to unscoped' do
46
36
  let(:criteria) do
47
37
  Fish.unscoped.where(fresh: true)
48
38
  end
49
39
 
50
- it "includes no default scoping information in the selector" do
51
- expect(criteria.selector).to eq({ "fresh" => true })
40
+ it 'includes no default scoping information in the selector' do
41
+ expect(criteria.selector).to eq('fresh' => true)
52
42
  end
53
43
  end
54
44
  end
@@ -1,13 +1,9 @@
1
- require "spec_helper"
1
+ require 'spec_helper'
2
2
 
3
3
  describe Mongoid::Validatable::UniquenessValidator do
4
-
5
- describe "#valid?" do
6
-
7
- context "when the document is a root document" do
8
-
9
- context "when the document is paranoid" do
10
-
4
+ describe '#valid?' do
5
+ context 'when the document is a root document' do
6
+ context 'when the document is paranoid' do
11
7
  before do
12
8
  ParanoidPost.validates_uniqueness_of :title
13
9
  end
@@ -17,42 +13,39 @@ describe Mongoid::Validatable::UniquenessValidator do
17
13
  end
18
14
 
19
15
  let!(:post) do
20
- ParanoidPost.create(title: "testing")
16
+ ParanoidPost.create(title: 'testing')
21
17
  end
22
18
 
23
- context "when the field is unique" do
24
-
19
+ context 'when the field is unique' do
25
20
  let(:new_post) do
26
- ParanoidPost.new(title: "test")
21
+ ParanoidPost.new(title: 'test')
27
22
  end
28
23
 
29
- it "returns true" do
24
+ it 'returns true' do
30
25
  expect(new_post).to be_valid
31
26
  end
32
27
  end
33
28
 
34
- context "when the field is unique for non soft deleted docs" do
35
-
29
+ context 'when the field is unique for non soft deleted docs' do
36
30
  before do
37
31
  post.delete
38
32
  end
39
33
 
40
34
  let(:new_post) do
41
- ParanoidPost.new(title: "testing")
35
+ ParanoidPost.new(title: 'testing')
42
36
  end
43
37
 
44
- it "returns true" do
38
+ it 'returns true' do
45
39
  expect(new_post).to be_valid
46
40
  end
47
41
  end
48
42
 
49
- context "when the field is not unique" do
50
-
43
+ context 'when the field is not unique' do
51
44
  let(:new_post) do
52
- ParanoidPost.new(title: "testing")
45
+ ParanoidPost.new(title: 'testing')
53
46
  end
54
47
 
55
- it "returns false" do
48
+ it 'returns false' do
56
49
  expect(new_post).not_to be_valid
57
50
  end
58
51
  end
@@ -1,40 +1,38 @@
1
1
  $LOAD_PATH.unshift(File.dirname(__FILE__))
2
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
3
 
4
- MODELS = File.join(File.dirname(__FILE__), "app/models")
4
+ MODELS = File.join(File.dirname(__FILE__), 'app/models')
5
5
  $LOAD_PATH.unshift(MODELS)
6
6
 
7
- require "mongoid"
8
- require "rspec"
7
+ require 'mongoid'
8
+ require 'rspec'
9
9
 
10
- require "mongoid/paranoia"
10
+ require 'mongoid/paranoia'
11
11
 
12
12
  # These environment variables can be set if wanting to test against a database
13
13
  # that is not on the local machine.
14
- ENV["MONGOID_SPEC_HOST"] ||= "localhost"
15
- ENV["MONGOID_SPEC_PORT"] ||= "27017"
14
+ ENV['MONGOID_SPEC_HOST'] ||= 'localhost'
15
+ ENV['MONGOID_SPEC_PORT'] ||= '27017'
16
16
 
17
17
  # These are used when creating any connection in the test suite.
18
- HOST = ENV["MONGOID_SPEC_HOST"]
19
- PORT = ENV["MONGOID_SPEC_PORT"].to_i
18
+ HOST = ENV['MONGOID_SPEC_HOST']
19
+ PORT = ENV['MONGOID_SPEC_PORT'].to_i
20
20
 
21
21
  # Moped.logger.level = Logger::DEBUG # TODO Remove Mongoid 4 support.
22
22
  # Mongoid.logger.level = Logger::DEBUG
23
- if defined?(Mongo)
24
- Mongo::Logger.logger.level = Logger::WARN
25
- end
23
+ Mongo::Logger.logger.level = Logger::WARN if defined?(Mongo)
26
24
 
27
25
  # When testing locally we use the database named mongoid_test. However when
28
26
  # tests are running in parallel on Travis we need to use different database
29
27
  # names for each process running since we do not have transactions and want a
30
28
  # clean slate before each spec run.
31
29
  def database_id
32
- "mongoid_test"
30
+ 'mongoid_test'
33
31
  end
34
32
 
35
33
  # Can we connect to MongoHQ from this box?
36
34
  def mongohq_connectable?
37
- ENV["MONGOHQ_REPL_PASS"].present?
35
+ ENV['MONGOHQ_REPL_PASS'].present?
38
36
  end
39
37
 
40
38
  # Set the database that the spec suite connects to.
@@ -43,8 +41,8 @@ Mongoid.configure do |config|
43
41
  end
44
42
 
45
43
  # Autoload every model for the test suite that sits in spec/app/models.
46
- Dir[ File.join(MODELS, "*.rb") ].sort.each do |file|
47
- name = File.basename(file, ".rb")
44
+ Dir[File.join(MODELS, '*.rb')].sort.each do |file|
45
+ name = File.basename(file, '.rb')
48
46
  autoload name.camelize.to_sym, name
49
47
  end
50
48
 
@@ -59,7 +57,6 @@ module MyApp
59
57
  end
60
58
 
61
59
  RSpec.configure do |config|
62
-
63
60
  # Drop all collections before each spec.
64
61
  config.before(:each) do
65
62
  Mongoid.purge!
@@ -68,7 +65,7 @@ RSpec.configure do |config|
68
65
  # On travis we are creating many different databases on each test run. We
69
66
  # drop the database after the suite.
70
67
  config.after(:suite) do
71
- if ENV["CI"]
68
+ if ENV['CI']
72
69
  if defined?(Mongo)
73
70
  Mongo::Client.new(["#{HOST}:#{PORT}"], database: database_id).database.drop
74
71
  else
@@ -78,11 +75,11 @@ RSpec.configure do |config|
78
75
  end
79
76
 
80
77
  # Filter out MongoHQ specs if we can't connect to it.
81
- config.filter_run_excluding(config: ->(value){
78
+ config.filter_run_excluding(config: lambda do |value|
82
79
  return true if value == :mongohq && !mongohq_connectable?
83
- })
80
+ end)
84
81
  end
85
82
 
86
83
  ActiveSupport::Inflector.inflections do |inflect|
87
- inflect.singular("address_components", "address_component")
84
+ inflect.singular('address_components', 'address_component')
88
85
  end
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid-paranoia
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
+ - Durran Jordan
7
8
  - Mario Uher
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2015-11-05 00:00:00.000000000 Z
12
+ date: 2016-03-17 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: activesupport
@@ -94,12 +95,15 @@ dependencies:
94
95
  version: '3'
95
96
  description: There may be times when you don't want documents to actually get deleted
96
97
  from the database, but "flagged" as deleted.
97
- email: uher.mario@gmail.com
98
+ email:
99
+ - durran@gmail.com
100
+ - uher.mario@gmail.com
98
101
  executables: []
99
102
  extensions: []
100
103
  extra_rdoc_files: []
101
104
  files:
102
105
  - ".gitignore"
106
+ - ".rubocop.yml"
103
107
  - ".travis.yml"
104
108
  - Gemfile
105
109
  - README.md
@@ -158,7 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
158
162
  version: '0'
159
163
  requirements: []
160
164
  rubyforge_project:
161
- rubygems_version: 2.5.0
165
+ rubygems_version: 2.4.5.1
162
166
  signing_key:
163
167
  specification_version: 4
164
168
  summary: Extraction of mongoid-paranoia into its own gem.