padrino-helpers 0.13.0.beta3 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 04bc4991e6d578ff63ba8e869485e744e3383578
4
- data.tar.gz: 17bd91f2a5fec04199e4985ca3b7b90d7e285399
3
+ metadata.gz: 151e75de2e213c7b7e67545cc17fc8272921078f
4
+ data.tar.gz: 613800341c4c854f60f8435f1ed2aa85b1e82430
5
5
  SHA512:
6
- metadata.gz: 246cb04ce86e264275303dcc5d7f62a9b27e95dce324ce40341620b262ad8660089d24fd12c2c4057ceb60811db21eb6c6877171e4910c040566230b56ad2648
7
- data.tar.gz: 7556f2f8fe3cd8a6b7fabab699401d91691032074f382536f682ff11ff72bc7486a79fa7cd01e39cd39b2377abb1ea239236d03518f042c4f22e3bf1d297f67a
6
+ metadata.gz: 2a490471869b20f05dae5f3438f6ead1cf63041cf795afc767013891b5d1d3d62b80e95409a82f29efe342d29d88e8e869bee3de1b9aff20a06dbc83de3de3b3
7
+ data.tar.gz: b97a7765a8ef80e94d0c67a978ff804e13cdf4e82454fcb77a192edfe2c7279bbbe5592974982c695b25c4d353f54ee4c6e4c14f982a225397657a92561b5357
@@ -45,7 +45,9 @@ module Padrino
45
45
  #
46
46
  def option_is_selected?(value, caption, selected_values)
47
47
  Array(selected_values).any? do |selected|
48
- [value.to_s, caption.to_s].include?(selected.to_s)
48
+ value ?
49
+ value.to_s == selected.to_s :
50
+ caption.to_s == selected.to_s
49
51
  end
50
52
  end
51
53
 
@@ -90,7 +92,7 @@ module Padrino
90
92
  collection.map{ |item| [ item.send(fields.first), item.send(fields.last) ] }
91
93
  else
92
94
  options.delete(:options) || []
93
- end
95
+ end
94
96
  end
95
97
  end
96
98
  end
@@ -202,7 +202,7 @@ module Padrino
202
202
  # This means that no engine was explicitly defined
203
203
  data, engine = resolve_template(engine, options) if data.nil?
204
204
 
205
- ensure_rendering_engine(engine) || (options[:layout] ||= false)
205
+ ensure_rendering_engine(engine) || (options[:layout] ||= @layout || false)
206
206
 
207
207
  # Cleanup the template.
208
208
  @current_engine, engine_was = engine, @current_engine
@@ -94,7 +94,7 @@ class RenderDemo < Padrino::Application
94
94
 
95
95
  helpers do
96
96
  def dive_helper(ext)
97
- # @current_engine, save = nil
97
+ # @current_engine, save = nil, @current_engine
98
98
  form_result = form_tag '/' do
99
99
  render "dive_inner_#{ext}"
100
100
  end
@@ -44,7 +44,7 @@ class MiniTest::Spec
44
44
  path = "/views/#{name}"
45
45
  path += ".#{options.delete(:locale)}" if options[:locale].present?
46
46
  path += ".#{options[:format]}" if options[:format].present?
47
- path += ".erb" unless options[:format].to_s =~ /erb|slim|haml|rss|atom|builder/
47
+ path += ".erb" unless options[:format].to_s =~ /erb|slim|haml|rss|atom|builder|liquid/
48
48
  path += ".builder" if options[:format].to_s =~ /rss|atom/
49
49
  file = File.dirname(__FILE__) + path
50
50
  File.open(file, 'w') { |io| io.write content }
@@ -773,6 +773,20 @@ describe "FormHelpers" do
773
773
  assert_has_tag('select option', :content => 'Black', :value => 'black1') { actual_html }
774
774
  end
775
775
 
