mongoid-likeable 5.0.4 → 6.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/LICENSE +22 -17
- data/lib/mongoid/likeable.rb +3 -1
- data/lib/mongoid/likeable/version.rb +7 -0
- metadata +80 -35
- data/.coveralls.yml +0 -1
- data/.editorconfig +0 -15
- data/.gitignore +0 -39
- data/.travis.yml +0 -7
- data/CONTRIBUTING.md +0 -45
- data/Gemfile +0 -2
- data/Rakefile +0 -13
- data/mongoid-likeable.gemspec +0 -28
- data/test/models/story.rb +0 -6
- data/test/models/story_with_timestamps.rb +0 -7
- data/test/models/user.rb +0 -5
- data/test/mongoid_likeable_test.rb +0 -147
- data/test/test_helper.rb +0 -20
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b98c808c6bc776167b5ae11ef81a819e70884158
|
|
4
|
+
data.tar.gz: 0d8878095a287e1697e9dea1b292e4f9f0d024a0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0e2a2304e769e361b2bff5d13a3057420660bb40b38ab0b1ad32ad8d254cee91b69171066fad4bf544304b1419ebf6c3995b4297f20df2393895615ed197b45e
|
|
7
|
+
data.tar.gz: 6456ff9fd4130a0c479286d8b678bec1f742e39ebe7d904c865918a7ce5196d7e1961d76b1fd406aee67efc22b5919ef1bd76e9c7b23440d54b4bfee9f1ecf74
|
data/CHANGELOG.md
CHANGED
data/LICENSE
CHANGED
|
@@ -1,24 +1,29 @@
|
|
|
1
|
-
|
|
1
|
+
BSD 2-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017, diowa
|
|
2
4
|
All rights reserved.
|
|
3
5
|
|
|
4
6
|
Redistribution and use in source and binary forms, with or without
|
|
5
7
|
modification, are permitted provided that the following conditions are met:
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
9
|
+
* Redistributions of source code must retain the above copyright notice, this
|
|
10
|
+
list of conditions and the following disclaimer.
|
|
11
|
+
|
|
12
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
|
13
|
+
this list of conditions and the following disclaimer in the documentation
|
|
14
|
+
and/or other materials provided with the distribution.
|
|
15
|
+
|
|
16
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
17
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
18
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
19
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
20
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
21
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
22
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
23
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
24
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
25
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
26
|
+
|
|
27
|
+
|
|
23
28
|
|
|
24
29
|
mongoid-voteable is licensed under the MIT License - Copyright (c) 2012 Tom Bell
|
data/lib/mongoid/likeable.rb
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'mongoid'
|
|
2
4
|
|
|
3
5
|
module Mongoid
|
|
4
6
|
module Likeable
|
|
5
|
-
|
|
6
7
|
extend ActiveSupport::Concern
|
|
7
8
|
|
|
8
9
|
included do
|
|
@@ -30,6 +31,7 @@ module Mongoid
|
|
|
30
31
|
end
|
|
31
32
|
|
|
32
33
|
private
|
|
34
|
+
|
|
33
35
|
def liker_id(liker)
|
|
34
36
|
if liker.respond_to?(:_id)
|
|
35
37
|
liker._id
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mongoid-likeable
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 6.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- diowa
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2017-04-28 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: mongoid
|
|
@@ -16,70 +16,132 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '
|
|
19
|
+
version: '6.1'
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '
|
|
26
|
+
version: '6.1'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: activesupport
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '5.0'
|
|
34
|
+
- - "<"
|
|
35
|
+
- !ruby/object:Gem::Version
|
|
36
|
+
version: '5.2'
|
|
37
|
+
type: :development
|
|
38
|
+
prerelease: false
|
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
40
|
+
requirements:
|
|
41
|
+
- - "~>"
|
|
42
|
+
- !ruby/object:Gem::Version
|
|
43
|
+
version: '5.0'
|
|
44
|
+
- - "<"
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '5.2'
|
|
47
|
+
- !ruby/object:Gem::Dependency
|
|
48
|
+
name: coveralls
|
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - "~>"
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: 0.8.21
|
|
54
|
+
type: :development
|
|
55
|
+
prerelease: false
|
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
57
|
+
requirements:
|
|
58
|
+
- - "~>"
|
|
59
|
+
- !ruby/object:Gem::Version
|
|
60
|
+
version: 0.8.21
|
|
27
61
|
- !ruby/object:Gem::Dependency
|
|
28
62
|
name: database_cleaner
|
|
29
63
|
requirement: !ruby/object:Gem::Requirement
|
|
30
64
|
requirements:
|
|
31
65
|
- - "~>"
|
|
32
66
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: '1.
|
|
67
|
+
version: '1.5'
|
|
34
68
|
type: :development
|
|
35
69
|
prerelease: false
|
|
36
70
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
71
|
requirements:
|
|
38
72
|
- - "~>"
|
|
39
73
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: '1.
|
|
74
|
+
version: '1.5'
|
|
41
75
|
- !ruby/object:Gem::Dependency
|
|
42
|
-
name:
|
|
76
|
+
name: m
|
|
43
77
|
requirement: !ruby/object:Gem::Requirement
|
|
44
78
|
requirements:
|
|
45
79
|
- - "~>"
|
|
46
80
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: '
|
|
81
|
+
version: '1.5'
|
|
48
82
|
type: :development
|
|
49
83
|
prerelease: false
|
|
50
84
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
85
|
requirements:
|
|
52
86
|
- - "~>"
|
|
53
87
|
- !ruby/object:Gem::Version
|
|
54
|
-
version: '
|
|
88
|
+
version: '1.5'
|
|
55
89
|
- !ruby/object:Gem::Dependency
|
|
56
|
-
name:
|
|
90
|
+
name: minitest
|
|
57
91
|
requirement: !ruby/object:Gem::Requirement
|
|
58
92
|
requirements:
|
|
59
93
|
- - "~>"
|
|
60
94
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: '
|
|
95
|
+
version: '5.10'
|
|
62
96
|
type: :development
|
|
63
97
|
prerelease: false
|
|
64
98
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
99
|
requirements:
|
|
66
100
|
- - "~>"
|
|
67
101
|
- !ruby/object:Gem::Version
|
|
68
|
-
version: '
|
|
102
|
+
version: '5.10'
|
|
69
103
|
- !ruby/object:Gem::Dependency
|
|
70
|
-
name:
|
|
104
|
+
name: mocha
|
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
|
106
|
+
requirements:
|
|
107
|
+
- - "~>"
|
|
108
|
+
- !ruby/object:Gem::Version
|
|
109
|
+
version: '1.1'
|
|
110
|
+
type: :development
|
|
111
|
+
prerelease: false
|
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
113
|
+
requirements:
|
|
114
|
+
- - "~>"
|
|
115
|
+
- !ruby/object:Gem::Version
|
|
116
|
+
version: '1.1'
|
|
117
|
+
- !ruby/object:Gem::Dependency
|
|
118
|
+
name: rubocop
|
|
119
|
+
requirement: !ruby/object:Gem::Requirement
|
|
120
|
+
requirements:
|
|
121
|
+
- - "~>"
|
|
122
|
+
- !ruby/object:Gem::Version
|
|
123
|
+
version: 0.48.1
|
|
124
|
+
type: :development
|
|
125
|
+
prerelease: false
|
|
126
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
127
|
+
requirements:
|
|
128
|
+
- - "~>"
|
|
129
|
+
- !ruby/object:Gem::Version
|
|
130
|
+
version: 0.48.1
|
|
131
|
+
- !ruby/object:Gem::Dependency
|
|
132
|
+
name: simplecov
|
|
71
133
|
requirement: !ruby/object:Gem::Requirement
|
|
72
134
|
requirements:
|
|
73
135
|
- - "~>"
|
|
74
136
|
- !ruby/object:Gem::Version
|
|
75
|
-
version: 0.
|
|
137
|
+
version: 0.14.1
|
|
76
138
|
type: :development
|
|
77
139
|
prerelease: false
|
|
78
140
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
141
|
requirements:
|
|
80
142
|
- - "~>"
|
|
81
143
|
- !ruby/object:Gem::Version
|
|
82
|
-
version: 0.
|
|
144
|
+
version: 0.14.1
|
|
83
145
|
description: Add likes to your Mongoid documents
|
|
84
146
|
email:
|
|
85
147
|
- dev@diowa.com
|
|
@@ -87,23 +149,11 @@ executables: []
|
|
|
87
149
|
extensions: []
|
|
88
150
|
extra_rdoc_files: []
|
|
89
151
|
files:
|
|
90
|
-
- ".coveralls.yml"
|
|
91
|
-
- ".editorconfig"
|
|
92
|
-
- ".gitignore"
|
|
93
|
-
- ".travis.yml"
|
|
94
152
|
- CHANGELOG.md
|
|
95
|
-
- CONTRIBUTING.md
|
|
96
|
-
- Gemfile
|
|
97
153
|
- LICENSE
|
|
98
154
|
- README.md
|
|
99
|
-
- Rakefile
|
|
100
155
|
- lib/mongoid/likeable.rb
|
|
101
|
-
- mongoid
|
|
102
|
-
- test/models/story.rb
|
|
103
|
-
- test/models/story_with_timestamps.rb
|
|
104
|
-
- test/models/user.rb
|
|
105
|
-
- test/mongoid_likeable_test.rb
|
|
106
|
-
- test/test_helper.rb
|
|
156
|
+
- lib/mongoid/likeable/version.rb
|
|
107
157
|
homepage: https://github.com/diowa/mongoid-likeable
|
|
108
158
|
licenses:
|
|
109
159
|
- BSD-2-Clause
|
|
@@ -124,13 +174,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
124
174
|
version: '0'
|
|
125
175
|
requirements: []
|
|
126
176
|
rubyforge_project: mongoid-likeable
|
|
127
|
-
rubygems_version: 2.
|
|
177
|
+
rubygems_version: 2.6.11
|
|
128
178
|
signing_key:
|
|
129
179
|
specification_version: 4
|
|
130
180
|
summary: Add likes to your Mongoid documents
|
|
131
|
-
test_files:
|
|
132
|
-
- test/models/story.rb
|
|
133
|
-
- test/models/story_with_timestamps.rb
|
|
134
|
-
- test/models/user.rb
|
|
135
|
-
- test/mongoid_likeable_test.rb
|
|
136
|
-
- test/test_helper.rb
|
|
181
|
+
test_files: []
|
data/.coveralls.yml
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
repo_token: TeAdnB8m66zap1R2f0TJCoagvA3K92A4N
|
data/.editorconfig
DELETED
data/.gitignore
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
# Linux.gitignore
|
|
2
|
-
*~
|
|
3
|
-
|
|
4
|
-
# OSX.gitignore
|
|
5
|
-
.DS_Store
|
|
6
|
-
.AppleDouble
|
|
7
|
-
.LSOverride
|
|
8
|
-
Icon
|
|
9
|
-
|
|
10
|
-
# Thumbnails
|
|
11
|
-
._*
|
|
12
|
-
|
|
13
|
-
# Files that might appear on external disk
|
|
14
|
-
.Spotlight-V100
|
|
15
|
-
.Trashes
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
# Ruby.gitignore
|
|
19
|
-
*.gem
|
|
20
|
-
*.rbc
|
|
21
|
-
.bundle
|
|
22
|
-
.config
|
|
23
|
-
coverage
|
|
24
|
-
InstalledFiles
|
|
25
|
-
lib/bundler/man
|
|
26
|
-
pkg
|
|
27
|
-
rdoc
|
|
28
|
-
spec/reports
|
|
29
|
-
test/tmp
|
|
30
|
-
test/version_tmp
|
|
31
|
-
tmp
|
|
32
|
-
.rvmrc
|
|
33
|
-
|
|
34
|
-
# YARD artifacts
|
|
35
|
-
.yardoc
|
|
36
|
-
_yardoc
|
|
37
|
-
doc/
|
|
38
|
-
|
|
39
|
-
Gemfile.lock
|
data/.travis.yml
DELETED
data/CONTRIBUTING.md
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
# Contributing to mongoid-likeable
|
|
2
|
-
|
|
3
|
-
Looking to contribute something to mongoid-likeable? **Here's how you can help.**
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
## Reporting issues
|
|
8
|
-
|
|
9
|
-
We only accept issues that are bug reports or feature requests. Bugs must be isolated and reproducible problems that we can fix within the mongoid-likeable core. Please read the following guidelines before opening any issue.
|
|
10
|
-
|
|
11
|
-
1. **Search for existing issues.**
|
|
12
|
-
2. **Create an isolated and reproducible test case.**
|
|
13
|
-
3. **Include a live example if possible.**
|
|
14
|
-
4. **Share as much information as possible.** Include at least Rails version, mongoid version and gem version. Also include steps to reproduce the bug.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
## Key branches
|
|
19
|
-
|
|
20
|
-
- `master` is the latest, deployed version. **Never make pull requests against this branch.**
|
|
21
|
-
- `develop` is the official development branch for the next release.
|
|
22
|
-
|
|
23
|
-
Take a look at [git-flow, A successful Git branching model](http://nvie.com/posts/a-successful-git-branching-model/)
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
## Pull requests
|
|
28
|
-
|
|
29
|
-
- Try to submit pull requests against the `develop` branch for easier merging
|
|
30
|
-
- Try not to pollute your pull request with unintended changes--keep them simple and small
|
|
31
|
-
- **Test. Code coverage should never go below 100%.** If you find a bug, write at first a failing test case and then fix it.
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
## Coding standards
|
|
36
|
-
|
|
37
|
-
### Ruby
|
|
38
|
-
|
|
39
|
-
- [Ruby Styleguide](https://github.com/styleguide/ruby)
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
## License
|
|
44
|
-
|
|
45
|
-
By contributing your code, you agree to license your contribution under the terms of the [BSD 2-Clause License](LICENSE)
|
data/Gemfile
DELETED
data/Rakefile
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
require 'rake/testtask'
|
|
2
|
-
task :default => "test"
|
|
3
|
-
|
|
4
|
-
Rake::TestTask.new(:test) do |test|
|
|
5
|
-
test.libs << 'lib' << 'test'
|
|
6
|
-
test.pattern = 'test/**/*_test.rb'
|
|
7
|
-
test.verbose = true
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
desc "Open an irb session preloaded with this library"
|
|
11
|
-
task :console do
|
|
12
|
-
sh "irb -rubygems -r ./lib/mongoid/likeable.rb"
|
|
13
|
-
end
|
data/mongoid-likeable.gemspec
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
|
2
|
-
$:.push File.expand_path('../lib', __FILE__)
|
|
3
|
-
|
|
4
|
-
Gem::Specification.new do |s|
|
|
5
|
-
s.name = 'mongoid-likeable'
|
|
6
|
-
s.version = '5.0.4'
|
|
7
|
-
s.platform = Gem::Platform::RUBY
|
|
8
|
-
s.authors = ['diowa']
|
|
9
|
-
s.email = ['dev@diowa.com']
|
|
10
|
-
s.homepage = 'https://github.com/diowa/mongoid-likeable'
|
|
11
|
-
s.summary = 'Add likes to your Mongoid documents'
|
|
12
|
-
s.license = 'BSD-2-Clause'
|
|
13
|
-
s.description = s.summary
|
|
14
|
-
|
|
15
|
-
s.rubyforge_project = 'mongoid-likeable'
|
|
16
|
-
|
|
17
|
-
s.add_dependency 'mongoid', '~> 4.0'
|
|
18
|
-
|
|
19
|
-
s.add_development_dependency 'database_cleaner', '~> 1.3'
|
|
20
|
-
s.add_development_dependency 'rake', '~> 10.4'
|
|
21
|
-
s.add_development_dependency 'delorean', '~> 2.1'
|
|
22
|
-
s.add_development_dependency 'coveralls', '~> 0.7.1'
|
|
23
|
-
|
|
24
|
-
s.files = `git ls-files`.split("\n")
|
|
25
|
-
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
26
|
-
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
|
27
|
-
s.require_paths = ['lib']
|
|
28
|
-
end
|
data/test/models/story.rb
DELETED
data/test/models/user.rb
DELETED
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
require 'test_helper'
|
|
2
|
-
require 'delorean'
|
|
3
|
-
|
|
4
|
-
class TestMongoidLikeable < MiniTest::Unit::TestCase
|
|
5
|
-
def setup
|
|
6
|
-
DatabaseCleaner.start
|
|
7
|
-
|
|
8
|
-
@simon = User.create name: 'Simon'
|
|
9
|
-
@emily = User.create name: 'Emily'
|
|
10
|
-
@story = Story.create name: 'Mongoid Rocks'
|
|
11
|
-
Delorean.time_travel_to(5.minutes.ago) { @story_with_timestamps = StoryWithTimestamps.create name: 'Mongoid Rocks' }
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def teardown
|
|
15
|
-
DatabaseCleaner.clean
|
|
16
|
-
Delorean.back_to_the_present
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def test_add_likes_field_to_document
|
|
20
|
-
refute_nil Story.fields['likes']
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def test_add_likers_field_to_document
|
|
24
|
-
refute_nil Story.fields['likers']
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def test_defines_like_method
|
|
28
|
-
story = Story.new
|
|
29
|
-
assert story.respond_to?('like')
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def test_defines_unlike_method
|
|
33
|
-
story = Story.new
|
|
34
|
-
assert story.respond_to?('unlike')
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def test_defines_liked_method
|
|
38
|
-
story = Story.new
|
|
39
|
-
assert story.respond_to?('liked?')
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def test_tracks_number_of_likers
|
|
43
|
-
@story.like @simon
|
|
44
|
-
@story.like @emily
|
|
45
|
-
assert_equal 2, @story.likes
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def test_can_like_by_user_id
|
|
49
|
-
@story.like @simon._id
|
|
50
|
-
assert_equal 1, @story.likes
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
def test_can_like_by_user
|
|
54
|
-
@story.like @simon
|
|
55
|
-
assert_equal 1, @story.likes
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
def test_can_unlike_by_user
|
|
59
|
-
@story.like @simon
|
|
60
|
-
assert_equal 1, @story.likes
|
|
61
|
-
@story.unlike @simon
|
|
62
|
-
assert_equal 0, @story.likes
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
def test_limits_one_like_per_liker
|
|
66
|
-
@story.like @simon
|
|
67
|
-
@story.like @simon
|
|
68
|
-
assert_equal 1, @story.likes
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
def test_successful_like_return_value
|
|
72
|
-
assert_equal true, @story.like(@simon)
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
def test_failed_like_return_value
|
|
76
|
-
@story.like @simon
|
|
77
|
-
assert_equal nil, @story.like(@simon)
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
def test_knows_who_has_liked
|
|
81
|
-
@story.like @simon
|
|
82
|
-
assert @story.liked? @simon
|
|
83
|
-
refute @story.liked? @emily
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
def test_updates_collection_correctly
|
|
87
|
-
@story.like @simon
|
|
88
|
-
@story.like @emily
|
|
89
|
-
story = Story.where(:name => 'Mongoid Rocks').first
|
|
90
|
-
assert_equal 2, story.likes
|
|
91
|
-
assert story.liked? @simon
|
|
92
|
-
assert story.liked? @emily
|
|
93
|
-
story.unlike @simon
|
|
94
|
-
story = Story.where(:name => 'Mongoid Rocks').first
|
|
95
|
-
assert_equal 1, story.likes
|
|
96
|
-
refute story.liked? @simon
|
|
97
|
-
assert story.liked? @emily
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
def test_touches_updated_at_when_liking
|
|
101
|
-
updated_at = @story_with_timestamps.updated_at
|
|
102
|
-
Delorean.time_travel_to(1.month.from_now) { @story_with_timestamps.like @simon }
|
|
103
|
-
assert @story_with_timestamps.updated_at > updated_at
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
def test_does_not_touche_updated_at_when_liking_without_success
|
|
107
|
-
@story_with_timestamps.like @simon
|
|
108
|
-
updated_at = @story_with_timestamps.updated_at
|
|
109
|
-
Delorean.time_travel_to(1.month.from_now) { @story_with_timestamps.like @simon }
|
|
110
|
-
assert @story_with_timestamps.updated_at == updated_at
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
def test_touches_updated_at_when_unliking
|
|
114
|
-
@story_with_timestamps.like @simon
|
|
115
|
-
updated_at = @story_with_timestamps.updated_at
|
|
116
|
-
Delorean.time_travel_to(1.month.from_now) { @story_with_timestamps.unlike @simon }
|
|
117
|
-
assert @story_with_timestamps.updated_at > updated_at
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
def test_does_not_touche_updated_at_when_unliking_without_success
|
|
121
|
-
updated_at = @story_with_timestamps.updated_at
|
|
122
|
-
Delorean.time_travel_to(1.month.from_now) { @story_with_timestamps.unlike @simon }
|
|
123
|
-
assert @story_with_timestamps.updated_at == updated_at
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
def test_touches_updated_at_and_updates_collection_correctly
|
|
127
|
-
updated_at = @story_with_timestamps.updated_at
|
|
128
|
-
Delorean.time_travel_to(1.month.from_now) do
|
|
129
|
-
@story_with_timestamps.like @simon
|
|
130
|
-
@story_with_timestamps.like @emily
|
|
131
|
-
end
|
|
132
|
-
story = StoryWithTimestamps.where(:name => 'Mongoid Rocks').first
|
|
133
|
-
assert_equal 2, story.likes
|
|
134
|
-
assert story.liked? @simon
|
|
135
|
-
assert story.liked? @emily
|
|
136
|
-
assert story.updated_at > updated_at
|
|
137
|
-
updated_at = @story_with_timestamps.updated_at
|
|
138
|
-
Delorean.time_travel_to(1.month.from_now) do
|
|
139
|
-
story.unlike @simon
|
|
140
|
-
end
|
|
141
|
-
story = StoryWithTimestamps.where(:name => 'Mongoid Rocks').first
|
|
142
|
-
assert_equal 1, story.likes
|
|
143
|
-
refute story.liked? @simon
|
|
144
|
-
assert story.liked? @emily
|
|
145
|
-
assert story.updated_at > updated_at
|
|
146
|
-
end
|
|
147
|
-
end
|
data/test/test_helper.rb
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
$:.unshift(File.expand_path("../../lib", __FILE__))
|
|
2
|
-
|
|
3
|
-
if ENV['CI']
|
|
4
|
-
require 'coveralls'
|
|
5
|
-
Coveralls.wear!
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
require 'minitest/autorun'
|
|
9
|
-
require 'database_cleaner'
|
|
10
|
-
|
|
11
|
-
require 'mongoid'
|
|
12
|
-
require 'mongoid/likeable'
|
|
13
|
-
|
|
14
|
-
Dir["#{File.dirname(__FILE__)}/models/*.rb"].each { |f| require f }
|
|
15
|
-
|
|
16
|
-
Mongoid.connect_to('mongoid-likeable-test')
|
|
17
|
-
Mongoid.logger = Logger.new $stdout
|
|
18
|
-
|
|
19
|
-
DatabaseCleaner.orm = 'mongoid'
|
|
20
|
-
DatabaseCleaner.strategy = :truncation
|