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.
@@ -1,15 +1,30 @@
1
1
  require "spec_helper"
2
2
 
3
- class CustomMessage < ActsAsMessageable::Message; end
3
+ class CustomMessage < ActsAsMessageable::Message
4
+ def custom_method;end
5
+ end
4
6
 
5
7
  describe "custom class" do
6
- before(:all) do
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 = @alice.send_message(@bob, :topic => "Helou bob!", :body => "What's up?")
12
- message.class.should == CustomMessage
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
 
@@ -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 'acts-as-messageable'
5
-
6
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
7
-
8
- ActiveRecord::Migration.verbose = false
9
-
10
- RSpec.configure do |config|
11
- config.before(:all) do
12
- ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:")
13
- create_database
14
-
15
- @alice = User.create :email => "alice@example.com"
16
- @bob = User.create :email => "bob@example.com"
17
- @pat = User.create :email => "pat@example.com"
18
- @admin = Admin.create :email => "admin@example.com"
19
- @men = Men.create :email => "men@example.com"
20
- end
21
-
22
- config.after(:all) do
23
- drop_database
24
- end
25
-
26
- config.after(:each) do
27
- User.messages_class_name.destroy_all
28
- end
29
- end
30
-
31
- def create_database
32
- ActiveRecord::Schema.define(:version => 1) do
33
- create_table :messages do |t|
34
- t.string :topic
35
- t.text :body
36
- t.references :received_messageable, :polymorphic => true
37
- t.references :sent_messageable, :polymorphic => true
38
- t.boolean :opened, :default => false
39
- t.boolean :recipient_delete, :default => false
40
- t.boolean :sender_delete, :default => false
41
- t.boolean :recipient_permanent_delete, :default => false
42
- t.boolean :sender_permanent_delete, :default => false
43
- t.string :ancestry
44
- t.timestamps
45
- end
46
-
47
- create_table :users do |t|
48
- t.string :email
49
- end
50
-
51
- create_table :admins do |t|
52
- t.string :email
53
- end
54
- end
55
- end
56
-
57
- def drop_database
58
- ActiveRecord::Base.connection.tables.each do |table|
59
- ActiveRecord::Base.connection.drop_table(table)
60
- end
61
- 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 '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,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,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.7
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: 2012-10-02 00:00:00.000000000 Z
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: -1531878341155458477
173
+ hash: 3130175712303537553
174
174
  required_rubygems_version: !ruby/object:Gem::Requirement
175
175
  none: false
176
176
  requirements: