simple_form-bootstrap 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +3 -2
- data/CHANGELOG.md +6 -0
- data/app/assets/javascripts/simple_form-bootstrap.js +1 -1
- data/app/assets/javascripts/simple_form-bootstrap/date_time_input.js +1 -1
- data/lib/simple_form/bootstrap/form_builders/date_time.rb +5 -2
- data/lib/simple_form/bootstrap/version.rb +1 -1
- data/spec/rails_helper.rb +4 -0
- data/spec/simple_form/bootstrap/form_builders/date_time_spec.rb +24 -16
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bdfdf05aca09c195d5c6ee957ac8e7cab9cea7b0
|
4
|
+
data.tar.gz: 97d050a70a8db896ef75331994b08bce0acce573
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3b8d5ddf01e8bac354cde128819e84525fd3147a1fac346e5d0f26abb53f9155c87f6b1d061d556ed9df630a1b95ad9c3e90e790d2eb3bea20895da7121253d
|
7
|
+
data.tar.gz: 3c16f939607cb67e2145d2d7927a324627568ff661f77664e1cf5069c61d1c2c08293b45c7483884d23058c4dde68727f117c45114e82ec72d10a0fe5f4bbacb
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -32,7 +32,7 @@
|
|
32
32
|
this.attr('type', 'text');
|
33
33
|
this.parent().css('display', '');
|
34
34
|
this.parent().next('input[type=text]').attr('type', 'hidden');
|
35
|
-
this.parent().prev('label').attr('for', this.attr('id'))
|
35
|
+
this.parent().prev('label').attr('for', this.attr('id'));
|
36
36
|
|
37
37
|
return this;
|
38
38
|
},
|
@@ -1,18 +1,21 @@
|
|
1
1
|
module SimpleForm::Bootstrap::FormBuilders::DateTime
|
2
2
|
DATE_TIME_COLUMN_TYPES = [
|
3
|
+
:datetime,
|
3
4
|
'datetime',
|
4
5
|
'timestamp',
|
5
6
|
'timestamp without time zone'
|
6
7
|
].freeze
|
7
8
|
|
8
9
|
DATE_COLUMN_TYPES = [
|
10
|
+
:date,
|
9
11
|
'date'
|
10
12
|
].freeze
|
11
13
|
|
12
14
|
def default_input_type(attribute_name, column, options, *args, &block)
|
13
15
|
if (options.is_a?(Hash) ? options[:as] : @options[:as]).nil? && !column.nil?
|
14
|
-
|
15
|
-
return :
|
16
|
+
type = column.respond_to?(:type) ? column.type : column.sql_type
|
17
|
+
return :bootstrap_date_time if DATE_TIME_COLUMN_TYPES.include?(type)
|
18
|
+
return :bootstrap_date if DATE_COLUMN_TYPES.include?(type)
|
16
19
|
end
|
17
20
|
|
18
21
|
super(attribute_name, column, options, *args, &block)
|
data/spec/rails_helper.rb
CHANGED
@@ -12,6 +12,10 @@ require 'simple_form'
|
|
12
12
|
require 'simple_form/bootstrap'
|
13
13
|
SimpleForm.setup do; end
|
14
14
|
|
15
|
+
class TestApplication < Rails::Application
|
16
|
+
secrets.secret_key_base = SecureRandom.base64(10)
|
17
|
+
end
|
18
|
+
|
15
19
|
# Requires supporting ruby files with custom matchers and macros, etc, in
|
16
20
|
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
|
17
21
|
# run as spec files by default. This means that files in spec/support that end
|
@@ -14,7 +14,11 @@ RSpec.describe 'date_time', type: :view do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def column_for_attribute(*)
|
17
|
-
|
17
|
+
if @column_sql_type.is_a?(Symbol)
|
18
|
+
Struct.new(:type).new(@column_sql_type)
|
19
|
+
else
|
20
|
+
Struct.new(:sql_type).new(@column_sql_type)
|
21
|
+
end
|
18
22
|
end
|
19
23
|
|
20
24
|
def has_attribute?(*)
|
@@ -34,35 +38,39 @@ RSpec.describe 'date_time', type: :view do
|
|
34
38
|
end
|
35
39
|
|
36
40
|
context 'when the database column is a datetime' do
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
+
['datetime', :datetime].each do |type|
|
42
|
+
let(:object) { DateTimeModel.new(type) }
|
43
|
+
it 'displays the text field' do
|
44
|
+
expect(rendered).to have_tag('div.form-group.bootstrap_date_time') do
|
45
|
+
with_tag('input.bootstrap_date_time', with: { value: object.test })
|
46
|
+
end
|
41
47
|
end
|
42
|
-
end
|
43
48
|
|
44
|
-
|
45
|
-
|
46
|
-
|
49
|
+
it 'has a hidden datepicker control' do
|
50
|
+
selector = 'div.form-group.bootstrap_date_time div.input-group'
|
51
|
+
required_style = { style: 'display: none' }
|
47
52
|
|
48
|
-
|
49
|
-
|
53
|
+
expect(rendered).to have_tag(selector, with: required_style) do
|
54
|
+
with_tag('input.bootstrap_date_time', with: { type: 'hidden' })
|
55
|
+
end
|
50
56
|
end
|
51
57
|
end
|
52
58
|
end
|
53
59
|
|
54
60
|
context 'when the database column is a date' do
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
61
|
+
['date', :date].each do |type|
|
62
|
+
let(:object) { DateTimeModel.new(type) }
|
63
|
+
it 'displays the text field' do
|
64
|
+
expect(rendered).to have_tag('div.form-group.bootstrap_date') do
|
65
|
+
with_tag('input.bootstrap_date', with: { value: object.test })
|
66
|
+
end
|
59
67
|
end
|
60
68
|
end
|
61
69
|
end
|
62
70
|
|
63
71
|
context 'when the database column is not a datetime' do
|
64
72
|
let(:object) { DateTimeModel.new('string') }
|
65
|
-
it 'does not have a
|
73
|
+
it 'does not have a datepicker control' do
|
66
74
|
expect(rendered).not_to have_tag('div.form-group.bootstrap_date_time')
|
67
75
|
end
|
68
76
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_form-bootstrap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joel Low
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-09-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bootstrap-sass
|
@@ -213,7 +213,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
213
213
|
version: '0'
|
214
214
|
requirements: []
|
215
215
|
rubyforge_project:
|
216
|
-
rubygems_version: 2.
|
216
|
+
rubygems_version: 2.6.6
|
217
217
|
signing_key:
|
218
218
|
specification_version: 4
|
219
219
|
summary: Initialises Simple Form to automatically produce Bootstrap 3-friendly markup.
|