acts-as-messageable 0.4.10 → 0.4.11
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 +5 -5
- data/.rspec +1 -1
- data/.travis.yml +16 -14
- data/Appraisals +30 -27
- data/Gemfile +10 -10
- data/Gemfile.lock +124 -98
- data/README.md +4 -5
- data/Rakefile +8 -10
- data/VERSION +1 -1
- data/acts-as-messageable.gemspec +45 -43
- data/gemfiles/rails_3.2.gemfile +7 -7
- data/gemfiles/rails_3.2.gemfile.lock +153 -0
- data/gemfiles/rails_4.2.11.gemfile +16 -0
- data/gemfiles/rails_4.2.11.gemfile.lock +157 -0
- data/gemfiles/rails_5.2.gemfile +16 -0
- data/gemfiles/rails_5.2.gemfile.lock +155 -0
- data/gemfiles/rails_6.0.gemfile +16 -0
- data/gemfiles/rails_6.0.gemfile.lock +155 -0
- data/lib/acts-as-messageable/message.rb +13 -13
- data/lib/acts-as-messageable/model.rb +46 -46
- data/lib/acts-as-messageable/rails4.rb +1 -3
- data/lib/acts-as-messageable/railtie.rb +0 -1
- data/lib/acts-as-messageable/relation.rb +4 -4
- data/lib/acts-as-messageable/scopes.rb +21 -20
- data/lib/generators/acts-as-messageable/migration/migration_generator.rb +12 -4
- data/spec/acts-as-messageable_spec.rb +155 -160
- data/spec/custom-class_spec.rb +19 -20
- data/spec/custom-required_spec.rb +27 -27
- data/spec/group-messages_spec.rb +17 -19
- data/spec/spec_helper.rb +22 -22
- data/spec/support/admin.rb +3 -3
- data/spec/support/send_message.rb +1 -1
- metadata +23 -21
- data/gemfiles/rails_3.0.gemfile +0 -16
- data/gemfiles/rails_3.1.gemfile +0 -16
- data/gemfiles/rails_4.0.gemfile +0 -16
- data/gemfiles/rails_4.1.gemfile +0 -16
- data/gemfiles/rails_4.1_ProtectedAttributes.gemfile +0 -17
data/spec/custom-class_spec.rb
CHANGED
@@ -1,40 +1,39 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
class CustomMessage < ActsAsMessageable::Message
|
4
|
-
def custom_method;end
|
4
|
+
def custom_method; end
|
5
5
|
end
|
6
6
|
|
7
|
-
describe
|
8
|
-
let(:alice) { User.find_by_email(
|
9
|
-
let(:bob) { User.find_by_email(
|
7
|
+
describe 'custom class' do
|
8
|
+
let(:alice) { User.find_by_email('alice@example.com') }
|
9
|
+
let(:bob) { User.find_by_email('bob@example.com') }
|
10
10
|
|
11
11
|
before do
|
12
|
-
User.acts_as_messageable :
|
13
|
-
@message = alice.send_message(bob, :
|
12
|
+
User.acts_as_messageable class_name: 'CustomMessage', table_name: 'custom_messages'
|
13
|
+
@message = alice.send_message(bob, topic: 'Helou bob!', body: "What's up?")
|
14
14
|
end
|
15
15
|
|
16
16
|
after { User.acts_as_messageable }
|
17
17
|
|
18
|
-
it
|
19
|
-
bob.messages.are_from(alice).
|
18
|
+
it 'returns messages from alice with filter' do
|
19
|
+
expect(bob.messages.are_from(alice)).to include(@message)
|
20
20
|
end
|
21
21
|
|
22
|
-
it
|
23
|
-
CustomMessage.are_from(alice).
|
22
|
+
it 'uses new table name' do
|
23
|
+
expect(CustomMessage.are_from(alice)).to include(@message)
|
24
24
|
end
|
25
25
|
|
26
|
-
it
|
27
|
-
@message.class.
|
26
|
+
it 'message should have CustomMessage class' do
|
27
|
+
expect(@message.class).to eq(CustomMessage)
|
28
28
|
end
|
29
29
|
|
30
|
-
it
|
31
|
-
@message.
|
30
|
+
it 'responds to custom_method' do
|
31
|
+
expect(@message).to respond_to(:custom_method)
|
32
32
|
end
|
33
33
|
|
34
|
-
it
|
35
|
-
@reply_message = @message.reply(:
|
36
|
-
@reply_message.root.
|
37
|
-
@reply_message.root.class.
|
34
|
+
it 'return proper class with ancestry methods' do
|
35
|
+
@reply_message = @message.reply(topic: 'Re: Helou bob!', body: 'Fine!')
|
36
|
+
expect(@reply_message.root).to eq(@message)
|
37
|
+
expect(@reply_message.root.class).to eq(CustomMessage)
|
38
38
|
end
|
39
39
|
end
|
40
|
-
|
@@ -1,50 +1,50 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe 'custom require' do
|
4
4
|
before(:each) do
|
5
5
|
# Use clean version of Message class
|
6
|
-
ActsAsMessageable.instance_eval { remove_const
|
7
|
-
load
|
6
|
+
ActsAsMessageable.instance_eval { remove_const 'Message' }
|
7
|
+
load 'acts-as-messageable/message.rb'
|
8
8
|
end
|
9
9
|
|
10
|
-
it
|
11
|
-
User.acts_as_messageable :
|
12
|
-
ActsAsMessageable::Message.required.
|
10
|
+
it 'should work with non-array require' do
|
11
|
+
User.acts_as_messageable required: :body
|
12
|
+
expect(ActsAsMessageable::Message.required).to eq([:body])
|
13
13
|
end
|
14
14
|
|
15
|
-
it
|
16
|
-
User.acts_as_messageable :
|
17
|
-
ActsAsMessageable::Message.required.
|
15
|
+
it 'should work with array require' do
|
16
|
+
User.acts_as_messageable required: %i[body topic]
|
17
|
+
expect(ActsAsMessageable::Message.required).to eq(%i[body topic])
|
18
18
|
end
|
19
19
|
|
20
|
-
context
|
20
|
+
context 'only body' do
|
21
21
|
before(:each) do
|
22
|
-
User.acts_as_messageable :
|
22
|
+
User.acts_as_messageable required: :body
|
23
23
|
end
|
24
24
|
|
25
|
-
it
|
26
|
-
@alice.send_message(@bob,
|
27
|
-
@alice.messages.first.body.
|
28
|
-
@bob.received_messages.first.body.
|
25
|
+
it 'alice should able to send message to bob only with body' do
|
26
|
+
@alice.send_message(@bob, 'Hello bob!')
|
27
|
+
expect(@alice.messages.first.body).to eq('Hello bob!')
|
28
|
+
expect(@bob.received_messages.first.body).to eq('Hello bob!')
|
29
29
|
end
|
30
30
|
|
31
|
-
it
|
32
|
-
@alice.send_message(@bob, :
|
33
|
-
@alice.messages.first.body.
|
31
|
+
it 'alice should able to send message to bob with hash' do
|
32
|
+
@alice.send_message(@bob, body: "Hi Bob! I'm hash master")
|
33
|
+
expect(@alice.messages.first.body).to eq("Hi Bob! I'm hash master")
|
34
34
|
end
|
35
35
|
|
36
|
-
it
|
37
|
-
@alice.send_message(@bob,
|
36
|
+
it 'alice send message to bob with body and bob reply to alice' do
|
37
|
+
@alice.send_message(@bob, 'Hi Bob!')
|
38
38
|
@message_from_alice = @bob.received_messages.first
|
39
|
-
@message_from_alice.body.
|
40
|
-
@bob.reply_to(@message_from_alice,
|
41
|
-
@alice.received_messages.first.body.
|
39
|
+
expect(@message_from_alice.body).to eq('Hi Bob!')
|
40
|
+
@bob.reply_to(@message_from_alice, 'Hi Alice!')
|
41
|
+
expect(@alice.received_messages.first.body).to eq('Hi Alice!')
|
42
42
|
end
|
43
43
|
|
44
|
-
it
|
45
|
-
@message_from_alice = @alice.send_message(@bob,
|
46
|
-
@bob.reply_to(@message_from_alice, :
|
47
|
-
@alice.received_messages.first.body.
|
44
|
+
it 'alice send message to bob and bob reply with hash' do
|
45
|
+
@message_from_alice = @alice.send_message(@bob, 'Hi Bob!')
|
46
|
+
@bob.reply_to(@message_from_alice, body: 'Hi Alice!')
|
47
|
+
expect(@alice.received_messages.first.body).to eq('Hi Alice!')
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
data/spec/group-messages_spec.rb
CHANGED
@@ -1,28 +1,26 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
4
|
-
let(:alice) { User.find_by_email(
|
5
|
-
let(:bob) { User.find_by_email(
|
6
|
-
let(:pat) { User.find_by_email(
|
3
|
+
describe 'group messages' do
|
4
|
+
let(:alice) { User.find_by_email('alice@example.com') }
|
5
|
+
let(:bob) { User.find_by_email('bob@example.com') }
|
6
|
+
let(:pat) { User.find_by_email('pat@example.com') }
|
7
7
|
|
8
8
|
before do
|
9
|
-
User.acts_as_messageable :
|
10
|
-
@message = alice.send_message(bob, :
|
9
|
+
User.acts_as_messageable group_messages: true
|
10
|
+
@message = alice.send_message(bob, topic: 'Helou bob!', body: "What's up?")
|
11
11
|
end
|
12
12
|
|
13
|
-
it
|
14
|
-
@reply_message = pat.reply_to(@message,
|
15
|
-
@sec_reply_message = bob.reply_to(@message,
|
16
|
-
@third_reply_message = alice.reply_to(@reply_message,
|
17
|
-
@message.conversation.
|
13
|
+
it 'joins to conversation' do
|
14
|
+
@reply_message = pat.reply_to(@message, 'Hi there!', 'I would like to join to this conversation!')
|
15
|
+
@sec_reply_message = bob.reply_to(@message, 'Hi!', 'Fine!')
|
16
|
+
@third_reply_message = alice.reply_to(@reply_message, 'hi!', 'no problem')
|
17
|
+
expect(@message.conversation).to include(@sec_reply_message, @third_reply_message, @reply_message, @message)
|
18
18
|
end
|
19
19
|
|
20
|
-
it
|
21
|
-
@reply_message = pat.reply_to(@message,
|
22
|
-
@sec_reply_message = bob.reply_to(@message,
|
23
|
-
@third_reply_message = alice.reply_to(@reply_message,
|
24
|
-
@message.people.
|
20
|
+
it 'alice,bob and pat should be involve into conversation' do
|
21
|
+
@reply_message = pat.reply_to(@message, 'Hi there!', 'I would like to join to this conversation!')
|
22
|
+
@sec_reply_message = bob.reply_to(@message, 'Hi!', 'Fine!')
|
23
|
+
@third_reply_message = alice.reply_to(@reply_message, 'hi!', 'no problem')
|
24
|
+
expect(@message.people).to eq([alice, bob, pat])
|
25
25
|
end
|
26
|
-
|
27
26
|
end
|
28
|
-
|
data/spec/spec_helper.rb
CHANGED
@@ -13,20 +13,20 @@ Bundler.require(:default)
|
|
13
13
|
|
14
14
|
require 'acts-as-messageable'
|
15
15
|
|
16
|
-
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
16
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
17
17
|
|
18
18
|
ActiveRecord::Migration.verbose = false
|
19
19
|
|
20
20
|
RSpec.configure do |config|
|
21
21
|
config.before(:all) do
|
22
|
-
ActiveRecord::Base.establish_connection(:
|
22
|
+
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
|
23
23
|
create_database
|
24
24
|
|
25
|
-
@alice = User.create :
|
26
|
-
@bob = User.create :
|
27
|
-
@pat = User.create :
|
28
|
-
@admin = Admin.create :
|
29
|
-
@men = Men.create :
|
25
|
+
@alice = User.create email: 'alice@example.com'
|
26
|
+
@bob = User.create email: 'bob@example.com'
|
27
|
+
@pat = User.create email: 'pat@example.com'
|
28
|
+
@admin = Admin.create email: 'admin@example.com'
|
29
|
+
@men = Men.create email: 'men@example.com'
|
30
30
|
end
|
31
31
|
|
32
32
|
config.after(:all) do
|
@@ -39,17 +39,17 @@ RSpec.configure do |config|
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def create_database
|
42
|
-
ActiveRecord::Schema.define(:
|
42
|
+
ActiveRecord::Schema.define(version: 1) do
|
43
43
|
create_table :messages do |t|
|
44
44
|
t.string :topic
|
45
45
|
t.text :body
|
46
|
-
t.references :received_messageable, :
|
47
|
-
t.references :sent_messageable, :
|
48
|
-
t.boolean :opened, :
|
49
|
-
t.boolean :recipient_delete, :
|
50
|
-
t.boolean :sender_delete, :
|
51
|
-
t.boolean :recipient_permanent_delete, :
|
52
|
-
t.boolean :sender_permanent_delete, :
|
46
|
+
t.references :received_messageable, polymorphic: true, index: false
|
47
|
+
t.references :sent_messageable, polymorphic: true, index: false
|
48
|
+
t.boolean :opened, default: false
|
49
|
+
t.boolean :recipient_delete, default: false
|
50
|
+
t.boolean :sender_delete, default: false
|
51
|
+
t.boolean :recipient_permanent_delete, default: false
|
52
|
+
t.boolean :sender_permanent_delete, default: false
|
53
53
|
t.string :ancestry
|
54
54
|
t.timestamps
|
55
55
|
end
|
@@ -57,13 +57,13 @@ def create_database
|
|
57
57
|
create_table :custom_messages do |t|
|
58
58
|
t.string :topic
|
59
59
|
t.text :body
|
60
|
-
t.references :received_messageable, :
|
61
|
-
t.references :sent_messageable, :
|
62
|
-
t.boolean :opened, :
|
63
|
-
t.boolean :recipient_delete, :
|
64
|
-
t.boolean :sender_delete, :
|
65
|
-
t.boolean :recipient_permanent_delete, :
|
66
|
-
t.boolean :sender_permanent_delete, :
|
60
|
+
t.references :received_messageable, polymorphic: true, index: false
|
61
|
+
t.references :sent_messageable, polymorphic: true, index: false
|
62
|
+
t.boolean :opened, default: false
|
63
|
+
t.boolean :recipient_delete, default: false
|
64
|
+
t.boolean :sender_delete, default: false
|
65
|
+
t.boolean :recipient_permanent_delete, default: false
|
66
|
+
t.boolean :sender_permanent_delete, default: false
|
67
67
|
t.string :ancestry
|
68
68
|
t.timestamps
|
69
69
|
end
|
data/spec/support/admin.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
class Admin < ActiveRecord::Base
|
2
|
-
acts_as_messageable
|
3
|
-
end
|
1
|
+
class Admin < ActiveRecord::Base
|
2
|
+
acts_as_messageable
|
3
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts-as-messageable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Nielacny
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-06-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -67,35 +67,35 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 3.0.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: appraisal
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: coveralls
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: '0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - "
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
96
|
+
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
98
|
+
name: jeweler
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - ">="
|
@@ -109,7 +109,7 @@ dependencies:
|
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
112
|
+
name: rspec
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - ">="
|
@@ -123,7 +123,7 @@ dependencies:
|
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
|
-
name:
|
126
|
+
name: sqlite3
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
129
|
- - ">="
|
@@ -154,12 +154,14 @@ files:
|
|
154
154
|
- Rakefile
|
155
155
|
- VERSION
|
156
156
|
- acts-as-messageable.gemspec
|
157
|
-
- gemfiles/rails_3.0.gemfile
|
158
|
-
- gemfiles/rails_3.1.gemfile
|
159
157
|
- gemfiles/rails_3.2.gemfile
|
160
|
-
- gemfiles/
|
161
|
-
- gemfiles/rails_4.
|
162
|
-
- gemfiles/rails_4.
|
158
|
+
- gemfiles/rails_3.2.gemfile.lock
|
159
|
+
- gemfiles/rails_4.2.11.gemfile
|
160
|
+
- gemfiles/rails_4.2.11.gemfile.lock
|
161
|
+
- gemfiles/rails_5.2.gemfile
|
162
|
+
- gemfiles/rails_5.2.gemfile.lock
|
163
|
+
- gemfiles/rails_6.0.gemfile
|
164
|
+
- gemfiles/rails_6.0.gemfile.lock
|
163
165
|
- lib/acts-as-messageable.rb
|
164
166
|
- lib/acts-as-messageable/message.rb
|
165
167
|
- lib/acts-as-messageable/model.rb
|
@@ -198,7 +200,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
198
200
|
version: '0'
|
199
201
|
requirements: []
|
200
202
|
rubyforge_project:
|
201
|
-
rubygems_version: 2.
|
203
|
+
rubygems_version: 2.7.6
|
202
204
|
signing_key:
|
203
205
|
specification_version: 4
|
204
206
|
summary: Make user messageable!;-)
|
data/gemfiles/rails_3.0.gemfile
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
# This file was generated by Appraisal
|
2
|
-
|
3
|
-
source "http://rubygems.org"
|
4
|
-
|
5
|
-
gem "activerecord", "~> 3.0.0"
|
6
|
-
gem "activesupport", "~> 3.0.0"
|
7
|
-
gem "ancestry", ">= 1.3.0"
|
8
|
-
gem "railties", "~> 3.0.0"
|
9
|
-
|
10
|
-
group :development do
|
11
|
-
gem "rspec", "~> 2.0"
|
12
|
-
gem "jeweler", "~> 1.8.0"
|
13
|
-
gem "sqlite3"
|
14
|
-
gem "coveralls", :require => false
|
15
|
-
gem "appraisal"
|
16
|
-
end
|
data/gemfiles/rails_3.1.gemfile
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
# This file was generated by Appraisal
|
2
|
-
|
3
|
-
source "http://rubygems.org"
|
4
|
-
|
5
|
-
gem "activerecord", "~> 3.1.0"
|
6
|
-
gem "activesupport", "~> 3.1.0"
|
7
|
-
gem "ancestry", ">= 1.3.0"
|
8
|
-
gem "railties", "~> 3.1.0"
|
9
|
-
|
10
|
-
group :development do
|
11
|
-
gem "rspec", "~> 2.0"
|
12
|
-
gem "jeweler", "~> 1.8.0"
|
13
|
-
gem "sqlite3"
|
14
|
-
gem "coveralls", :require => false
|
15
|
-
gem "appraisal"
|
16
|
-
end
|
data/gemfiles/rails_4.0.gemfile
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
# This file was generated by Appraisal
|
2
|
-
|
3
|
-
source "http://rubygems.org"
|
4
|
-
|
5
|
-
gem "activerecord", "~> 4.0.0"
|
6
|
-
gem "activesupport", "~> 4.0.0"
|
7
|
-
gem "ancestry", ">= 1.3.0"
|
8
|
-
gem "railties", "~> 4.0.0"
|
9
|
-
|
10
|
-
group :development do
|
11
|
-
gem "rspec", "~> 2.0"
|
12
|
-
gem "jeweler", "~> 1.8.0"
|
13
|
-
gem "sqlite3"
|
14
|
-
gem "coveralls", :require => false
|
15
|
-
gem "appraisal"
|
16
|
-
end
|
data/gemfiles/rails_4.1.gemfile
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
# This file was generated by Appraisal
|
2
|
-
|
3
|
-
source "http://rubygems.org"
|
4
|
-
|
5
|
-
gem "activerecord", "~> 4.1.0"
|
6
|
-
gem "activesupport", "~> 4.1.0"
|
7
|
-
gem "ancestry", ">= 1.3.0"
|
8
|
-
gem "railties", "~> 4.1.0"
|
9
|
-
|
10
|
-
group :development do
|
11
|
-
gem "rspec", "~> 2.0"
|
12
|
-
gem "jeweler", "~> 1.8.0"
|
13
|
-
gem "sqlite3"
|
14
|
-
gem "coveralls", :require => false
|
15
|
-
gem "appraisal"
|
16
|
-
end
|