use user host url for summary message links, fixes #4455

Change-Id: Iddfd3b9c72cd9367b5bcb22928de3adfe795c4e8
Reviewed-on: https://gerrit.instructure.com/3440
Reviewed-by: Zach Wily <zach@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
This commit is contained in:
Brian Palmer 2011-05-03 11:03:24 -06:00
parent 39588b17be
commit 2cb69ae0d7
3 changed files with 18 additions and 4 deletions

View File

@ -1,5 +1,5 @@
<% define_content :link do %>
http://<%= HostUrl.default_host %>
http://<%= HostUrl.context_host(user.pseudonym.try(:account)) %>
<% end %>
<% define_content :subject do %>
@ -25,4 +25,4 @@
You can change your notification settings by visiting the following page:
http://<%= HostUrl.default_host %>/profile/communication
http://<%= HostUrl.context_host(user.pseudonym.try(:account)) %>/profile/communication

View File

@ -17,7 +17,6 @@
#
def notification_model(opts={})
Notification.find(:all).each{|n| n.destroy }
@notification = Notification.create!(notification_valid_attributes.merge(opts))
end
@ -28,4 +27,4 @@ def notification_valid_attributes
:body => "value for body",
:category => "TestImmediately"
}
end
end

View File

@ -111,4 +111,19 @@ describe DelayedMessage do
@delayed_message.state.should eql(:sent)
end
end
it "should use the user's main account domain for links" do
Canvas::MessageHelper.create_notification('Summary', 'Summaries', 0, '', 'Summaries')
account = Account.create!(:name => 'new acct')
user = user_with_pseudonym(:account => account)
user.pseudonym.update_attribute(:account, account)
user.pseudonym.account.should == account
HostUrl.should_receive(:context_host).with(user.pseudonym.account).at_least(:once).and_return("dm.dummy.test.host")
HostUrl.should_receive(:default_host).any_number_of_times.and_return("test.host")
dm = DelayedMessage.create!(:summary => "This is a notification", :context => Account.default, :communication_channel => user.communication_channel, :notification => notification_model)
DelayedMessage.summarize([dm])
message = Message.last
message.body.to_s.should_not match(%r{http://test.host/})
message.body.to_s.should match(%r{http://dm.dummy.test.host/})
end
end