Skip to content

Commit ed44e54

Browse files
authored
Merge pull request #88 from christhomson/locale-in-template-data
`Api#render`: allow locale to be passed in `template_data`
2 parents 359434a + 4e40338 commit ed44e54

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

lib/send_with_us/api.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def emails()
145145
alias list_templates emails
146146

147147
def render(template_id, version_id = nil, template_data = {}, strict = false)
148-
locale = template_data.delete(:locale)
148+
locale = template_data[:locale]
149149

150150
payload = {
151151
template: template_id,

test/lib/send_with_us/api_test.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,26 @@
9999

100100
it { subject.customer_get(email) }
101101
end
102+
103+
describe '#render' do
104+
let(:locale) { 'fr-CA' }
105+
let(:template_id) { 'template-id' }
106+
let(:template_data) { { foo: 'bar', locale: locale } }
107+
let(:strict) { true }
108+
let(:version_id) { 'some-version-id' }
109+
110+
let(:payload) do
111+
{
112+
template: template_id,
113+
template_data: template_data,
114+
strict: strict,
115+
version_id: version_id,
116+
locale: locale,
117+
}
118+
end
119+
120+
before { SendWithUs::ApiRequest.any_instance.expects(:post).with(:render, payload.to_json) }
121+
122+
it { subject.render(template_id, version_id, template_data, strict) }
123+
end
102124
end

0 commit comments

Comments
 (0)