776
+ it 'should display selected options first based on values not content' do
777
+ options = [['First', 'one'], ['one', 'two'], ['three', 'three']]
778
+ actual_html = select_tag(:number, :options => options, :selected => 'one')
779
+ assert_has_tag('select option', :selected => 'selected', :count => 1) { actual_html }
780
+ assert_has_tag('select option', :content => 'First', :value => 'one', :selected => 'selected') { actual_html }
781
+ end
782
+
783
+ it 'should display selected options falling back to checking content' do
784
+ options = [['one'], ['two'], ['three', 'three']]
785
+ actual_html = select_tag(:number, :options => options, :selected => 'one').gsub!(/value="(one|two)"/, '').html_safe
786
+ assert_has_tag('select option', :selected => 'selected', :count => 1) { actual_html }
787
+ assert_has_tag('select option', :content => 'one', :selected => 'selected') { actual_html }
788
+ end
789
+
776
790
  it 'should display options with values and accept disabled options' do
777
791
  options = [['Green', 'green1', {:disabled => true}], ['Blue', 'blue1'], ['Black', "black1"]]
778
792
  actual_html = select_tag(:favorite_color, :options => options)
@@ -785,7 +799,7 @@ describe "FormHelpers" do
785
799
 
786
800
  it 'should display option with values and multiple selected' do
787
801
  options = [['Green', 'green1'], ['Blue', 'blue1'], ['Black', "black1"]]
788
- actual_html = select_tag(:favorite_color, :options => options, :selected => ['green1', 'Black'])
802
+ actual_html = select_tag(:favorite_color, :options => options, :selected => ['green1', 'black1'])
789
803
  assert_has_tag(:select, :name => 'favorite_color') { actual_html }
790
804
  assert_has_tag('select option', :selected => 'selected', :count => 2) { actual_html }
791
805
  assert_has_tag('select option', :content => 'Green', :value => 'green1', :selected => 'selected') { actual_html }
@@ -1,5 +1,6 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/helper')
2
2
  require 'slim'
3
+ require 'liquid'
3
4
 
4
5
  describe "Rendering" do
5
6
  def setup
@@ -87,6 +88,26 @@ describe "Rendering" do
87
88
  assert_equal "js file", body
88
89
  end
89
90
 
91
+ it 'should set and restore layout in controllers' do
92
+ create_layout :boo, "boo is a <%= yield %>"
93
+ create_layout :moo, "moo is a <%= yield %>"
94
+ create_view :foo, "liquid file", :format => :liquid
95
+ mock_app do
96
+ layout :boo
97
+ controller :moo do
98
+ layout :moo
99
+ get('/liquid') { render :foo }
100
+ end
101
+ controller :boo do
102
+ get('/liquid') { render :foo }
103
+ end
104
+ end
105
+ get "/moo/liquid"
106
+ assert_equal "moo is a liquid file", body
107
+ get "/boo/liquid"
108
+ assert_equal "boo is a liquid file", body
109
+ end
110
+
90
111
  it 'should use correct layout for each format' do
91
112
  create_layout :application, "this is an <%= yield %>"
92
113
  create_layout :application, "document start <%= yield %> end", :format => :xml
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: padrino-helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.0.beta3
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Padrino Team
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2015-08-02 00:00:00.000000000 Z
14
+ date: 2015-10-11 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: padrino-support
@@ -19,14 +19,14 @@ dependencies:
19
19
  requirements:
20
20
  - - '='
21
21
  - !ruby/object:Gem::Version
22
- version: 0.13.0.beta3
22
+ version: 0.13.0
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - '='
28
28
  - !ruby/object:Gem::Version
29
- version: 0.13.0.beta3
29
+ version: 0.13.0
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: tilt
32
32
  requirement: !ruby/object:Gem::Requirement
@@ -234,12 +234,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
234
234
  version: '0'
235
235
  required_rubygems_version: !ruby/object:Gem::Requirement
236
236
  requirements:
237
- - - '>'
237
+ - - '>='
238
238
  - !ruby/object:Gem::Version
239
- version: 1.3.1
239
+ version: 1.3.6
240
240
  requirements: []
241
241
  rubyforge_project: padrino-helpers
242
- rubygems_version: 2.0.6
242
+ rubygems_version: 2.4.8
243
243
  signing_key:
244
244
  specification_version: 4
245
245
  summary: Helpers for padrino