Browse files

Sort hashes so all tests pass for Ruby 1.8.7 and 1.9.2, would be bett…

…er to change specs than rely on a ordered hash
  • Loading branch information...
1 parent 5ce02f7 commit d1b8d673a51d0014e25dfec5ea72ecb6eb9a4a89 @jsntv200 jsntv200 committed Feb 3, 2012
Showing with 12 additions and 12 deletions.
  1. +2 −2 app/models/mail.rb
  2. +1 −1 lib/mailer_tags.rb
  3. +9 −9 spec/lib/mailer_tags_spec.rb
View
4 app/models/mail.rb
@@ -24,7 +24,7 @@ def self.config_errors(config)
end
def self.config_error_messages(config)
- config_errors(config).collect do |field, message|
+ config_errors(config).sort.collect do |field, message|
"'#{field}' #{message}"
end.to_sentence
end
@@ -199,4 +199,4 @@ def leave_blank_field
def disallow_link_fields
@config[:disallow_links] if @config.has_key?(:disallow_links)
end
-end
+end
View
2 lib/mailer_tags.rb
@@ -368,7 +368,7 @@ def mailer_attrs(tag, extras={})
'tabindex' => nil,
'title' => nil,
'width' => nil}.merge(extras)
- result = attrs.collect do |k,v|
+ result = attrs.sort.collect do |k,v|
v = (tag.attr[k] || v)
if k == 'class' && tag.attr['required'].present?
v = [v, 'required', tag.attr['required']].compact.join(' ')
View
18 spec/lib/mailer_tags_spec.rb
@@ -206,33 +206,33 @@
describe "<r:mailer:select>" do
it "should render a select tag" do
- pages(:mail_form).should render('<r:mailer:select name="foo" />').as('<select size="1" id="foo" name="mailer[foo]"></select>')
+ pages(:mail_form).should render('<r:mailer:select name="foo" />').as('<select id="foo" size="1" name="mailer[foo]"></select>')
end
it "should raise an error if the name attribute is not specified" do
pages(:mail_form).should render("<r:mailer:select />").with_error("`mailer:select' tag requires a `name' attribute")
end
it "should render its contents within the select tag" do
- pages(:mail_form).should render('<r:mailer:select name="foo">bar</r:mailer:select>').as('<select size="1" id="foo" name="mailer[foo]">bar</select>')
+ pages(:mail_form).should render('<r:mailer:select name="foo">bar</r:mailer:select>').as('<select id="foo" size="1" name="mailer[foo]">bar</select>')
end
it "should render nested <r:mailer:option> tags as option tags" do
- pages(:mail_form).should render('<r:mailer:select name="foo"><r:option value="bar">bar</r:option></r:mailer:select>').as('<select size="1" id="foo" name="mailer[foo]"><option value="bar" >bar</option></select>')
+ pages(:mail_form).should render('<r:mailer:select name="foo"><r:option value="bar">bar</r:option></r:mailer:select>').as('<select id="foo" size="1" name="mailer[foo]"><option value="bar" >bar</option></select>')
end
it "should select the specified option tag on a new form" do
- pages(:mail_form).should render('<r:mailer:select name="foo"><r:option value="bar" selected="selected">bar</r:option><r:option value="baz">baz</r:option></r:mailer:select>').as('<select size="1" id="foo" name="mailer[foo]"><option value="bar" selected="selected" >bar</option><option value="baz" >baz</option></select>')
+ pages(:mail_form).should render('<r:mailer:select name="foo"><r:option value="bar" selected="selected">bar</r:option><r:option value="baz">baz</r:option></r:mailer:select>').as('<select id="foo" size="1" name="mailer[foo]"><option value="bar" selected="selected" >bar</option><option value="baz" >baz</option></select>')
end
it "should select the option tag with previously posted value" do
@page = pages(:mail_form)
@page.last_mail = @mail = Mail.new(@page, config(@page), 'foo' => 'baz')
- @page.should render('<r:mailer:select name="foo"><r:option value="bar" selected="selected">bar</r:option><r:option value="baz">baz</r:option></r:mailer:select>').as('<select size="1" id="foo" name="mailer[foo]"><option value="bar" >bar</option><option value="baz" selected="selected" >baz</option></select>')
+ @page.should render('<r:mailer:select name="foo"><r:option value="bar" selected="selected">bar</r:option><r:option value="baz">baz</r:option></r:mailer:select>').as('<select id="foo" size="1" name="mailer[foo]"><option value="bar" >bar</option><option value="baz" selected="selected" >baz</option></select>')
end
it "should add a 'required' hidden field when the required attribute is specified" do
- pages(:mail_form).should render("<r:mailer:select name='foo' required='true'/>").as(%Q{<select size="1" class="required true" id="foo" name="mailer[foo]"></select><input type="hidden" name="mailer[required][foo]" value="true" />})
+ pages(:mail_form).should render("<r:mailer:select name='foo' required='true'/>").as(%Q{<select class="required true" id="foo" size="1" name="mailer[foo]"></select><input type="hidden" name="mailer[required][foo]" value="true" />})
end
end
@@ -272,19 +272,19 @@ def render_tag_in_mailer(content)
describe "<r:mailer:textarea>" do
it "should render a textarea tag" do
- pages(:mail_form).should render('<r:mailer:textarea name="body" />').as('<textarea id="body" rows="5" cols="35" name="mailer[body]"></textarea>')
+ pages(:mail_form).should render('<r:mailer:textarea name="body" />').as('<textarea cols="35" id="body" rows="5" name="mailer[body]"></textarea>')
end
it "should raise an error if the name attribute is not specified" do
pages(:mail_form).should render("<r:mailer:textarea />").with_error("`mailer:textarea' tag requires a `name' attribute")
end
it "should render its contents as the contents of the textarea tag" do
- pages(:mail_form).should render('<r:mailer:textarea name="body">Hello, world!</r:mailer:textarea>').as('<textarea id="body" rows="5" cols="35" name="mailer[body]">Hello, world!</textarea>')
+ pages(:mail_form).should render('<r:mailer:textarea name="body">Hello, world!</r:mailer:textarea>').as('<textarea cols="35" id="body" rows="5" name="mailer[body]">Hello, world!</textarea>')
end
it "should add a 'required' hidden field when the required attribute is specified" do
- pages(:mail_form).should render("<r:mailer:textarea name='body' required='true'/>").as(%Q{<textarea class="required true" id="body" rows="5" cols="35" name="mailer[body]"></textarea><input type="hidden" name="mailer[required][body]" value="true" />})
+ pages(:mail_form).should render("<r:mailer:textarea name='body' required='true'/>").as(%Q{<textarea class="required true" cols="35" id="body" rows="5" name="mailer[body]"></textarea><input type="hidden" name="mailer[required][body]" value="true" />})
end
end

0 comments on commit d1b8d67

Please sign in to comment.