Skip to content

Commit 8e6aac8

Browse files
author
tjwp-yesware
committed
Merge pull request vendasta#7 from Yesware/nested-mailbox-bug
Fix a bug in nested access to mailboxes
2 parents 7214fa7 + 618cdc9 commit 8e6aac8

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

lib/gmail/client/base.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def mailbox(name, read_only = nil, &block)
163163
result = block.arity == 1 ? block.call(mailbox) : block.call
164164
mailbox_stack.pop
165165
last_mailbox = mailbox_stack.last
166-
switch_to_mailbox(last_mailbox, last_mailbox ? last_mailbox.read_only : nil)
166+
switch_to_mailbox(last_mailbox, last_mailbox ? mailboxes[last_mailbox].read_only : nil)
167167
return result
168168
end
169169

spec/support/mailbox_helpers.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,22 @@
1919
client.labels.delete("TEST")
2020
end
2121
end
22+
23+
it "should allow nested mailbox access" do
24+
mock_client do |client|
25+
client.labels.create("TEST")
26+
client.labels.create("TEST2")
27+
28+
# Add a mailbox to the stack
29+
client.send(:mailbox_stack) << 'TEST'
30+
client.mailboxes['TEST'] = Gmail::Mailbox.new(client, 'TEST', true)
31+
32+
client.mailbox("TEST2") do |mailbox|
33+
mailbox.name.should == "TEST2"
34+
end
35+
36+
client.labels.delete("TEST")
37+
client.labels.delete("TEST2")
38+
end
39+
end
2240
end

0 commit comments

Comments
 (0)