facteur 0.2.2 → 0.3.0

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.
data/README.markdown CHANGED
@@ -69,6 +69,7 @@ It is also possible to create a mailbox dynamically. This mailbox will not be av
69
69
 
70
70
  @john.create_mailbox(:new_mailbox) #=> true
71
71
  User.mailboxes #=> [{:name=>:private_mailbox, :default=>true}, {:name=>:public_mailbox}]
72
+ @john.mailboxes #=> [{:name=>:private_mailbox, :default=>true}, {:name=>:public_mailbox}, {:name=>:new_mailbox}]
72
73
 
73
74
  After the previous example, the "news\_mailbox" is only avalaible to John. The names of the mailboxes must be unique. if you try to create a mailbox which already exists, the create_mailbox() method will return false.
74
75
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.2
1
+ 0.3.0
@@ -22,6 +22,9 @@ module Facteur
22
22
  mailbox = {:name => name}
23
23
  mailbox.merge! options
24
24
  mailboxes << mailbox
25
+ all.each do |addressee|
26
+ addressee.create_mailbox!(name, options)
27
+ end
25
28
  end
26
29
 
27
30
  # Returns the mailboxes defined for the class
data/spec/facteur_spec.rb CHANGED
@@ -86,4 +86,43 @@ describe Facteur::AddresseeModel do
86
86
  end
87
87
  end
88
88
 
89
+ context "When adding a new mailbox" do
90
+ before(:all) do
91
+ create_users
92
+ class User < ActiveRecord::Base
93
+ mailbox :added_mailbox
94
+ end
95
+ end
96
+
97
+ it "should add the new mailbox to the class mailboxes" do
98
+ User.mailboxes.should include({:name=>:added_mailbox})
99
+ end
100
+
101
+ it "should add the new mailbox to all the existing users" do
102
+ @john.mailboxes.where(:name => 'private_mailbox').first.should_not be_nil
103
+ @john.mailboxes.where(:name => 'public_mailbox').first.should_not be_nil
104
+ @john.mailboxes.where(:name => 'added_mailbox').first.should_not be_nil
105
+
106
+ @peter.mailboxes.where(:name => 'private_mailbox').first.should_not be_nil
107
+ @peter.mailboxes.where(:name => 'public_mailbox').first.should_not be_nil
108
+ @peter.mailboxes.where(:name => 'added_mailbox').first.should_not be_nil
109
+
110
+ @james.mailboxes.where(:name => 'private_mailbox').first.should_not be_nil
111
+ @james.mailboxes.where(:name => 'public_mailbox').first.should_not be_nil
112
+ @james.mailboxes.where(:name => 'added_mailbox').first.should_not be_nil
113
+
114
+ @mary.mailboxes.where(:name => 'private_mailbox').first.should_not be_nil
115
+ @mary.mailboxes.where(:name => 'public_mailbox').first.should_not be_nil
116
+ @mary.mailboxes.where(:name => 'added_mailbox').first.should_not be_nil
117
+
118
+ @jane.mailboxes.where(:name => 'private_mailbox').first.should_not be_nil
119
+ @jane.mailboxes.where(:name => 'public_mailbox').first.should_not be_nil
120
+ @jane.mailboxes.where(:name => 'added_mailbox').first.should_not be_nil
121
+
122
+ @victoria.mailboxes.where(:name => 'private_mailbox').first.should_not be_nil
123
+ @victoria.mailboxes.where(:name => 'public_mailbox').first.should_not be_nil
124
+ @victoria.mailboxes.where(:name => 'added_mailbox').first.should_not be_nil
125
+ end
126
+ end
127
+
89
128
  end
data/spec/spec_helper.rb CHANGED
@@ -59,6 +59,7 @@ class Message < ActiveRecord::Base
59
59
  end
60
60
 
61
61
  def create_users
62
+ User.delete_all
62
63
  %w(John Peter James Mary Jane Victoria).each do |name|
63
64
  eval "@#{name.downcase} = User.create(:name => '#{name}')"
64
65
  end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 2
8
- - 2
9
- version: 0.2.2
7
+ - 3
8
+ - 0
9
+ version: 0.3.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Rawane ZOSSOU