# Check that we can't send a message from a GET request
assert_difference "ActionMailer::Base.deliveries.size", 0 do
assert_difference "Message.count", 0 do
- get :new,
- :params => { :display_name => recipient_user.display_name,
- :message => { :title => "Test Message", :body => "Test message body" } }
+ perform_enqueued_jobs do
+ get :new,
+ :params => { :display_name => recipient_user.display_name,
+ :message => { :title => "Test Message", :body => "Test message body" } }
+ end
end
end
assert_response :success
# Check that the subject is preserved over errors
assert_difference "ActionMailer::Base.deliveries.size", 0 do
assert_difference "Message.count", 0 do
- post :new,
- :params => { :display_name => recipient_user.display_name,
- :message => { :title => "Test Message", :body => "" } }
+ perform_enqueued_jobs do
+ post :new,
+ :params => { :display_name => recipient_user.display_name,
+ :message => { :title => "Test Message", :body => "" } }
+ end
end
end
assert_response :success
# Check that the body text is preserved over errors
assert_difference "ActionMailer::Base.deliveries.size", 0 do
assert_difference "Message.count", 0 do
- post :new,
- :params => { :display_name => recipient_user.display_name,
- :message => { :title => "", :body => "Test message body" } }
+ perform_enqueued_jobs do
+ post :new,
+ :params => { :display_name => recipient_user.display_name,
+ :message => { :title => "", :body => "Test message body" } }
+ end
end
end
assert_response :success
# Check that sending a message works
assert_difference "ActionMailer::Base.deliveries.size", 1 do
assert_difference "Message.count", 1 do
- post :create,
- :params => { :display_name => recipient_user.display_name,
- :message => { :title => "Test Message", :body => "Test message body" } }
+ perform_enqueued_jobs do
+ post :create,
+ :params => { :display_name => recipient_user.display_name,
+ :message => { :title => "Test Message", :body => "Test message body" } }
+ end
end
end
assert_redirected_to inbox_messages_path
assert_equal "[OpenStreetMap] Test Message", e.subject
assert_match(/Test message body/, e.text_part.decoded)
assert_match(/Test message body/, e.html_part.decoded)
- assert_match %r{#{SERVER_URL}/messages/[0-9]+}, e.text_part.decoded
+ assert_match %r{#{Settings.server_url}/messages/[0-9]+}, e.text_part.decoded
ActionMailer::Base.deliveries.clear
m = Message.last
assert_equal user.id, m.from_user_id
assert_no_difference "ActionMailer::Base.deliveries.size" do
assert_no_difference "Message.count" do
with_message_limit(0) do
- post :create,
- :params => { :display_name => recipient_user.display_name,
- :message => { :title => "Test Message", :body => "Test message body" } }
- assert_response :success
- assert_template "new"
- assert_select ".error", /wait a while/
+ perform_enqueued_jobs do
+ post :create,
+ :params => { :display_name => recipient_user.display_name,
+ :message => { :title => "Test Message", :body => "Test message body" } }
+ assert_response :success
+ assert_template "new"
+ assert_select ".error", /wait a while/
+ end
end
end
end
get :inbox
assert_response :success
assert_template "inbox"
- assert_select "table.messages", :count => 1 do
+ assert_select ".content-inner > table", :count => 1 do
assert_select "tr", :count => 2
assert_select "tr#inbox-#{read_message.id}.inbox-row", :count => 1
end
get :outbox
assert_response :success
assert_template "outbox"
- assert_select "table.messages", :count => 1 do
+ assert_select ".content-inner > table", :count => 1 do
assert_select "tr", :count => 2
assert_select "tr.inbox-row", :count => 1
end
private
def with_message_limit(value)
- max_messages_per_hour = Object.send("remove_const", "MAX_MESSAGES_PER_HOUR")
- Object.const_set("MAX_MESSAGES_PER_HOUR", value)
+ max_messages_per_hour = Settings.max_messages_per_hour
+ Settings.max_messages_per_hour = value
yield
- Object.send("remove_const", "MAX_MESSAGES_PER_HOUR")
- Object.const_set("MAX_MESSAGES_PER_HOUR", max_messages_per_hour)
+ Settings.max_messages_per_hour = max_messages_per_hour
end
end