facteur 0.3.1 → 0.3.2

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.1
1
+ 0.3.2
@@ -22,15 +22,22 @@ 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
28
25
  end
29
26
 
30
27
  # Returns the mailboxes defined for the class
31
28
  def mailboxes
32
29
  @mailboxes ||= []
33
30
  end
31
+
32
+ def update_addressees_mailboxes
33
+ all.each do |addressee|
34
+ @mailboxes.each do |mailbox|
35
+ options = {}.merge(mailbox)
36
+ name = options.delete(:name)
37
+ addressee.create_mailbox(name, options)
38
+ end
39
+ end
40
+ end
34
41
  end
35
42
 
36
43
  module InstanceMethods
data/spec/facteur_spec.rb CHANGED
@@ -31,6 +31,21 @@ describe Facteur::AddresseeModel do
31
31
  it "creates the addressee's mailboxes" do
32
32
  @john.mailboxes.where(:name => 'private_mailbox').first.should_not be_nil
33
33
  @john.mailboxes.where(:name => 'public_mailbox').first.should_not be_nil
34
+
35
+ @peter.mailboxes.where(:name => 'private_mailbox').first.should_not be_nil
36
+ @peter.mailboxes.where(:name => 'public_mailbox').first.should_not be_nil
37
+
38
+ @james.mailboxes.where(:name => 'private_mailbox').first.should_not be_nil
39
+ @james.mailboxes.where(:name => 'public_mailbox').first.should_not be_nil
40
+
41
+ @mary.mailboxes.where(:name => 'private_mailbox').first.should_not be_nil
42
+ @mary.mailboxes.where(:name => 'public_mailbox').first.should_not be_nil
43
+
44
+ @jane.mailboxes.where(:name => 'private_mailbox').first.should_not be_nil
45
+ @jane.mailboxes.where(:name => 'public_mailbox').first.should_not be_nil
46
+
47
+ @victoria.mailboxes.where(:name => 'private_mailbox').first.should_not be_nil
48
+ @victoria.mailboxes.where(:name => 'public_mailbox').first.should_not be_nil
34
49
  end
35
50
 
36
51
  it "defines the mailboxes accessors" do
@@ -38,6 +53,71 @@ describe Facteur::AddresseeModel do
38
53
  @john.should respond_to :public_mailbox
39
54
  @john.private_mailbox.should_not be_nil
40
55
  @john.public_mailbox.should_not be_nil
56
+
57
+ @peter.should respond_to :private_mailbox
58
+ @peter.should respond_to :public_mailbox
59
+ @peter.private_mailbox.should_not be_nil
60
+ @peter.public_mailbox.should_not be_nil
61
+
62
+ @james.should respond_to :private_mailbox
63
+ @james.should respond_to :public_mailbox
64
+ @james.private_mailbox.should_not be_nil
65
+ @james.public_mailbox.should_not be_nil
66
+
67
+ @mary.should respond_to :private_mailbox
68
+ @mary.should respond_to :public_mailbox
69
+ @mary.private_mailbox.should_not be_nil
70
+ @mary.public_mailbox.should_not be_nil
71
+
72
+ @jane.should respond_to :private_mailbox
73
+ @jane.should respond_to :public_mailbox
74
+ @jane.private_mailbox.should_not be_nil
75
+ @jane.public_mailbox.should_not be_nil
76
+
77
+ @victoria.should respond_to :private_mailbox
78
+ @victoria.should respond_to :public_mailbox
79
+ @victoria.private_mailbox.should_not be_nil
80
+ @victoria.public_mailbox.should_not be_nil
81
+ end
82
+ end
83
+
84
+ context "When adding a new mailbox" do
85
+ before(:all) do
86
+ create_users
87
+ class User < ActiveRecord::Base
88
+ mailbox :added_mailbox
89
+ end
90
+ User.update_addressees_mailboxes
91
+ end
92
+
93
+ it "should add the new mailbox to the class mailboxes" do
94
+ User.mailboxes.should include({:name=>:added_mailbox})
95
+ end
96
+
97
+ it "should add the new mailbox to all the existing users" do
98
+ @john.mailboxes.where(:name => 'private_mailbox').first.should_not be_nil
99
+ @john.mailboxes.where(:name => 'public_mailbox').first.should_not be_nil
100
+ @john.mailboxes.where(:name => 'added_mailbox').first.should_not be_nil
101
+
102
+ @peter.mailboxes.where(:name => 'private_mailbox').first.should_not be_nil
103
+ @peter.mailboxes.where(:name => 'public_mailbox').first.should_not be_nil
104
+ @peter.mailboxes.where(:name => 'added_mailbox').first.should_not be_nil
105
+
106
+ @james.mailboxes.where(:name => 'private_mailbox').first.should_not be_nil
107
+ @james.mailboxes.where(:name => 'public_mailbox').first.should_not be_nil
108
+ @james.mailboxes.where(:name => 'added_mailbox').first.should_not be_nil
109
+
110
+ @mary.mailboxes.where(:name => 'private_mailbox').first.should_not be_nil
111
+ @mary.mailboxes.where(:name => 'public_mailbox').first.should_not be_nil
112
+ @mary.mailboxes.where(:name => 'added_mailbox').first.should_not be_nil
113
+
114
+ @jane.mailboxes.where(:name => 'private_mailbox').first.should_not be_nil
115
+ @jane.mailboxes.where(:name => 'public_mailbox').first.should_not be_nil
116
+ @jane.mailboxes.where(:name => 'added_mailbox').first.should_not be_nil
117
+
118
+ @victoria.mailboxes.where(:name => 'private_mailbox').first.should_not be_nil
119
+ @victoria.mailboxes.where(:name => 'public_mailbox').first.should_not be_nil
120
+ @victoria.mailboxes.where(:name => 'added_mailbox').first.should_not be_nil
41
121
  end
42
122
  end
43
123
 
@@ -86,43 +166,4 @@ describe Facteur::AddresseeModel do
86
166
  end
87
167
  end
88
168
 
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
-
128
169
  end
data/spec/spec_helper.rb CHANGED
@@ -60,6 +60,7 @@ end
60
60
 
61
61
  def create_users
62
62
  User.delete_all
63
+ Mailbox.delete_all
63
64
  %w(John Peter James Mary Jane Victoria).each do |name|
64
65
  eval "@#{name.downcase} = User.create(:name => '#{name}')"
65
66
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 1
9
- version: 0.3.1
8
+ - 2
9
+ version: 0.3.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Rawane ZOSSOU