mention_system 0.0.6
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 +7 -0
- data/.empty +0 -0
- data/.gitignore +15 -0
- data/.keep +0 -0
- data/.rspec +2 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +23 -0
- data/Appraisals +7 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +170 -0
- data/Rakefile +8 -0
- data/gemfiles/.empty +0 -0
- data/gemfiles/.gitignore +0 -0
- data/gemfiles/.keep +0 -0
- data/gemfiles/rails4.1.gemfile +7 -0
- data/gemfiles/rails4.2.gemfile +7 -0
- data/lib/.empty +0 -0
- data/lib/.gitignore +0 -0
- data/lib/.keep +0 -0
- data/lib/generators/.empty +0 -0
- data/lib/generators/.gitignore +0 -0
- data/lib/generators/.keep +0 -0
- data/lib/generators/mention_system/.empty +0 -0
- data/lib/generators/mention_system/.gitignore +0 -0
- data/lib/generators/mention_system/.keep +0 -0
- data/lib/generators/mention_system/mention_system_generator.rb +46 -0
- data/lib/generators/mention_system/templates/.empty +0 -0
- data/lib/generators/mention_system/templates/.gitignore +0 -0
- data/lib/generators/mention_system/templates/.keep +0 -0
- data/lib/generators/mention_system/templates/migration.rb +47 -0
- data/lib/mention_system.rb +46 -0
- data/lib/mention_system/.empty +0 -0
- data/lib/mention_system/.gitignore +0 -0
- data/lib/mention_system/.keep +0 -0
- data/lib/mention_system/mention.rb +155 -0
- data/lib/mention_system/mention_processor.rb +141 -0
- data/lib/mention_system/mentionee.rb +58 -0
- data/lib/mention_system/mentioner.rb +88 -0
- data/lib/mention_system/version.rb +12 -0
- data/mention_system.gemspec +31 -0
- data/spec/.empty +0 -0
- data/spec/.gitignore +0 -0
- data/spec/.keep +0 -0
- data/spec/db/.empty +0 -0
- data/spec/db/.gitignore +0 -0
- data/spec/db/.keep +0 -0
- data/spec/db/migrate/.empty +0 -0
- data/spec/db/migrate/.gitignore +0 -0
- data/spec/db/migrate/.keep +0 -0
- data/spec/db/migrate/20140926000000_create_mentions.rb +47 -0
- data/spec/db/migrate/20140926000005_create_dummy_mentioners.rb +22 -0
- data/spec/db/migrate/20140926000010_create_dummy_mentionees.rb +22 -0
- data/spec/mention_system/.empty +0 -0
- data/spec/mention_system/.gitignore +0 -0
- data/spec/mention_system/.keep +0 -0
- data/spec/mention_system/mention_processor_spec.rb +155 -0
- data/spec/mention_system/mention_spec.rb +177 -0
- data/spec/mention_system/mentionee_spec.rb +69 -0
- data/spec/mention_system/mentioner_spec.rb +96 -0
- data/spec/spec_helper.rb +116 -0
- data/spec/support/.empty +0 -0
- data/spec/support/.gitignore +0 -0
- data/spec/support/.keep +0 -0
- data/spec/support/active_record.rb +12 -0
- data/spec/support/shoulda_matchers.rb +2 -0
- metadata +240 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'mention_system/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "mention_system"
|
|
8
|
+
spec.version = MentionSystem::VERSION
|
|
9
|
+
spec.authors = ["Pablo Martin Viva"]
|
|
10
|
+
spec.email = ["pmviva@gmail.com"]
|
|
11
|
+
spec.summary = %q{An active record like system.}
|
|
12
|
+
spec.description = %q{An active record mention system developed using ruby on rails 4.1 applying domain driven design and test driven development principles.}
|
|
13
|
+
spec.homepage = "http://github.com/pmviva/mention_system"
|
|
14
|
+
spec.license = "MIT"
|
|
15
|
+
|
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
19
|
+
spec.require_paths = ["lib"]
|
|
20
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.0.0")
|
|
21
|
+
|
|
22
|
+
spec.add_dependency "rails", [ ">= 4.1", "< 5" ]
|
|
23
|
+
|
|
24
|
+
spec.add_development_dependency "appraisal", "~> 2.0"
|
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
|
26
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
27
|
+
spec.add_development_dependency "rspec", "~> 3.1"
|
|
28
|
+
spec.add_development_dependency "shoulda-matchers", "~> 2.7"
|
|
29
|
+
spec.add_development_dependency "sqlite3", "~> 1.3"
|
|
30
|
+
end
|
|
31
|
+
|
data/spec/.empty
ADDED
|
File without changes
|
data/spec/.gitignore
ADDED
|
File without changes
|
data/spec/.keep
ADDED
|
File without changes
|
data/spec/db/.empty
ADDED
|
File without changes
|
data/spec/db/.gitignore
ADDED
|
File without changes
|
data/spec/db/.keep
ADDED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
###
|
|
2
|
+
# CreateMentions class
|
|
3
|
+
#
|
|
4
|
+
# This class defines the test create mentions migration in mention system
|
|
5
|
+
###
|
|
6
|
+
class CreateMentions < ActiveRecord::Migration
|
|
7
|
+
###
|
|
8
|
+
# Changes the database
|
|
9
|
+
###
|
|
10
|
+
def change
|
|
11
|
+
###
|
|
12
|
+
# Mentions table creation
|
|
13
|
+
###
|
|
14
|
+
create_table :mentions do |t|
|
|
15
|
+
###
|
|
16
|
+
# Mentionee id field and mentionee type field definition
|
|
17
|
+
###
|
|
18
|
+
t.references :mentionee, polymorphic: true
|
|
19
|
+
|
|
20
|
+
###
|
|
21
|
+
# Mentioner id fiel and mentioner type field definition
|
|
22
|
+
###
|
|
23
|
+
t.references :mentioner, polymorphic: true
|
|
24
|
+
|
|
25
|
+
###
|
|
26
|
+
# Timestamps fields definition
|
|
27
|
+
###
|
|
28
|
+
t.timestamps null: false
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
###
|
|
32
|
+
# Mentions table mentionee id field and mentionee type field index addition
|
|
33
|
+
###
|
|
34
|
+
add_index :mentions, [:mentionee_id, :mentionee_type], name: "mentions_mentionee_idx"
|
|
35
|
+
|
|
36
|
+
###
|
|
37
|
+
# Mentions table mentioner id field and mentioner type field index addition
|
|
38
|
+
###
|
|
39
|
+
add_index :mentions, [:mentioner_id, :mentioner_type], name: "mentions_mentioner_idx"
|
|
40
|
+
|
|
41
|
+
###
|
|
42
|
+
# Mentions table mentionee id field and mentionee type field and mentioner id field and mentioner type field unique index addition
|
|
43
|
+
###
|
|
44
|
+
add_index :mentions, [:mentionee_id, :mentionee_type, :mentioner_id, :mentioner_type], name: "mentions_mentionee_mentioner_idx", unique: true
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
###
|
|
2
|
+
# CreateDummyMentioners class
|
|
3
|
+
#
|
|
4
|
+
# This class defines the create dummy mentioners migration in mention system
|
|
5
|
+
###
|
|
6
|
+
class CreateDummyMentioners < ActiveRecord::Migration
|
|
7
|
+
###
|
|
8
|
+
# Changes the database
|
|
9
|
+
###
|
|
10
|
+
def change
|
|
11
|
+
###
|
|
12
|
+
# Dummy mentioners table creation
|
|
13
|
+
###
|
|
14
|
+
create_table :dummy_mentioners do |t|
|
|
15
|
+
###
|
|
16
|
+
# Timestamps fields definition
|
|
17
|
+
###
|
|
18
|
+
t.timestamps null: false
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
###
|
|
2
|
+
# CreateDummyMentionees class
|
|
3
|
+
#
|
|
4
|
+
# This class defines the create dummy mentionees migration in mention system
|
|
5
|
+
###
|
|
6
|
+
class CreateDummyMentionees < ActiveRecord::Migration
|
|
7
|
+
###
|
|
8
|
+
# Changes the database
|
|
9
|
+
###
|
|
10
|
+
def change
|
|
11
|
+
###
|
|
12
|
+
# Dummy mentionees table creation
|
|
13
|
+
###
|
|
14
|
+
create_table :dummy_mentionees do |t|
|
|
15
|
+
###
|
|
16
|
+
# Timestamps fields definition
|
|
17
|
+
###
|
|
18
|
+
t.timestamps null: false
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
###
|
|
4
|
+
# Describes MentionSystem::MentionProcessor
|
|
5
|
+
###
|
|
6
|
+
describe MentionSystem::MentionProcessor do
|
|
7
|
+
###
|
|
8
|
+
# Let mention_processor be MentionSystem::MentionProcessor.new
|
|
9
|
+
###
|
|
10
|
+
let(:mention_processor) { MentionSystem::MentionProcessor.new }
|
|
11
|
+
|
|
12
|
+
###
|
|
13
|
+
# Let mentionee be DummyMentionee.create
|
|
14
|
+
###
|
|
15
|
+
let(:mentionee) { DummyMentionee.create }
|
|
16
|
+
|
|
17
|
+
###
|
|
18
|
+
# Let mentioner be DummyMentioner.create
|
|
19
|
+
###
|
|
20
|
+
let(:mentioner) { DummyMentioner.create }
|
|
21
|
+
|
|
22
|
+
###
|
|
23
|
+
# Describes instance methods
|
|
24
|
+
###
|
|
25
|
+
describe "instance methods" do
|
|
26
|
+
###
|
|
27
|
+
# Should process mentions with default mention prefix
|
|
28
|
+
###
|
|
29
|
+
it "should process mentions with default mention prefix" do
|
|
30
|
+
expect(mention_processor).to receive(:extract_mentioner_content).with(mentioner) { "This is the mentioner content with @handle1 and @handle2" }
|
|
31
|
+
|
|
32
|
+
expect(mention_processor).to receive(:find_mentionees_by_handles).with(["handle1", "handle2"]) { [mentionee] }
|
|
33
|
+
|
|
34
|
+
expect(mentioner).to receive(:mention).with(mentionee) { true }
|
|
35
|
+
|
|
36
|
+
mention_processor.process_mentions(mentioner)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
###
|
|
40
|
+
# Should process mentions with overriden mention prefix
|
|
41
|
+
###
|
|
42
|
+
it "should process mentions with overriden mention prefix" do
|
|
43
|
+
expect(mention_processor).to receive(:mention_prefix).exactly(3).times { "#" }
|
|
44
|
+
|
|
45
|
+
expect(mention_processor).to receive(:extract_mentioner_content).with(mentioner) { "This is the mentioner content with #handle1 and #handle2" }
|
|
46
|
+
|
|
47
|
+
expect(mention_processor).to receive(:find_mentionees_by_handles).with(["handle1", "handle2"]) { [mentionee] }
|
|
48
|
+
|
|
49
|
+
expect(mentioner).to receive(:mention).with(mentionee) { true }
|
|
50
|
+
|
|
51
|
+
mention_processor.process_mentions(mentioner)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
###
|
|
55
|
+
# Should invooke after callbacks when processing mentions
|
|
56
|
+
###
|
|
57
|
+
it "should invoke after callbacks when processing mentions" do
|
|
58
|
+
callback = Proc.new { }
|
|
59
|
+
|
|
60
|
+
mention_processor.add_after_callback(callback)
|
|
61
|
+
mention_processor.add_after_callback(callback)
|
|
62
|
+
|
|
63
|
+
expect(callback).to receive(:call).exactly(2).times { true }
|
|
64
|
+
|
|
65
|
+
expect(mention_processor).to receive(:extract_mentioner_content).with(mentioner) { "This is the mentioner content with @handle1 and @handle2" }
|
|
66
|
+
|
|
67
|
+
expect(mention_processor).to receive(:find_mentionees_by_handles).with(["handle1", "handle2"]) { [mentionee] }
|
|
68
|
+
|
|
69
|
+
expect(mentioner).to receive(:mention).with(mentionee) { true }
|
|
70
|
+
|
|
71
|
+
mention_processor.process_mentions(mentioner)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
###
|
|
75
|
+
# Should stop processing when invoke after callback returns false
|
|
76
|
+
###
|
|
77
|
+
it "should sto processing when invoke after callback returns false" do
|
|
78
|
+
callback = Proc.new { }
|
|
79
|
+
|
|
80
|
+
mention_processor.add_after_callback(callback)
|
|
81
|
+
mention_processor.add_after_callback(callback)
|
|
82
|
+
|
|
83
|
+
expect(callback).to receive(:call).once { false }
|
|
84
|
+
|
|
85
|
+
expect(mention_processor).to receive(:extract_mentioner_content).with(mentioner) { "This is the mentioner content with @handle1 and @handle2" }
|
|
86
|
+
|
|
87
|
+
expect(mention_processor).to receive(:find_mentionees_by_handles).with(["handle1", "handle2"]) { [mentionee] }
|
|
88
|
+
|
|
89
|
+
expect(mentioner).to receive(:mention).with(mentionee) { true }
|
|
90
|
+
|
|
91
|
+
mention_processor.process_mentions(mentioner)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
###
|
|
95
|
+
# Should invoke before callbacks when processing mentions
|
|
96
|
+
###
|
|
97
|
+
it "should invoke before callbacks when processing mentions" do
|
|
98
|
+
callback = Proc.new {}
|
|
99
|
+
|
|
100
|
+
mention_processor.add_before_callback(callback)
|
|
101
|
+
mention_processor.add_before_callback(callback)
|
|
102
|
+
|
|
103
|
+
expect(callback).to receive(:call).exactly(2).times { true }
|
|
104
|
+
|
|
105
|
+
expect(mention_processor).to receive(:extract_mentioner_content).with(mentioner) { "This is the mentioner content with @handle1 and @handle2" }
|
|
106
|
+
|
|
107
|
+
expect(mention_processor).to receive(:find_mentionees_by_handles).with(["handle1", "handle2"]) { [mentionee] }
|
|
108
|
+
|
|
109
|
+
expect(mentioner).to receive(:mention).with(mentionee) { true }
|
|
110
|
+
|
|
111
|
+
mention_processor.process_mentions(mentioner)
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
###
|
|
115
|
+
# Should stop processing when invoke before callbacks returns false
|
|
116
|
+
###
|
|
117
|
+
it "should stop processing when invoke before callback returns false" do
|
|
118
|
+
callback = Proc.new {}
|
|
119
|
+
|
|
120
|
+
mention_processor.add_before_callback(callback)
|
|
121
|
+
mention_processor.add_before_callback(callback)
|
|
122
|
+
|
|
123
|
+
expect(callback).to receive(:call).once { false }
|
|
124
|
+
|
|
125
|
+
expect(mention_processor).to receive(:extract_mentioner_content).with(mentioner) { "This is the mentioner content with @handle1 and @handle2" }
|
|
126
|
+
|
|
127
|
+
expect(mention_processor).to receive(:find_mentionees_by_handles).with(["handle1", "handle2"]) { [mentionee] }
|
|
128
|
+
|
|
129
|
+
expect(mentioner).to receive(:mention).with(mentionee).at_most(0).times
|
|
130
|
+
|
|
131
|
+
mention_processor.process_mentions(mentioner)
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
###
|
|
135
|
+
# Should stop processing when mention returns false
|
|
136
|
+
###
|
|
137
|
+
it "should stop processing when mention returns false" do
|
|
138
|
+
callback = Proc.new {}
|
|
139
|
+
|
|
140
|
+
mention_processor.add_after_callback(callback)
|
|
141
|
+
mention_processor.add_after_callback(callback)
|
|
142
|
+
|
|
143
|
+
expect(callback).to receive(:call).at_most(0).times
|
|
144
|
+
|
|
145
|
+
expect(mention_processor).to receive(:extract_mentioner_content).with(mentioner) { "This is the mentioner content with @handle1 and @handle2" }
|
|
146
|
+
|
|
147
|
+
expect(mention_processor).to receive(:find_mentionees_by_handles).with(["handle1", "handle2"]) { [mentionee] }
|
|
148
|
+
|
|
149
|
+
expect(mentioner).to receive(:mention).with(mentionee) { false }
|
|
150
|
+
|
|
151
|
+
mention_processor.process_mentions(mentioner)
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
###
|
|
4
|
+
# Describes MentionSystem::Mention
|
|
5
|
+
###
|
|
6
|
+
describe MentionSystem::Mention do
|
|
7
|
+
###
|
|
8
|
+
# Let mentionee be DummyMentionee.create
|
|
9
|
+
###
|
|
10
|
+
let(:mentionee) { DummyMentionee.create }
|
|
11
|
+
|
|
12
|
+
###
|
|
13
|
+
# Let mentioner be DummyMentioner.create
|
|
14
|
+
###
|
|
15
|
+
let(:mentioner) { DummyMentioner.create }
|
|
16
|
+
|
|
17
|
+
###
|
|
18
|
+
# Describes associations
|
|
19
|
+
###
|
|
20
|
+
describe "associations" do
|
|
21
|
+
###
|
|
22
|
+
# Should belong to mentionee
|
|
23
|
+
###
|
|
24
|
+
it "should belong to mentionee" do
|
|
25
|
+
should belong_to(:mentionee)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
###
|
|
29
|
+
# Should belong to mentioner
|
|
30
|
+
###
|
|
31
|
+
it "should belong to mentioner" do
|
|
32
|
+
should belong_to(:mentioner)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
###
|
|
37
|
+
# Describes class methods
|
|
38
|
+
###
|
|
39
|
+
describe "class methods" do
|
|
40
|
+
###
|
|
41
|
+
# Should raise argument error on invalid mentionee when mentions
|
|
42
|
+
###
|
|
43
|
+
it "should raise argument error on invalid mentionee when mentions" do
|
|
44
|
+
expect { MentionSystem::Mention.mention(mentioner, mentioner) }.to raise_error ArgumentError
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
###
|
|
48
|
+
# Should raise argument error on invalid mentioner when mentions
|
|
49
|
+
###
|
|
50
|
+
it "should raise argument error on invalid mentioner when mentions " do
|
|
51
|
+
expect { MentionSystem::Mention.mention(mentionee, mentionee) }.to raise_error ArgumentError
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
###
|
|
55
|
+
# Should mention
|
|
56
|
+
###
|
|
57
|
+
it "should mention" do
|
|
58
|
+
expect(MentionSystem::Mention.mention(mentioner, mentionee)).to equal(true)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
###
|
|
62
|
+
# Should not mention
|
|
63
|
+
###
|
|
64
|
+
it "should not mention" do
|
|
65
|
+
MentionSystem::Mention.mention(mentioner, mentionee)
|
|
66
|
+
|
|
67
|
+
expect(MentionSystem::Mention.mention(mentioner, mentionee)).to equal(false)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
###
|
|
71
|
+
# Should raise argument error on invalid mentionee when unmentions
|
|
72
|
+
###
|
|
73
|
+
it "should raise argument error on invalid mentionee when unmentions" do
|
|
74
|
+
expect { MentionSystem::Mention.unmention(mentioner, mentioner) }.to raise_error ArgumentError
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
###
|
|
78
|
+
# Should raise argument error on invalid mentioner when unmentions
|
|
79
|
+
###
|
|
80
|
+
it "should raise argument error on invalid mentioner when unmentions" do
|
|
81
|
+
expect { MentionSystem::Mention.unmention(mentionee, mentionee) }.to raise_error ArgumentError
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
###
|
|
85
|
+
# Should unmention
|
|
86
|
+
###
|
|
87
|
+
it "should unmention" do
|
|
88
|
+
MentionSystem::Mention.mention(mentioner, mentionee)
|
|
89
|
+
|
|
90
|
+
expect(MentionSystem::Mention.unmention(mentioner, mentionee)).to equal(true)
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
###
|
|
94
|
+
# Should not unmention
|
|
95
|
+
###
|
|
96
|
+
it "should not unmention" do
|
|
97
|
+
expect(MentionSystem::Mention.unmention(mentioner, mentionee)).to equal(false)
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
###
|
|
101
|
+
# Should raise argument error on invalid mentionee when toggle mention
|
|
102
|
+
###
|
|
103
|
+
it "should raise argument error on invalid mentionee when toggle mention" do
|
|
104
|
+
expect { MentionSystem::Mention.toggle_mention(mentioner, mentioner) }.to raise_error ArgumentError
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
###
|
|
108
|
+
# Should raise argument error on invalid mentioner when toggle mention
|
|
109
|
+
###
|
|
110
|
+
it "should raise argument error on invalid mentioner when toggle mention" do
|
|
111
|
+
expect { MentionSystem::Mention.toggle_mention(mentionee, mentionee) }.to raise_error ArgumentError
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
###
|
|
115
|
+
# Should toggle mention
|
|
116
|
+
###
|
|
117
|
+
it "should toggle mention" do
|
|
118
|
+
expect(MentionSystem::Mention.mentions?(mentioner, mentionee)).to equal(false)
|
|
119
|
+
|
|
120
|
+
MentionSystem::Mention.toggle_mention(mentioner, mentionee)
|
|
121
|
+
|
|
122
|
+
expect(MentionSystem::Mention.mentions?(mentioner, mentionee)).to equal(true)
|
|
123
|
+
|
|
124
|
+
MentionSystem::Mention.toggle_mention(mentioner, mentionee)
|
|
125
|
+
|
|
126
|
+
expect(MentionSystem::Mention.mentions?(mentioner, mentionee)).to equal(false)
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
###
|
|
130
|
+
# Should specify if mentions
|
|
131
|
+
###
|
|
132
|
+
it "should specify if mentions" do
|
|
133
|
+
expect(MentionSystem::Mention.mentions?(mentioner, mentionee)).to equal(false)
|
|
134
|
+
|
|
135
|
+
MentionSystem::Mention.mention(mentioner, mentionee)
|
|
136
|
+
|
|
137
|
+
expect(MentionSystem::Mention.mentions?(mentioner, mentionee)).to equal(true)
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
###
|
|
141
|
+
# Should scope mentions by mentionee
|
|
142
|
+
###
|
|
143
|
+
it "should scope mentions by mentionee" do
|
|
144
|
+
scope = MentionSystem::Mention.where(mentionee: mentionee)
|
|
145
|
+
|
|
146
|
+
expect(MentionSystem::Mention.scope_by_mentionee(mentionee)).to eq(scope)
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
###
|
|
150
|
+
# Should scope mentions by mentionee type
|
|
151
|
+
####
|
|
152
|
+
it "should scope mentions by mentionee type" do
|
|
153
|
+
scope = MentionSystem::Mention.where(mentionee_type: DummyMentionee)
|
|
154
|
+
|
|
155
|
+
expect(MentionSystem::Mention.scope_by_mentionee_type(DummyMentionee)).to eq(scope)
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
###
|
|
159
|
+
# Should scope mentions by mentioner
|
|
160
|
+
###
|
|
161
|
+
it "should scope mentions by mentioner" do
|
|
162
|
+
scope = MentionSystem::Mention.where(mentioner: mentioner)
|
|
163
|
+
|
|
164
|
+
expect(MentionSystem::Mention.scope_by_mentioner(mentioner)).to eq(scope)
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
###
|
|
168
|
+
# Should scope mentions by mentioner type
|
|
169
|
+
####
|
|
170
|
+
it "should scope mentions by mentioner type" do
|
|
171
|
+
scope = MentionSystem::Mention.where(mentioner_type: DummyMentioner)
|
|
172
|
+
|
|
173
|
+
expect(MentionSystem::Mention.scope_by_mentioner_type(DummyMentioner)).to eq(scope)
|
|
174
|
+
end
|
|
175
|
+
end
|
|
176
|
+
end
|
|
177
|
+
|