acts-as-messageable 0.4.8 → 0.4.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,10 +9,20 @@ describe "custom class" do
9
9
  let(:bob) { User.find_by_email("bob@example.com") }
10
10
 
11
11
  before do
12
- User.acts_as_messageable :class_name => "CustomMessage"
12
+ User.acts_as_messageable :class_name => "CustomMessage", :table_name => "custom_messages"
13
13
  @message = alice.send_message(bob, :topic => "Helou bob!", :body => "What's up?")
14
14
  end
15
15
 
16
+ after { User.acts_as_messageable }
17
+
18
+ it "returns messages from alice with filter" do
19
+ bob.messages.are_from(alice).should include(@message)
20
+ end
21
+
22
+ it "uses new table name" do
23
+ CustomMessage.are_from(alice).should include(@message)
24
+ end
25
+
16
26
  it "message should have CustomMessage class" do
17
27
  @message.class.should == CustomMessage
18
28
  end
@@ -0,0 +1,28 @@
1
+ require "spec_helper"
2
+
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
+
8
+ before do
9
+ User.acts_as_messageable :group_messages => true
10
+ @message = alice.send_message(bob, :topic => "Helou bob!", :body => "What's up?")
11
+ end
12
+
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
+ @message.conversation.should include(@sec_reply_message, @third_reply_message, @reply_message, @message)
18
+ end
19
+
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
+ @message.people.should == [alice, bob, pat]
25
+ end
26
+
27
+ end
28
+
data/spec/spec_helper.rb CHANGED
@@ -1,65 +1,81 @@
1
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
- $LOAD_PATH.unshift(File.dirname(__FILE__))
3
- require 'rspec'
4
- require 'active_record/railtie'
5
- ActiveRecord::Base.logger = Logger.new(STDERR)
6
- ActiveRecord::Base.logger.level = 3
7
-
8
- require 'acts-as-messageable'
9
-
10
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
11
-
12
- ActiveRecord::Migration.verbose = false
13
-
14
- RSpec.configure do |config|
15
- config.before(:all) do
16
- ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:")
17
- create_database
18
-
19
- @alice = User.create :email => "alice@example.com"
20
- @bob = User.create :email => "bob@example.com"
21
- @pat = User.create :email => "pat@example.com"
22
- @admin = Admin.create :email => "admin@example.com"
23
- @men = Men.create :email => "men@example.com"
24
- end
25
-
26
- config.after(:all) do
27
- drop_database
28
- end
29
-
30
- config.after(:each) do
31
- User.messages_class_name.destroy_all
32
- end
33
- end
34
-
35
- def create_database
36
- ActiveRecord::Schema.define(:version => 1) do
37
- create_table :messages do |t|
38
- t.string :topic
39
- t.text :body
40
- t.references :received_messageable, :polymorphic => true
41
- t.references :sent_messageable, :polymorphic => true
42
- t.boolean :opened, :default => false
43
- t.boolean :recipient_delete, :default => false
44
- t.boolean :sender_delete, :default => false
45
- t.boolean :recipient_permanent_delete, :default => false
46
- t.boolean :sender_permanent_delete, :default => false
47
- t.string :ancestry
48
- t.timestamps
49
- end
50
-
51
- create_table :users do |t|
52
- t.string :email
53
- end
54
-
55
- create_table :admins do |t|
56
- t.string :email
57
- end
58
- end
59
- end
60
-
61
- def drop_database
62
- ActiveRecord::Base.connection.tables.each do |table|
63
- ActiveRecord::Base.connection.drop_table(table)
64
- end
65
- end
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+ require 'active_record/railtie'
5
+ ActiveRecord::Base.logger = Logger.new(STDERR)
6
+ ActiveRecord::Base.logger.level = 3
7
+
8
+ require 'coveralls'
9
+ Coveralls.wear!
10
+
11
+ require 'acts-as-messageable'
12
+
13
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
14
+
15
+ ActiveRecord::Migration.verbose = false
16
+
17
+ RSpec.configure do |config|
18
+ config.before(:all) do
19
+ ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:")
20
+ create_database
21
+
22
+ @alice = User.create :email => "alice@example.com"
23
+ @bob = User.create :email => "bob@example.com"
24
+ @pat = User.create :email => "pat@example.com"
25
+ @admin = Admin.create :email => "admin@example.com"
26
+ @men = Men.create :email => "men@example.com"
27
+ end
28
+
29
+ config.after(:all) do
30
+ drop_database
31
+ end
32
+
33
+ config.after(:each) do
34
+ User.messages_class_name.destroy_all
35
+ end
36
+ end
37
+
38
+ def create_database
39
+ ActiveRecord::Schema.define(:version => 1) do
40
+ create_table :messages do |t|
41
+ t.string :topic
42
+ t.text :body
43
+ t.references :received_messageable, :polymorphic => true
44
+ t.references :sent_messageable, :polymorphic => true
45
+ t.boolean :opened, :default => false
46
+ t.boolean :recipient_delete, :default => false
47
+ t.boolean :sender_delete, :default => false
48
+ t.boolean :recipient_permanent_delete, :default => false
49
+ t.boolean :sender_permanent_delete, :default => false
50
+ t.string :ancestry
51
+ t.timestamps
52
+ end
53
+
54
+ create_table :custom_messages do |t|
55
+ t.string :topic
56
+ t.text :body
57
+ t.references :received_messageable, :polymorphic => true
58
+ t.references :sent_messageable, :polymorphic => true
59
+ t.boolean :opened, :default => false
60
+ t.boolean :recipient_delete, :default => false
61
+ t.boolean :sender_delete, :default => false
62
+ t.boolean :recipient_permanent_delete, :default => false
63
+ t.boolean :sender_permanent_delete, :default => false
64
+ t.string :ancestry
65
+ t.timestamps
66
+ end
67
+ create_table :users do |t|
68
+ t.string :email
69
+ end
70
+
71
+ create_table :admins do |t|
72
+ t.string :email
73
+ end
74
+ end
75
+ end
76
+
77
+ def drop_database
78
+ ActiveRecord::Base.connection.tables.each do |table|
79
+ ActiveRecord::Base.connection.drop_table(table)
80
+ end
81
+ end
@@ -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
@@ -1,3 +1,3 @@
1
1
  def send_message(from=@bob, to=@alice, topic="Topic", body="Body")
