acts-as-messageable 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/acts-as-messageable.gemspec +3 -2
- data/lib/acts-as-messageable/message.rb +2 -2
- data/spec/acts-as-messageable_spec.rb +20 -0
- data/spec/spec_helper.rb +7 -2
- data/spec/support/admin.rb +3 -0
- metadata +18 -17
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.3
|
data/acts-as-messageable.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "acts-as-messageable"
|
8
|
-
s.version = "0.4.
|
8
|
+
s.version = "0.4.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Piotr Nielacny"]
|
12
|
-
s.date = "2011-
|
12
|
+
s.date = "2011-12-04"
|
13
13
|
s.email = "piotr.nielacny@gmail.com"
|
14
14
|
s.extra_rdoc_files = [
|
15
15
|
"README.md"
|
@@ -36,6 +36,7 @@ Gem::Specification.new do |s|
|
|
36
36
|
"spec/custom-class_spec.rb",
|
37
37
|
"spec/custom-required_spec.rb",
|
38
38
|
"spec/spec_helper.rb",
|
39
|
+
"spec/support/admin.rb",
|
39
40
|
"spec/support/user.rb"
|
40
41
|
]
|
41
42
|
s.homepage = "http://github.com/LTe/acts-as-messageable"
|
@@ -27,8 +27,8 @@ module ActsAsMessageable
|
|
27
27
|
|
28
28
|
# Sample documentation for scope
|
29
29
|
default_scope order(:created_at)
|
30
|
-
scope :are_from, lambda { |*args| where("sent_messageable_id = :sender", :sender => args.first) }
|
31
|
-
scope :are_to, lambda { |*args| where("received_messageable_id = :receiver", :receiver => args.first) }
|
30
|
+
scope :are_from, lambda { |*args| where("sent_messageable_id = :sender AND sent_messageable_type = :sender_type", :sender => args.first, :sender_type => args.first.class.to_s) }
|
31
|
+
scope :are_to, lambda { |*args| where("received_messageable_id = :receiver AND received_messageable_type = :receiver_type", :receiver => args.first, :receiver_type => args.first.class.to_s) }
|
32
32
|
scope :with_id, lambda { |*args| where("id = :id", :id => args.first) }
|
33
33
|
|
34
34
|
scope :connected_with, lambda { |*args| where("(sent_messageable_type = :sent_type and
|
@@ -160,4 +160,24 @@ describe "ActsAsMessageable" do
|
|
160
160
|
send_message
|
161
161
|
@bob.sent_messages.class.should == ActiveRecord::Relation
|
162
162
|
end
|
163
|
+
|
164
|
+
describe "send messages between two different models (the same id)" do
|
165
|
+
it "should have the same id" do
|
166
|
+
@alice.id.should be_equal(@admin.id)
|
167
|
+
end
|
168
|
+
|
169
|
+
it "bob send message to admin (different model) with the same id" do
|
170
|
+
@bob.send_message(@alice, "hello", "alice")
|
171
|
+
@alice.messages.are_to(@alice).size.should be_equal(1)
|
172
|
+
@alice.messages.are_to(@admin).size.should be_equal(0)
|
173
|
+
end
|
174
|
+
|
175
|
+
it "admin send message to bob" do
|
176
|
+
@admin.send_message(@bob, "hello", "bob")
|
177
|
+
@bob.messages.are_from(@admin).size.should be_equal(1)
|
178
|
+
@bob.messages.are_from(@alice).size.should be_equal(0)
|
179
|
+
end
|
180
|
+
|
181
|
+
end
|
182
|
+
|
163
183
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -12,8 +12,9 @@ RSpec.configure do |config|
|
|
12
12
|
ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:")
|
13
13
|
create_database
|
14
14
|
|
15
|
-
@alice = User.create :email
|
16
|
-
@bob = User.create :email
|
15
|
+
@alice = User.create :email => "alice@example.com"
|
16
|
+
@bob = User.create :email => "bob@example.com"
|
17
|
+
@admin = Admin.create :email => "admin@example.com"
|
17
18
|
end
|
18
19
|
|
19
20
|
config.after(:all) do
|
@@ -44,6 +45,10 @@ def create_database
|
|
44
45
|
create_table :users do |t|
|
45
46
|
t.string :email
|
46
47
|
end
|
48
|
+
|
49
|
+
create_table :admins do |t|
|
50
|
+
t.string :email
|
51
|
+
end
|
47
52
|
end
|
48
53
|
end
|
49
54
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
12
|
+
date: 2011-12-04 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
16
|
-
requirement: &
|
16
|
+
requirement: &70249729576820 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 3.0.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70249729576820
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: activesupport
|
27
|
-
requirement: &
|
27
|
+
requirement: &70249729576140 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 3.0.0
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70249729576140
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: ancestry
|
38
|
-
requirement: &
|
38
|
+
requirement: &70249729575440 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 1.2.4
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70249729575440
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: railties
|
49
|
-
requirement: &
|
49
|
+
requirement: &70249729574540 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 3.0.0
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70249729574540
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rspec
|
60
|
-
requirement: &
|
60
|
+
requirement: &70249729573820 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: 2.6.0
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70249729573820
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: jeweler
|
71
|
-
requirement: &
|
71
|
+
requirement: &70249729572960 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: 1.6.0
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70249729572960
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: sqlite3-ruby
|
82
|
-
requirement: &
|
82
|
+
requirement: &70249729572120 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,7 +87,7 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70249729572120
|
91
91
|
description:
|
92
92
|
email: piotr.nielacny@gmail.com
|
93
93
|
executables: []
|
@@ -116,6 +116,7 @@ files:
|
|
116
116
|
- spec/custom-class_spec.rb
|
117
117
|
- spec/custom-required_spec.rb
|
118
118
|
- spec/spec_helper.rb
|
119
|
+
- spec/support/admin.rb
|
119
120
|
- spec/support/user.rb
|
120
121
|
homepage: http://github.com/LTe/acts-as-messageable
|
121
122
|
licenses: []
|
@@ -131,7 +132,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
131
132
|
version: '0'
|
132
133
|
segments:
|
133
134
|
- 0
|
134
|
-
hash: -
|
135
|
+
hash: -4338229032027904725
|
135
136
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
136
137
|
none: false
|
137
138
|
requirements:
|