acts-as-messageable 0.4.7 → 0.4.8
Sign up to get free protection for your applications and to get access to all the features.
- data/.rspec +1 -1
- data/Gemfile +12 -12
- data/README.md +278 -265
- data/VERSION +1 -1
- data/acts-as-messageable.gemspec +2 -2
- data/lib/acts-as-messageable.rb +7 -7
- data/lib/acts-as-messageable/message.rb +97 -95
- data/lib/acts-as-messageable/model.rb +165 -157
- data/lib/acts-as-messageable/relation.rb +4 -0
- data/spec/acts-as-messageable_spec.rb +266 -234
- data/spec/custom-class_spec.rb +19 -4
- data/spec/spec_helper.rb +65 -61
- data/spec/support/admin.rb +3 -3
- data/spec/support/user.rb +7 -7
- metadata +3 -3
data/spec/custom-class_spec.rb
CHANGED
@@ -1,15 +1,30 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
class CustomMessage < ActsAsMessageable::Message
|
3
|
+
class CustomMessage < ActsAsMessageable::Message
|
4
|
+
def custom_method;end
|
5
|
+
end
|
4
6
|
|
5
7
|
describe "custom class" do
|
6
|
-
|
8
|
+
let(:alice) { User.find_by_email("alice@example.com") }
|
9
|
+
let(:bob) { User.find_by_email("bob@example.com") }
|
10
|
+
|
11
|
+
before do
|
7
12
|
User.acts_as_messageable :class_name => "CustomMessage"
|
13
|
+
@message = alice.send_message(bob, :topic => "Helou bob!", :body => "What's up?")
|
8
14
|
end
|
9
15
|
|
10
16
|
it "message should have CustomMessage class" do
|
11
|
-
message
|
12
|
-
|
17
|
+
@message.class.should == CustomMessage
|
18
|
+
end
|
19
|
+
|
20
|
+
it "responds to custom_method" do
|
21
|
+
@message.should respond_to(:custom_method)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "return proper class with ancestry methods" do
|
25
|
+
@reply_message = @message.reply(:topic => "Re: Helou bob!", :body => "Fine!")
|
26
|
+
@reply_message.root.should == @message
|
27
|
+
@reply_message.root.class.should == CustomMessage
|
13
28
|
end
|
14
29
|
end
|
15
30
|
|
data/spec/spec_helper.rb
CHANGED
@@ -1,61 +1,65 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
-
require 'rspec'
|
4
|
-
require '
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
@
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
end
|
25
|
-
|
26
|
-
config.after(:
|
27
|
-
|
28
|
-
end
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
t.
|
39
|
-
t.
|
40
|
-
t.
|
41
|
-
t.
|
42
|
-
t.boolean :
|
43
|
-
t.
|
44
|
-
t.
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
t.
|
49
|
-
end
|
50
|
-
|
51
|
-
create_table :
|
52
|
-
t.string :email
|
53
|
-
end
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
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
|
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
|
data/spec/support/user.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
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
|
7
|
+
|
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.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-02-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -170,7 +170,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
170
170
|
version: '0'
|
171
171
|
segments:
|
172
172
|
- 0
|
173
|
-
hash:
|
173
|
+
hash: 3130175712303537553
|
174
174
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
175
175
|
none: false
|
176
176
|
requirements:
|