2
2
  from.send_message(to, topic, body)
3
- end
3
+ end
data/spec/support/user.rb CHANGED
@@ -1,7 +1,6 @@
1
- class User < ActiveRecord::Base
2
- acts_as_messageable
3
- end
4
-
5
- class Men < User
6
- end
7
-
1
+ class User < ActiveRecord::Base
2
+ acts_as_messageable
3
+ end
4
+
5
+ class Men < User
6
+ end
metadata CHANGED
@@ -1,100 +1,88 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts-as-messageable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.8
5
- prerelease:
4
+ version: 0.4.9
6
5
  platform: ruby
7
6
  authors:
8
7
  - Piotr Nielacny
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-02-05 00:00:00.000000000 Z
11
+ date: 2013-11-25 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: activerecord
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: 3.0.0
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: 3.0.0
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: activesupport
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: 3.0.0
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: 3.0.0
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: ancestry
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ~>
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: 1.3.0
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ~>
52
+ - - '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: 1.3.0
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: railties
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - '>='
68
60
  - !ruby/object:Gem::Version
69
61
  version: 3.0.0
70
62
  type: :runtime
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - '>='
76
67
  - !ruby/object:Gem::Version
77
68
  version: 3.0.0
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: rspec
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
73
  - - ~>
84
74
  - !ruby/object:Gem::Version
85
- version: 2.11.0
75
+ version: '2.0'
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
80
  - - ~>
92
81
  - !ruby/object:Gem::Version
93
- version: 2.11.0
82
+ version: '2.0'
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: jeweler
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
87
  - - ~>
100
88
  - !ruby/object:Gem::Version
@@ -102,7 +90,6 @@ dependencies:
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
94
  - - ~>
108
95
  - !ruby/object:Gem::Version
@@ -110,17 +97,29 @@ dependencies:
110
97
  - !ruby/object:Gem::Dependency
111
98
  name: sqlite3
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
- - - ! '>='
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: coveralls
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '>='
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
121
  requirements:
123
- - - ! '>='
122
+ - - '>='
124
123
  - !ruby/object:Gem::Version
125
124
  version: '0'
126
125
  description:
@@ -130,9 +129,11 @@ extensions: []
130
129
  extra_rdoc_files:
131
130
  - README.md
132
131
  files:
132
+ - .coveralls.yml
133
133
  - .rspec
134
134
  - .travis.yml
135
135
  - Gemfile
136
+ - Gemfile.lock
136
137
  - MIT-LICENSE
137
138
  - README.md
138
139
  - Rakefile
@@ -141,46 +142,47 @@ files:
141
142
  - gemfiles/Gemfile-3.0
142
143
  - gemfiles/Gemfile-3.1
143
144
  - gemfiles/Gemfile-3.2
145
+ - gemfiles/Gemfile-4.0
144
146
  - lib/acts-as-messageable.rb
145
147
  - lib/acts-as-messageable/message.rb
146
148
  - lib/acts-as-messageable/model.rb
149
+ - lib/acts-as-messageable/rails3.rb
150
+ - lib/acts-as-messageable/rails4.rb
147
151
  - lib/acts-as-messageable/railtie.rb
148
152
  - lib/acts-as-messageable/relation.rb
153
+ - lib/acts-as-messageable/scopes.rb
149
154
  - lib/generators/acts-as-messageable/migration/migration_generator.rb
150
155
  - lib/generators/acts-as-messageable/migration/templates/migration.rb
151
156
  - lib/generators/acts-as-messageable/migration/templates/migration_permanent.rb
152
157
  - spec/acts-as-messageable_spec.rb
153
158
  - spec/custom-class_spec.rb
154
159
  - spec/custom-required_spec.rb
160
+ - spec/group-messages_spec.rb
155
161
  - spec/spec_helper.rb
156
162
  - spec/support/admin.rb
157
163
  - spec/support/send_message.rb
158
164
  - spec/support/user.rb
159
165
  homepage: http://github.com/LTe/acts-as-messageable
160
166
  licenses: []
167
+ metadata: {}
161
168
  post_install_message:
162
169
  rdoc_options: []
163
170
  require_paths:
164
171
  - lib
165
172
  required_ruby_version: !ruby/object:Gem::Requirement
166
- none: false
167
173
  requirements:
168
- - - ! '>='
174
+ - - '>='
169
175
  - !ruby/object:Gem::Version
170
176
  version: '0'
171
- segments:
172
- - 0
173
- hash: 3130175712303537553
174
177
  required_rubygems_version: !ruby/object:Gem::Requirement
175
- none: false
176
178
  requirements:
177
- - - ! '>='
179
+ - - '>='
178
180
  - !ruby/object:Gem::Version
179
181
  version: '0'
180
182
  requirements: []
181
183
  rubyforge_project:
182
- rubygems_version: 1.8.24
184
+ rubygems_version: 2.1.11
183
185
  signing_key:
184
- specification_version: 3
186
+ specification_version: 4
185
187
  summary: Make user messageable!;-)
186
188
  test_files: []