diff --git a/app/models/sms_gateway.rb b/app/models/message_gateway.rb similarity index 96% rename from app/models/sms_gateway.rb rename to app/models/message_gateway.rb index d7b3cefa..83f8ad67 100644 --- a/app/models/sms_gateway.rb +++ b/app/models/message_gateway.rb @@ -1,5 +1,4 @@ -class SMSGateway < ActionMailer::Base - CONTEXT_NAME = 'Inbox' +class MessageGateway < ActionMailer::Base def receive(email) user = User.find(:first, :include => [:preference], :conditions => ["preferences.sms_email = ?", email.from[0].strip]) if user.nil? diff --git a/app/views/preferences/edit.html.erb b/app/views/preferences/edit.html.erb index 28171a7e..796cd8ce 100644 --- a/app/views/preferences/edit.html.erb +++ b/app/views/preferences/edit.html.erb @@ -19,8 +19,8 @@
  • refresh: automatic refresh interval for each of the pages (in minutes)
  • verbose action descriptor: when true, show project/context name in action listing; when false show [P]/[C] with tool tips
  • mobile todos per page: the maximum number of actions to show on a single page in the mobile view
  • -
  • SMS email: the email address of your cell phone for sending text messages to your Tracks account
  • -
  • SMS context: the context to which tasks sent in via SMS should be added
  • +
  • From email: the email address you use for sending todos as email or SMS messages to your Tracks account
  • +
  • Message context: the context to which tasks sent in via email or SMS should be added
  • diff --git a/app/views/preferences/index.html.erb b/app/views/preferences/index.html.erb index d86dccf1..81b0edf0 100644 --- a/app/views/preferences/index.html.erb +++ b/app/views/preferences/index.html.erb @@ -28,8 +28,8 @@
  • Refresh interval (in minutes): <%= prefs.refresh %>
  • Verbose action descriptors: <%= prefs.verbose_action_descriptors %>
  • Actions per page (Mobile View): <%= prefs.mobile_todos_per_page %>
  • -
  • SMS email address: <%= prefs.sms_email %>
  • -
  • SMS context: <%= prefs.sms_context.nil? ? "None" : prefs.sms_context.name %>
  • +
  • From email: <%= prefs.sms_email %>
  • +
  • Message context: <%= prefs.sms_context.nil? ? "None" : prefs.sms_context.name %>
  • <%= link_to "Edit preferences »", { :controller => 'preferences', :action => 'edit'}, :class => 'edit_link' %> diff --git a/test/unit/sms_gateway_test.rb b/test/unit/message_gateway_test.rb similarity index 88% rename from test/unit/sms_gateway_test.rb rename to test/unit/message_gateway_test.rb index da6c121d..12b6aadf 100644 --- a/test/unit/sms_gateway_test.rb +++ b/test/unit/message_gateway_test.rb @@ -1,6 +1,6 @@ require File.dirname(__FILE__) + '/../test_helper' -class SMSGatewayTest < Test::Rails::TestCase +class MessageGatewayTest < Test::Rails::TestCase fixtures :users, :contexts def setup @@ -9,7 +9,7 @@ class SMSGatewayTest < Test::Rails::TestCase end def load_message(filename) - SMSGateway.receive(File.read(File.join(RAILS_ROOT, 'test', 'fixtures', filename))) + MessageGateway.receive(File.read(File.join(RAILS_ROOT, 'test', 'fixtures', filename))) end def test_sms_with_no_subject @@ -53,7 +53,7 @@ class SMSGatewayTest < Test::Rails::TestCase todo_count = Todo.count badmessage = File.read(File.join(RAILS_ROOT, 'test', 'fixtures', 'sample_sms.txt')) badmessage.gsub!("5555555555", "notauser") - SMSGateway.receive(badmessage) + MessageGateway.receive(badmessage) assert_equal(todo_count, Todo.count) end @@ -63,12 +63,12 @@ class SMSGatewayTest < Test::Rails::TestCase valid_context_msg = message.gsub('message_content', 'anothercontext: this is a task') invalid_context_msg = message.gsub('message_content', 'notacontext: this is a task') - SMSGateway.receive(valid_context_msg) + MessageGateway.receive(valid_context_msg) valid_context_todo = Todo.find(:first, :conditions => {:description => "this is a task"}) assert_not_nil(valid_context_todo) assert_equal(contexts(:anothercontext), valid_context_todo.context) - SMSGateway.receive(invalid_context_msg) + MessageGateway.receive(invalid_context_msg) invalid_context_todo = Todo.find(:first, :conditions => {:description => 'notacontext: this is a task'}) assert_not_nil(invalid_context_todo) assert_equal(@inbox, invalid_context_todo.context) @@ -82,22 +82,22 @@ class SMSGatewayTest < Test::Rails::TestCase valid_due_msg3 = message.gsub('message_content', 'due:1/28/2008 funky!') invalid_due_msg1 = message.gsub('message_content', 'do something tomorrow due:xxxx and remember it!') - SMSGateway.receive(valid_due_msg1) + MessageGateway.receive(valid_due_msg1) valid_due_todo1 = Todo.find(:first, :conditions => {:description => "do something tomorrow"}) assert_not_nil(valid_due_todo1) assert_equal(Date.civil(2008, 6, 15), valid_due_todo1.due) - SMSGateway.receive(valid_due_msg2) + MessageGateway.receive(valid_due_msg2) valid_due_todo2 = Todo.find(:first, :conditions => {:description => "do something tomorrow and remember it!"}) assert_not_nil(valid_due_todo2) assert_equal(Date.civil(2008, 6, 28), valid_due_todo2.due) - SMSGateway.receive(valid_due_msg3) + MessageGateway.receive(valid_due_msg3) valid_due_todo3 = Todo.find(:first, :conditions => {:description => "funky!"}) assert_not_nil(valid_due_todo3) assert_equal(Date.civil(2008, 1, 28), valid_due_todo3.due) - SMSGateway.receive(invalid_due_msg1) + MessageGateway.receive(invalid_due_msg1) invalid_due_todo1 = Todo.find(:first, :conditions => {:description => "do something tomorrow due:xxxx and remember it!"}) assert_not_nil(invalid_due_todo1) assert_nil(invalid_due_todo1.due) @@ -111,23 +111,23 @@ class SMSGatewayTest < Test::Rails::TestCase valid_show_msg3 = message.gsub('message_content', "show:#{Date.tomorrow.to_s} alternative format") invalid_show_msg1 = message.gsub('message_content', 'do something tomorrow show:xxxx and remember it!') - SMSGateway.receive(valid_show_msg1) + MessageGateway.receive(valid_show_msg1) valid_show_todo1 = Todo.find(:first, :conditions => {:description => "do something tomorrow"}) assert_not_nil(valid_show_todo1) assert_equal(Date.tomorrow, valid_show_todo1.show_from) - SMSGateway.receive(valid_show_msg2) + MessageGateway.receive(valid_show_msg2) valid_show_todo2 = Todo.find(:first, :conditions => {:description => "do something next week and remember it!"}) assert_not_nil(valid_show_todo2) assert_equal(Date.today.next_week, valid_show_todo2.show_from) - SMSGateway.receive(valid_show_msg3) + MessageGateway.receive(valid_show_msg3) valid_show_todo3 = Todo.find(:first, :conditions => {:description => "alternative format"}) # p @user.todos.last assert_not_nil(valid_show_todo3) assert_equal(Date.tomorrow, valid_show_todo3.show_from) - SMSGateway.receive(invalid_show_msg1) + MessageGateway.receive(invalid_show_msg1) invalid_show_todo1 = Todo.find(:first, :conditions => {:description => "do something tomorrow show:xxxx and remember it!"}) assert_not_nil(invalid_show_todo1) assert_nil(invalid_show_todo1.show_from)