mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-23 10:40:13 +01:00
Support dispatching emailed-in todos based on To: field as well as From: field. Setting configured in site.yml.
This commit is contained in:
parent
eb9fc5391c
commit
dbeb793214
4 changed files with 55 additions and 2 deletions
29
spec/models/message_gateway_spec.rb
Normal file
29
spec/models/message_gateway_spec.rb
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
require File.dirname(__FILE__) + '/../spec_helper'
|
||||
|
||||
describe MessageGateway do
|
||||
before :each do
|
||||
todo = mock_model(Todo, :description= => nil, :notes= => nil, :context_id= => nil, :save! => nil)
|
||||
|
||||
@user = mock_model(User,
|
||||
:prefs => mock_model(Preference, :sms_context => mock_model(Context)),
|
||||
:todos => mock('Todo collection', :find => nil, :build => todo),
|
||||
:contexts => mock('Context collection', :exists? => true, :find => nil))
|
||||
|
||||
User.stub!(:find).and_return(@user)
|
||||
end
|
||||
|
||||
def load_message(filename)
|
||||
MessageGateway.receive(File.read(File.join(RAILS_ROOT, 'test', 'fixtures', filename)))
|
||||
end
|
||||
|
||||
|
||||
it "should dispatch on From: or To: according to site.yml" do
|
||||
SITE_CONFIG['email_dispatch'] = 'from'
|
||||
User.should_receive(:find).with(:first, :include => [:preference], :conditions => ["preferences.sms_email = ?", '5555555555@tmomail.net'])
|
||||
load_message('sample_email.txt')
|
||||
|
||||
SITE_CONFIG['email_dispatch'] = 'to'
|
||||
User.should_receive(:find).with(:first, :include => [:preference], :conditions => ["preferences.sms_email = ?", 'gtd@tracks.com'])
|
||||
load_message('sample_email.txt')
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue