enhanced_date_select 1.0.8 → 1.1.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: b34333236164e6785df96db1b5ff1dcaffbb31f8
4
- data.tar.gz: 7038e7e9a22fe7f148bf5fa397ab6dc09b6f7f42
3
+ metadata.gz: 3b98e7441ce7fe22743dc678e910ecf2cf5fe7e1
4
+ data.tar.gz: f3f3d99af313e538aae77c5eed222d736793d571
5
5
  SHA512:
6
- metadata.gz: a3fd14406101dad7161ea3a868a8b41f88d77bb7e0c1165d68ca5a0bc751fb784784713651cc892ab1ab63f3da7488eb8c6bf2b07f7cbe0a9d4dcef7409a18be
7
- data.tar.gz: 4f7b503c899bafa67d5434fcb37ddb9d61782d8c3825771c3d7de0843876fc7eefd7fb48f6475039b4c7f54bf93a4ed871bfefdf61c96abdcf2ced2cf02aae08
6
+ metadata.gz: 6672fd65897ffdfe0f45ddd7ffcb30486503d171fd28d6b1003316baee56b6c4e921025ba92d4893de6236f78b4a9b26c2d5f214028e770e488a8140544ea774
7
+ data.tar.gz: b241f302ab001674c00fe4673a5b1da18a638c6dccb9d6e0b740672032299aed9286d74c3d0d58266b563622055de4d29f73563d545b205f6f8a45b3bbcffb99
data/.rubocop.yml ADDED
@@ -0,0 +1,67 @@
1
+ AllCops:
2
+ Exclude:
3
+ - enhanced_date_select.gemspec
4
+ - Guardfile
5
+
6
+ Documentation:
7
+ Enabled: false
8
+
9
+ Encoding:
10
+ Enabled: false
11
+
12
+ LineLength:
13
+ Max: 200
14
+
15
+ AccessModifierIndentation:
16
+ EnforcedStyle: outdent
17
+
18
+ IfUnlessModifier:
19
+ Enabled: false
20
+
21
+ CaseIndentation:
22
+ IndentWhenRelativeTo: case
23
+ IndentOneStep: true
24
+
25
+ MethodLength:
26
+ CountComments: false
27
+ Max: 20
28
+
29
+ SignalException:
30
+ Enabled: false
31
+
32
+ ColonMethodCall:
33
+ Enabled: false
34
+
35
+ AsciiComments:
36
+ Enabled: false
37
+
38
+ RegexpLiteral:
39
+ Enabled: false
40
+
41
+ AssignmentInCondition:
42
+ Enabled: false
43
+
44
+ ParameterLists:
45
+ CountKeywordArgs: false
46
+
47
+ SingleLineBlockParams:
48
+ Methods:
49
+ - reduce:
50
+ - memo
51
+ - item
52
+
53
+ Metrics/AbcSize:
54
+ Enabled: false
55
+
56
+ Style/CollectionMethods:
57
+ Enabled: true
58
+
59
+ Style/SymbolArray:
60
+ Enabled: true
61
+
62
+ Style/ExtraSpacing:
63
+ Enabled: true
64
+
65
+ Style/FileName:
66
+ Enabled: false
67
+
data/Appraisals CHANGED
@@ -18,6 +18,8 @@ appraise "rails-4.1.1" do
18
18
  gem "rails", "4.1.1"
19
19
  end
20
20
 
21
+
22
+
21
23
  appraise "rails-4.1.4" do
22
24
  gem "rails", "4.1.4"
23
- end
25
+ end
data/Gemfile CHANGED
@@ -1,7 +1,3 @@
1
- source "http://rubygems.org"
2
- # Add dependencies required to use your gem here.
3
- # Example:
4
- # gem "activesupport", ">= 2.3.5"
5
- gemspec
6
- # Add dependencies to develop your gem here.
7
- # Include everything needed to run rake, tests, features, etc.
1
+ source 'http://rubygems.org'
2
+
3
+ gemspec
data/Rakefile CHANGED
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
- require File.expand_path("../version", __FILE__)
2
+ require File.expand_path('../version', __FILE__)
3
3
  require 'rubygems'
4
4
  require 'bundler/setup'
5
5
  require 'bundler/gem_tasks'
@@ -12,32 +12,29 @@ begin
12
12
  Bundler.setup(:default, :development)
13
13
  rescue Bundler::BundlerError => e
14
14
  $stderr.puts e.message
15
- $stderr.puts "Run `bundle install` to install missing gems"
15
+ $stderr.puts 'Run `bundle install` to install missing gems'
16
16
  exit e.status_code
17
17
  end
18
18
  require 'rake'
19
19
 
20
-
21
-
22
20
  RSpec::Core::RakeTask.new(:spec) do |spec|
23
- # spec.rspec_opts = ['--backtrace ']
21
+ spec.rspec_opts = ['--backtrace '] if ENV['DEBUG']
24
22
  end
25
23
 
26
- desc "Default: run the unit tests."
27
- task :default => [:all]
24
+ desc 'Default: run the unit tests.'
25
+ task default: [:all]
28
26
 
29
27
  desc 'Test the plugin under all supported Rails versions.'
30
- task :all do |t|
31
- if ENV["TRAVIS"]
32
- exec(' bundle exec appraisal install && bundle exec rake appraisal spec && bundle exec rake coveralls:push')
28
+ task :all do
29
+ if ENV['TRAVIS']
30
+ exec('bundle exec appraisal install && bundle exec rake appraisal spec && bundle exec rake coveralls:push')
33
31
  else
34
- exec(' bundle exec appraisal install && bundle exec rake appraisal spec')
32
+ exec('bundle exec appraisal install && bundle exec rake appraisal spec')
35
33
  end
36
34
  end
37
35
 
38
36
  require 'rdoc/task'
39
37
  Rake::RDocTask.new do |rdoc|
40
-
41
38
  rdoc.rdoc_dir = 'rdoc'
42
39
  rdoc.title = "enhanced_date_select #{ EnhancedDateSelect.gem_version}"
43
40
  rdoc.rdoc_files.include('README*')
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
22
22
  s.require_paths = ["lib"]
23
23
  s.required_ruby_version = '>= 1.9'
24
24
 
25
- s.add_development_dependency 'rspec-rails', '~> 2.0', '>= 2.0'
25
+ s.add_development_dependency 'rspec-rails', '~> 2.0', '>= 2.0'
26
26
  s.add_development_dependency 'guard', '~> 2.6', '>= 2.6.1'
27
27
  s.add_development_dependency 'guard-rspec', '~> 4.2', '>= 4.2.9'
28
28
  s.add_development_dependency 'appraisal', '~> 1.0', '>= 1.0.0'
@@ -33,5 +33,7 @@ Gem::Specification.new do |s|
33
33
  s.add_development_dependency 'shoulda', '~> 3.5', '>= 3.5.0'
34
34
  s.add_development_dependency 'rake', '~> 10.3', '>= 10.3.0'
35
35
  s.add_development_dependency 'rspec-mocks', '~> 2.14', '>= 2.14.0'
36
-
36
+ s.add_development_dependency 'rubocop', '0.29'
37
+ s.add_development_dependency 'phare'
38
+ s.add_development_dependency "scss-lint"
37
39
  end
@@ -3,22 +3,21 @@ if defined?(Rails) && defined?(ActionView)
3
3
  module ActionView
4
4
  module Helpers
5
5
  module FormOptionsHelper
6
- def enhanced_date_select object, method, options = {}, html_options = {}
7
- if ( Rails::VERSION::MAJOR.to_i <= 3 )
8
- @instance_tag = InstanceTag.new(object, method, self, options.delete(:object))
6
+ def enhanced_date_select(object, method, options = {}, html_options = {})
7
+ if Rails::VERSION::MAJOR.to_i <= 3
8
+ @instance_tag = InstanceTag.new(object, method, self, options.delete(:object))
9
9
  else
10
10
  @instance_tag = Tags::Base.new(object, method, self, options)
11
11
  end
12
- @instance_tag .to_enhanced_date_select_tag(options, html_options)
12
+ @instance_tag.to_enhanced_date_select_tag(options, html_options)
13
13
  end
14
14
  end
15
15
 
16
16
  module EnhancedDateSelectTagHelper
17
- def to_enhanced_date_select_tag options, html_options
17
+ def to_enhanced_date_select_tag(options, html_options)
18
18
  enhanced_datetime_selector(options, html_options).enhanced_select_date.html_safe
19
19
  end
20
20
 
21
- private
22
21
  def enhanced_datetime_selector(options, html_options)
23
22
  datetime = options[:value] || value(object) || default_datetime(options)
24
23
 
@@ -28,56 +27,53 @@ if defined?(Rails) && defined?(ActionView)
28
27
  options[:field_name] = @method_name
29
28
  options[:include_position] = true
30
29
  options[:prefix] ||= @object_name
31
- options[:index] = @auto_index if @auto_index && !options.has_key?(:index)
30
+ options[:index] = @auto_index if @auto_index && !options.key?(:index)
32
31
 
33
32
  EnhancedDateTimeSelector.new(datetime, options, html_options)
34
33
  end
35
-
36
34
  end
35
+
37
36
  class InstanceTag
38
37
  include EnhancedDateSelectTagHelper
39
-
40
38
  end
41
39
 
42
40
  module Tags
43
41
  class Base
44
42
  include EnhancedDateSelectTagHelper
45
-
46
43
  end
47
44
  end
48
45
 
49
46
  class EnhancedDateTimeSelector < DateTimeSelector
50
-
51
47
  def enhanced_select_date
52
48
  order = date_order.dup
53
-
54
- @options[:discard_hour] = true
55
- @options[:discard_minute] = true
56
- @options[:discard_second] = true
57
-
58
- @options[:discard_year] ||= true unless order.include?(:year)
59
- @options[:discard_month] ||= true unless order.include?(:month)
60
- @options[:discard_day] ||= true if @options[:discard_month] || !order.include?(:day)
61
-
49
+ reset_options_enhanced(order)
62
50
  # If the day is hidden and the month is visible, the day should be set to the 1st so all month choices are valid (otherwise it could be 31 and February wouldn't be a valid date)
63
51
  if @datetime && @options[:discard_day] && !@options[:discard_month]
64
52
  if @datetime.is_a?(Hash)
65
53
  @datetime[:day] = 1
66
54
  else
67
- @datetime = @datetime.change(:day => 1)
55
+ @datetime = @datetime.change(day: 1)
68
56
  end
69
57
  end
70
-
71
- [:day, :month, :year].each { |o| order.unshift(o) unless order.include?(o) }
72
-
58
+ %w(day month year).each do |o|
59
+ order.unshift(o.to_sym) unless order.include?(o.to_sym)
60
+ end
73
61
  build_selects_from_types(order)
74
62
  end
75
63
 
76
- private
64
+ def reset_options_enhanced(order)
65
+ @options[:discard_hour] = true
66
+ @options[:discard_minute] = true
67
+ @options[:discard_second] = true
68
+ @options[:discard_year] ||= true unless order.include?(:year)
69
+ @options[:discard_month] ||= true unless order.include?(:month)
70
+ @options[:discard_day] ||= true if @options[:discard_month] || !order.include?(:day)
71
+ end
72
+
77
73
  %w( sec min hour day month year ).each do |method|
78
74
  define_method(method) do
79
75
  if @datetime
80
- if @datetime.kind_of?(Fixnum)
76
+ if @datetime.is_a?(Fixnum)
81
77
  @datetime
82
78
  elsif @datetime.is_a?(Hash)
83
79
  @datetime[method.to_sym]
@@ -87,13 +83,10 @@ if defined?(Rails) && defined?(ActionView)
87
83
  end
88
84
  end
89
85
  end
90
-
91
-
92
-
93
86
  end
94
87
 
95
88
  class FormBuilder
96
- def enhanced_date_select method, options = {}, html_options = {}
89
+ def enhanced_date_select(method, options = {}, html_options = {})
97
90
  @template.enhanced_date_select(@object_name, method, objectify_options(options), html_options)
98
91
  end
99
92
  end
@@ -1,65 +1,85 @@
1
- require "spec_helper"
1
+ require 'spec_helper'
2
2
 
3
- describe "Enhanced DateSelect" do
3
+ describe 'Enhanced DateSelect' do
4
4
  include ActionView::Helpers::FormOptionsHelper
5
- let(:student) {Object.new}
6
- let(:deprecated_form_builder){ ActionView::Helpers::FormBuilder.new(:birthday, student, self, {}, nil)}
7
- let(:rails41_form_builder){ ActionView::Helpers::FormBuilder.new(:birthday, student, self, {})}
8
-
9
- let(:instance_tag) { ActionView::Helpers::InstanceTag.new(student.class, 'birthday', self, student )}
10
- let(:rails4_instance_tag) {ActionView::Helpers::Tags::Base.new(student.class, 'birthday', self, student ) }
11
- let(:datetime){{:year => 2001, :month => 2, :day => 3}}
12
- let(:html_options){{}}
13
- let(:options) {{ :discard_day =>true,
14
- :value => {:year => 2001, :month => 2, :day => 3},
15
- :order => [:day, :month, :year],
16
- :start_year => 2013,
17
- :end_year => 1940 }}
18
- let(:expected_result) {"<input id=\"birthday_birthday_3i\" name=\"birthday[birthday(3i)]\" type=\"hidden\" value=\"1\" />\n<select id=\"birthday_birthday_2i\" name=\"birthday[birthday(2i)]\">\n<option value=\"1\">January</option>\n<option selected=\"selected\" value=\"2\">February</option>\n<option value=\"3\">March</option>\n<option value=\"4\">April</option>\n<option value=\"5\">May</option>\n<option value=\"6\">June</option>\n<option value=\"7\">July</option>\n<option value=\"8\">August</option>\n<option value=\"9\">September</option>\n<option value=\"10\">October</option>\n<option value=\"11\">November</option>\n<option value=\"12\">December</option>\n</select>\n<select id=\"birthday_birthday_1i\" name=\"birthday[birthday(1i)]\">\n<option value=\"2012\">2012</option>\n<option value=\"2011\">2011</option>\n<option value=\"2010\">2010</option>\n<option value=\"2009\">2009</option>\n<option value=\"2008\">2008</option>\n<option value=\"2007\">2007</option>\n<option value=\"2006\">2006</option>\n<option value=\"2005\">2005</option>\n<option value=\"2004\">2004</option>\n<option value=\"2003\">2003</option>\n<option value=\"2002\">2002</option>\n<option selected=\"selected\" value=\"2001\">2001</option>\n<option value=\"2000\">2000</option>\n<option value=\"1999\">1999</option>\n<option value=\"1998\">1998</option>\n<option value=\"1997\">1997</option>\n<option value=\"1996\">1996</option>\n<option value=\"1995\">1995</option>\n<option value=\"1994\">1994</option>\n<option value=\"1993\">1993</option>\n<option value=\"1992\">1992</option>\n<option value=\"1991\">1991</option>\n<option value=\"1990\">1990</option>\n<option value=\"1989\">1989</option>\n<option value=\"1988\">1988</option>\n<option value=\"1987\">1987</option>\n<option value=\"1986\">1986</option>\n<option value=\"1985\">1985</option>\n<option value=\"1984\">1984</option>\n<option value=\"1983\">1983</option>\n<option value=\"1982\">1982</option>\n<option value=\"1981\">1981</option>\n<option value=\"1980\">1980</option>\n<option value=\"1979\">1979</option>\n<option value=\"1978\">1978</option>\n<option value=\"1977\">1977</option>\n<option value=\"1976\">1976</option>\n<option value=\"1975\">1975</option>\n<option value=\"1974\">1974</option>\n<option value=\"1973\">1973</option>\n<option value=\"1972\">1972</option>\n<option value=\"1971\">1971</option>\n<option value=\"1970\">1970</option>\n<option value=\"1969\">1969</option>\n<option value=\"1968\">1968</option>\n<option value=\"1967\">1967</option>\n<option value=\"1966\">1966</option>\n<option value=\"1965\">1965</option>\n<option value=\"1964\">1964</option>\n<option value=\"1963\">1963</option>\n<option value=\"1962\">1962</option>\n<option value=\"1961\">1961</option>\n<option value=\"1960\">1960</option>\n<option value=\"1959\">1959</option>\n<option value=\"1958\">1958</option>\n<option value=\"1957\">1957</option>\n<option value=\"1956\">1956</option>\n<option value=\"1955\">1955</option>\n<option value=\"1954\">1954</option>\n<option value=\"1953\">1953</option>\n<option value=\"1952\">1952</option>\n<option value=\"1951\">1951</option>\n<option value=\"1950\">1950</option>\n<option value=\"1949\">1949</option>\n<option value=\"1948\">1948</option>\n<option value=\"1947\">1947</option>\n<option value=\"1946\">1946</option>\n<option value=\"1945\">1945</option>\n<option value=\"1944\">1944</option>\n<option value=\"1943\">1943</option>\n<option value=\"1942\">1942</option>\n<option value=\"1941\">1941</option>\n<option value=\"1940\">1940</option>\n</select>\n"}
5
+ include ActionView::Helpers::DateHelper
6
+ include ActionView::Helpers::FormHelper
7
+ let(:student) { Object.new }
8
+ let(:deprecated_form_builder) { ActionView::Helpers::FormBuilder.new(:birthday, student, self, {}, nil) }
9
+ let(:rails41_form_builder) { ActionView::Helpers::FormBuilder.new(:birthday, student, self, {}) }
10
+ let(:tag_name) { 'birthday' }
11
+ let(:instance_tag) { ActionView::Helpers::InstanceTag.new(student.class, tag_name, self, student) }
12
+ let(:rails4_instance_tag) { ActionView::Helpers::Tags::Base.new(student.class, tag_name, self, student) }
13
+ let(:datetime) { { year: 2001, month: 2, day: 3 } }
14
+ let(:html_options) { {} }
15
+ let(:options) do
16
+ { discard_day: true,
17
+ value: { year: 2001, month: 2, day: 3 },
18
+ order: %w(day month year).map(&:to_sym),
19
+ start_year: 2013,
20
+ end_year: 1940 }
21
+ end
22
+ let(:expected_result) do
23
+ "#{hidden_field(tag_name.to_sym, "#{tag_name}(3i)", value: 1)}
24
+ #{select_month(options[:value][:month],
25
+ field_name: "#{tag_name}(2i)",
26
+ prefix: tag_name)}
27
+ #{select_year(options[:value][:year],
28
+ start_year: options['start_year'],
29
+ end_year: options['end_year'],
30
+ field_name: "#{tag_name}(1i)",
31
+ prefix: tag_name)}"
32
+ end
19
33
  before(:each) do
20
34
  student.stub(:delete).and_return(student)
21
- if ( Rails::VERSION::MAJOR.to_i <= 3 )
22
- @instance_tag = instance_tag
35
+ if (Rails::VERSION::MAJOR.to_i <= 3)
36
+ @instance_tag = instance_tag
23
37
  else
24
38
  @instance_tag = rails4_instance_tag
25
39
  end
26
- if ( Rails::VERSION::MAJOR.to_i >= 4 && Rails::VERSION::MINOR >= 1 )
27
- @form_builder = rails41_form_builder
40
+ if Rails::VERSION::MAJOR.to_i >= 4 && Rails::VERSION::MINOR >= 1
41
+ @form_builder = rails41_form_builder
28
42
  else
29
43
  @form_builder = deprecated_form_builder
30
44
  end
31
-
45
+
32
46
  @enhanced_datetime_selector = ActionView::Helpers::EnhancedDateTimeSelector.new(datetime, options, {})
33
47
  end
34
48
 
35
-
36
- describe ".enhanced_date_select" do
37
- it "constructs 3 selectboxes" do
38
- @form_builder.enhanced_date_select(:birthday,{ :prompt => {
39
- :day => "please select one",
40
- :month => "please select one",
41
- :year => "please select one" },
42
- :value => {:year => 2001, :month => 2, :day => 3},
43
- :order => [:day, :month, :year],
44
- :start_year => 2013,
45
- :end_year => 1940 } ).should == "<select id=\"birthday_birthday_3i\" name=\"birthday[birthday(3i)]\">\n<option value=\"\">please select one</option>\n<option value=\"1\">1</option>\n<option value=\"2\">2</option>\n<option selected=\"selected\" value=\"3\">3</option>\n<option value=\"4\">4</option>\n<option value=\"5\">5</option>\n<option value=\"6\">6</option>\n<option value=\"7\">7</option>\n<option value=\"8\">8</option>\n<option value=\"9\">9</option>\n<option value=\"10\">10</option>\n<option value=\"11\">11</option>\n<option value=\"12\">12</option>\n<option value=\"13\">13</option>\n<option value=\"14\">14</option>\n<option value=\"15\">15</option>\n<option value=\"16\">16</option>\n<option value=\"17\">17</option>\n<option value=\"18\">18</option>\n<option value=\"19\">19</option>\n<option value=\"20\">20</option>\n<option value=\"21\">21</option>\n<option value=\"22\">22</option>\n<option value=\"23\">23</option>\n<option value=\"24\">24</option>\n<option value=\"25\">25</option>\n<option value=\"26\">26</option>\n<option value=\"27\">27</option>\n<option value=\"28\">28</option>\n<option value=\"29\">29</option>\n<option value=\"30\">30</option>\n<option value=\"31\">31</option>\n</select>\n<select id=\"birthday_birthday_2i\" name=\"birthday[birthday(2i)]\">\n<option value=\"\">please select one</option>\n<option value=\"1\">January</option>\n<option selected=\"selected\" value=\"2\">February</option>\n<option value=\"3\">March</option>\n<option value=\"4\">April</option>\n<option value=\"5\">May</option>\n<option value=\"6\">June</option>\n<option value=\"7\">July</option>\n<option value=\"8\">August</option>\n<option value=\"9\">September</option>\n<option value=\"10\">October</option>\n<option value=\"11\">November</option>\n<option value=\"12\">December</option>\n</select>\n<select id=\"birthday_birthday_1i\" name=\"birthday[birthday(1i)]\">\n<option value=\"\">please select one</option>\n<option value=\"2013\">2013</option>\n<option value=\"2012\">2012</option>\n<option value=\"2011\">2011</option>\n<option value=\"2010\">2010</option>\n<option value=\"2009\">2009</option>\n<option value=\"2008\">2008</option>\n<option value=\"2007\">2007</option>\n<option value=\"2006\">2006</option>\n<option value=\"2005\">2005</option>\n<option value=\"2004\">2004</option>\n<option value=\"2003\">2003</option>\n<option value=\"2002\">2002</option>\n<option selected=\"selected\" value=\"2001\">2001</option>\n<option value=\"2000\">2000</option>\n<option value=\"1999\">1999</option>\n<option value=\"1998\">1998</option>\n<option value=\"1997\">1997</option>\n<option value=\"1996\">1996</option>\n<option value=\"1995\">1995</option>\n<option value=\"1994\">1994</option>\n<option value=\"1993\">1993</option>\n<option value=\"1992\">1992</option>\n<option value=\"1991\">1991</option>\n<option value=\"1990\">1990</option>\n<option value=\"1989\">1989</option>\n<option value=\"1988\">1988</option>\n<option value=\"1987\">1987</option>\n<option value=\"1986\">1986</option>\n<option value=\"1985\">1985</option>\n<option value=\"1984\">1984</option>\n<option value=\"1983\">1983</option>\n<option value=\"1982\">1982</option>\n<option value=\"1981\">1981</option>\n<option value=\"1980\">1980</option>\n<option value=\"1979\">1979</option>\n<option value=\"1978\">1978</option>\n<option value=\"1977\">1977</option>\n<option value=\"1976\">1976</option>\n<option value=\"1975\">1975</option>\n<option value=\"1974\">1974</option>\n<option value=\"1973\">1973</option>\n<option value=\"1972\">1972</option>\n<option value=\"1971\">1971</option>\n<option value=\"1970\">1970</option>\n<option value=\"1969\">1969</option>\n<option value=\"1968\">1968</option>\n<option value=\"1967\">1967</option>\n<option value=\"1966\">1966</option>\n<option value=\"1965\">1965</option>\n<option value=\"1964\">1964</option>\n<option value=\"1963\">1963</option>\n<option value=\"1962\">1962</option>\n<option value=\"1961\">1961</option>\n<option value=\"1960\">1960</option>\n<option value=\"1959\">1959</option>\n<option value=\"1958\">1958</option>\n<option value=\"1957\">1957</option>\n<option value=\"1956\">1956</option>\n<option value=\"1955\">1955</option>\n<option value=\"1954\">1954</option>\n<option value=\"1953\">1953</option>\n<option value=\"1952\">1952</option>\n<option value=\"1951\">1951</option>\n<option value=\"1950\">1950</option>\n<option value=\"1949\">1949</option>\n<option value=\"1948\">1948</option>\n<option value=\"1947\">1947</option>\n<option value=\"1946\">1946</option>\n<option value=\"1945\">1945</option>\n<option value=\"1944\">1944</option>\n<option value=\"1943\">1943</option>\n<option value=\"1942\">1942</option>\n<option value=\"1941\">1941</option>\n<option value=\"1940\">1940</option>\n</select>\n"
49
+ describe '.enhanced_date_select' do
50
+ it 'constructs 3 selectboxes' do
51
+ custom = { prompt: {
52
+ day: 'please select one',
53
+ month: 'please select one',
54
+ year: 'please select one' } }
55
+ @form_builder.enhanced_date_select(:birthday, options.merge(custom)).should ==
56
+ "#{hidden_field(tag_name.to_sym, "#{tag_name}_3i", value: 1, name: "#{tag_name}[#{tag_name}(3i)]")}
57
+ #{select_month(options[:value][:month],
58
+ field_name: "#{tag_name}(2i)",
59
+ prefix: tag_name,
60
+ prompt: custom[:prompt][:month])}#{select_year(options[:value][:year],
61
+ start_year: options[:start_year],
62
+ end_year: options[:end_year],
63
+ field_name: "#{tag_name}(1i)",
64
+ prefix: tag_name,
65
+ prompt: custom[:prompt][:year])}"
46
66
  end
47
67
 
48
- it "construct withoud the day dropdown" do
49
- @form_builder.enhanced_date_select(:birthday,{ :discard_day =>true,
50
- :value => {:year => 2001, :month => 2, :day => 3},
51
- :order => [:day, :month, :year],
52
- :start_year => 2013,
53
- :end_year => 1940 } ).should =="<input id=\"birthday_birthday_3i\" name=\"birthday[birthday(3i)]\" type=\"hidden\" value=\"1\" />\n<select id=\"birthday_birthday_2i\" name=\"birthday[birthday(2i)]\">\n<option value=\"1\">January</option>\n<option selected=\"selected\" value=\"2\">February</option>\n<option value=\"3\">March</option>\n<option value=\"4\">April</option>\n<option value=\"5\">May</option>\n<option value=\"6\">June</option>\n<option value=\"7\">July</option>\n<option value=\"8\">August</option>\n<option value=\"9\">September</option>\n<option value=\"10\">October</option>\n<option value=\"11\">November</option>\n<option value=\"12\">December</option>\n</select>\n<select id=\"birthday_birthday_1i\" name=\"birthday[birthday(1i)]\">\n<option value=\"2013\">2013</option>\n<option value=\"2012\">2012</option>\n<option value=\"2011\">2011</option>\n<option value=\"2010\">2010</option>\n<option value=\"2009\">2009</option>\n<option value=\"2008\">2008</option>\n<option value=\"2007\">2007</option>\n<option value=\"2006\">2006</option>\n<option value=\"2005\">2005</option>\n<option value=\"2004\">2004</option>\n<option value=\"2003\">2003</option>\n<option value=\"2002\">2002</option>\n<option selected=\"selected\" value=\"2001\">2001</option>\n<option value=\"2000\">2000</option>\n<option value=\"1999\">1999</option>\n<option value=\"1998\">1998</option>\n<option value=\"1997\">1997</option>\n<option value=\"1996\">1996</option>\n<option value=\"1995\">1995</option>\n<option value=\"1994\">1994</option>\n<option value=\"1993\">1993</option>\n<option value=\"1992\">1992</option>\n<option value=\"1991\">1991</option>\n<option value=\"1990\">1990</option>\n<option value=\"1989\">1989</option>\n<option value=\"1988\">1988</option>\n<option value=\"1987\">1987</option>\n<option value=\"1986\">1986</option>\n<option value=\"1985\">1985</option>\n<option value=\"1984\">1984</option>\n<option value=\"1983\">1983</option>\n<option value=\"1982\">1982</option>\n<option value=\"1981\">1981</option>\n<option value=\"1980\">1980</option>\n<option value=\"1979\">1979</option>\n<option value=\"1978\">1978</option>\n<option value=\"1977\">1977</option>\n<option value=\"1976\">1976</option>\n<option value=\"1975\">1975</option>\n<option value=\"1974\">1974</option>\n<option value=\"1973\">1973</option>\n<option value=\"1972\">1972</option>\n<option value=\"1971\">1971</option>\n<option value=\"1970\">1970</option>\n<option value=\"1969\">1969</option>\n<option value=\"1968\">1968</option>\n<option value=\"1967\">1967</option>\n<option value=\"1966\">1966</option>\n<option value=\"1965\">1965</option>\n<option value=\"1964\">1964</option>\n<option value=\"1963\">1963</option>\n<option value=\"1962\">1962</option>\n<option value=\"1961\">1961</option>\n<option value=\"1960\">1960</option>\n<option value=\"1959\">1959</option>\n<option value=\"1958\">1958</option>\n<option value=\"1957\">1957</option>\n<option value=\"1956\">1956</option>\n<option value=\"1955\">1955</option>\n<option value=\"1954\">1954</option>\n<option value=\"1953\">1953</option>\n<option value=\"1952\">1952</option>\n<option value=\"1951\">1951</option>\n<option value=\"1950\">1950</option>\n<option value=\"1949\">1949</option>\n<option value=\"1948\">1948</option>\n<option value=\"1947\">1947</option>\n<option value=\"1946\">1946</option>\n<option value=\"1945\">1945</option>\n<option value=\"1944\">1944</option>\n<option value=\"1943\">1943</option>\n<option value=\"1942\">1942</option>\n<option value=\"1941\">1941</option>\n<option value=\"1940\">1940</option>\n</select>\n"
68
+ it 'construct withoud the day dropdown' do
69
+ @form_builder.enhanced_date_select(:birthday, options).should == "#{hidden_field(tag_name.to_sym, "#{tag_name}_3i", value: 1, name: "#{tag_name}[#{tag_name}(3i)]")}
70
+ #{select_month(options[:value][:month],
71
+ field_name: "#{tag_name}(2i)",
72
+ prefix: tag_name)}#{select_year(options[:value][:year],
73
+ start_year: options[:start_year],
74
+ end_year: options[:end_year],
75
+ field_name: "#{tag_name}(1i)",
76
+ prefix: tag_name)}"
54
77
  end
55
78
  end
56
79
 
57
-
58
80
  describe ActionView::Helpers::FormOptionsHelper do
59
-
60
-
61
81
  before(:each) do
62
- if ( Rails::VERSION::MAJOR.to_i <= 3 )
82
+ if (Rails::VERSION::MAJOR.to_i <= 3)
63
83
  ActionView::Helpers::InstanceTag.stub(:new).and_return(@instance_tag)
64
84
  @class = ActionView::Helpers::InstanceTag
65
85
  else
@@ -68,65 +88,54 @@ describe "Enhanced DateSelect" do
68
88
  end
69
89
  end
70
90
 
71
- it "should call the instance tag with argument" do
72
- if ( Rails::VERSION::MAJOR.to_i <= 3 )
91
+ it 'should call the instance tag with argument' do
92
+ if (Rails::VERSION::MAJOR.to_i <= 3)
73
93
  @class.should_receive(:new).with(student, 'birthday', self, options.delete(:object)).and_return(@instance_tag)
74
94
  else
75
95
  @class.should_receive(:new).with(student, 'birthday', self, options).and_return(@instance_tag)
76
96
  end
77
- enhanced_date_select(student,'birthday',options )
97
+ enhanced_date_select(student, 'birthday', options)
78
98
  end
79
- it "should call the tp date_select_tag method" do
99
+
100
+ it 'should call the tp date_select_tag method' do
80
101
  @instance_tag.should_receive(:to_enhanced_date_select_tag).with(options, {})
81
- enhanced_date_select(student,'birthday',options )
102
+ enhanced_date_select(student, 'birthday', options)
82
103
  end
83
-
84
104
  end
85
105
 
86
- if ( Rails::VERSION::MAJOR.to_i <= 3 )
106
+ if (Rails::VERSION::MAJOR.to_i <= 3)
87
107
  describe ActionView::Helpers::InstanceTag do
88
-
89
108
  before(:each) do
90
109
  @instance_tag.stub(:enhanced_datetime_selector).and_return(@enhanced_datetime_selector)
91
110
  end
92
111
 
93
-
94
- it "should call the datetimeselector" do
112
+ it 'should call the datetimeselector' do
95
113
  @instance_tag.should_receive(:enhanced_datetime_selector).with(options, html_options).and_return(@enhanced_datetime_selector)
96
114
  @instance_tag.to_enhanced_date_select_tag(options, html_options)
97
115
  end
98
116
 
99
- it "should call the datetimeselector" do
117
+ it 'should call the datetimeselector' do
100
118
  @enhanced_datetime_selector.should_receive(:enhanced_select_date).and_return(expected_result)
101
119
  @instance_tag.to_enhanced_date_select_tag(options, html_options)
102
120
  end
103
-
104
-
105
-
106
121
  end
107
122
 
108
123
  else
109
124
  describe ActionView::Helpers::Tags::Base do
110
-
111
125
  before(:each) do
112
126
  @instance_tag.stub(:enhanced_datetime_selector).and_return(@enhanced_datetime_selector)
113
127
  end
114
128
 
115
-
116
- it "should call the datetimeselector" do
129
+ it 'should call the datetimeselector' do
117
130
  @instance_tag.should_receive(:enhanced_datetime_selector).with(options, html_options).and_return(@enhanced_datetime_selector)
118
131
  @instance_tag.to_enhanced_date_select_tag(options, html_options)
119
132
  end
120
133
 
121
- it "should call the datetimeselector" do
134
+ it 'should call the datetimeselector' do
122
135
  @enhanced_datetime_selector.should_receive(:enhanced_select_date).and_return(expected_result)
123
136
  @instance_tag.to_enhanced_date_select_tag(options, html_options)
124
137
  end
125
-
126
-
127
-
128
138
  end
129
139
 
130
140
  end
131
-
132
141
  end
data/spec/spec_helper.rb CHANGED
@@ -1,11 +1,7 @@
1
-
2
1
  require 'coveralls'
3
2
  Coveralls.wear!
4
3
 
5
- require "bundler/setup"
6
- require "rails"
7
- require "action_view"
8
- require "enhanced_date_select"
9
-
10
- RSpec.configure do |config|
11
- end
4
+ require 'bundler/setup'
5
+ require 'rails'
6
+ require 'action_view'
7
+ require 'enhanced_date_select'
data/version.rb CHANGED
@@ -6,10 +6,10 @@ module EnhancedDateSelect
6
6
 
7
7
  module VERSION
8
8
  MAJOR = 1
9
- MINOR = 0
10
- TINY = 8
11
- PRE = nil
9
+ MINOR = 1
10
+ TINY = 0
11
+ PRE = nil
12
12
 
13
- STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
13
+ STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
14
14
  end
15
15
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enhanced_date_select
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.8
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - bogdanRada
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-05 00:00:00.000000000 Z
11
+ date: 2015-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec-rails
@@ -230,6 +230,48 @@ dependencies:
230
230
  - - '>='
231
231
  - !ruby/object:Gem::Version
232
232
  version: 2.14.0
233
+ - !ruby/object:Gem::Dependency
234
+ name: rubocop
235
+ requirement: !ruby/object:Gem::Requirement
236
+ requirements:
237
+ - - '='
238
+ - !ruby/object:Gem::Version
239
+ version: '0.29'
240
+ type: :development
241
+ prerelease: false
242
+ version_requirements: !ruby/object:Gem::Requirement
243
+ requirements:
244
+ - - '='
245
+ - !ruby/object:Gem::Version
246
+ version: '0.29'
247
+ - !ruby/object:Gem::Dependency
248
+ name: phare
249
+ requirement: !ruby/object:Gem::Requirement
250
+ requirements:
251
+ - - '>='
252
+ - !ruby/object:Gem::Version
253
+ version: '0'
254
+ type: :development
255
+ prerelease: false
256
+ version_requirements: !ruby/object:Gem::Requirement
257
+ requirements:
258
+ - - '>='
259
+ - !ruby/object:Gem::Version
260
+ version: '0'
261
+ - !ruby/object:Gem::Dependency
262
+ name: scss-lint
263
+ requirement: !ruby/object:Gem::Requirement
264
+ requirements:
265
+ - - '>='
266
+ - !ruby/object:Gem::Version
267
+ version: '0'
268
+ type: :development
269
+ prerelease: false
270
+ version_requirements: !ruby/object:Gem::Requirement
271
+ requirements:
272
+ - - '>='
273
+ - !ruby/object:Gem::Version
274
+ version: '0'
233
275
  description: '"Enhances ActionView with a customizable date select form helper where
234
276
  any valid HTML attribute can be applied."'
235
277
  email: raoul_ice@yahoo.com
@@ -242,6 +284,7 @@ files:
242
284
  - .coveralls.yml
243
285
  - .gitignore
244
286
  - .rspec
287
+ - .rubocop.yml
245
288
  - .travis.yml
246
289
  - Appraisals
247
290
  - Gemfile
@@ -274,7 +317,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
274
317
  version: '0'
275
318
  requirements: []
276
319
  rubyforge_project:
277
- rubygems_version: 2.4.2
320
+ rubygems_version: 2.4.6
278
321
  signing_key:
279
322
  specification_version: 4
280
323
  summary: '"enhanced date select"'