has_zone 0.0.2 → 0.0.3

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: 0a1c519eeebf58d6beadb0a8e4b486681d80cf58
4
- data.tar.gz: 1a653b1b8a287b40c85b013f7fdee4375d5fe12d
3
+ metadata.gz: cf5120495cf481f69a7452aadba6f140de7ba232
4
+ data.tar.gz: 315db39902f8de620b18cce802db1004baed2aac
5
5
  SHA512:
6
- metadata.gz: 412de64b074483785fb2495330554baf4588207aa28384062083132b7280b2c15483a7e0788a5ed3f9a7fed07ee62dc85ca32c0f67d9afab8d134330e854695a
7
- data.tar.gz: 2e44919e99ee36b6d444c76181aef15c198b3c26b2e706662d46d1c785794fbed0cd598fd41201fb14d3245ce834c4e61c49f5d73ee5275beef8df3feedb5089
6
+ metadata.gz: 0a4cd134bf939a445716498e022b1025409f9ba1938c900ad475349b23d5d24be6502bd850fec4a8a7b43ee2f9a82bab34a7d96b99db2cd5e08edcad25cde2f9
7
+ data.tar.gz: ee4e84cf72c337d77ff78c006fe8ac89469a67dbf9e1f278dd120626e8b0fd584fb882d3772d75b72c45c279da8e02c2fdd98eec784ce8ac0a3c9f24ebbef0b8
@@ -35,12 +35,15 @@ module HasZone
35
35
  write_attribute(options[:with], tz)
36
36
  end
37
37
 
38
- define_method(:set_utc_time_zone) do
39
- send "#{options[:with]}=".to_sym, "Etc/UTC" if send(options[:with]) == "UTC"
38
+ define_method(:alias_time_zone) do
39
+ if send(options[:with]) == "UTC"
40
+ send "#{options[:with]}=".to_sym, "Etc/UTC"
41
+ elsif ::ActiveSupport::TimeZone.tzids_map.keys.exclude? send(options[:with])
42
+ Rails.logger.warn("Time zone #{send(options[:with])} is not a valid time zone.") if defined? Rails
43
+ end
40
44
  end
41
45
 
42
- before_validation :set_utc_time_zone
43
- validates_inclusion_of options[:with], in: ::ActiveSupport::TimeZone.tzids_map.keys, allow_blank: true
46
+ before_validation :alias_time_zone
44
47
 
45
48
  end
46
49
  end
@@ -1,3 +1,3 @@
1
1
  module HasZone
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -51,4 +51,10 @@ describe HasZone do
51
51
  resource.time_zone.should == "Etc/UTC"
52
52
  end
53
53
 
54
+ it "sets time zone to nil if the time zone is not recognized" do
55
+ resource.time_zone = "Bogus"
56
+ resource.should be_valid
57
+ resource.zone.should be_nil
58
+ end
59
+
54
60
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: has_zone
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jerry Luk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-16 00:00:00.000000000 Z
11
+ date: 2013-08-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport