mongoid-publishing_logic 0.2.0 → 0.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0b0bc501ce174c2ec49fe7d7e36c1872ee4f5604
4
- data.tar.gz: 1b0bbd84424fe3bb9a87640832ab27a747b281ca
3
+ metadata.gz: f76f63914653f6433409ed3dea537d290a97f857
4
+ data.tar.gz: 515cd74dce846e88c621791342db2b1e3045d55b
5
5
  SHA512:
6
- metadata.gz: 5805cbc21dfec6d55f53b11cadec66f17d5bd9b85a0986798a1cc940ab9cabc947feeb25b6f64091837aa148eb44f8fbbbc6119700878ba1f314477207b65328
7
- data.tar.gz: 392003f993f1b48ec175d5a37a89ec0b473151958d0320e2c5400029937a865b62a16e9a7000ae49fdb25a9ae1e963f5f71e420fa054b5e3dd1898c3121a39aa
6
+ metadata.gz: 9147f87a05ae908bcea243d04d5e7e0eb9dfa2de597e9086d2c27b85ee403ba282925184c5458680883ddc15230cfe125f807e3d5b1cb28d7c4ce79a833025e1
7
+ data.tar.gz: daa02654c352a24fbeade5fe9393845b0c53ac8e947de6dc772ccdf0f2fcc5381723144c16603ea86d33a2674bbacd38bc2bad2441c1047849482c33da42a0de
@@ -65,5 +65,17 @@ module Mongoid
65
65
  I18n.locale = locale_was
66
66
  end
67
67
  end
68
+
69
+ def published_flag
70
+ super || false
71
+ end
72
+
73
+ def publishing_date
74
+ super || publishing_date_translations[I18n.default_locale]
75
+ end
76
+
77
+ def publishing_end_date
78
+ super || publishing_end_date_translations[I18n.default_locale]
79
+ end
68
80
  end
69
81
  end
@@ -1,5 +1,5 @@
1
1
  module Mongoid
2
2
  module PublishingLogic
3
- VERSION = "0.2.0"
3
+ VERSION = "0.2.1"
4
4
  end
5
5
  end
@@ -3,6 +3,52 @@ require_relative '../publishing_logic_spec'
3
3
 
4
4
  module Mongoid
5
5
  describe PublishingLogic::Localized do
6
+ before do
7
+ I18n.available_locales = [:de, :en]
8
+ end
9
+
6
10
  it_behaves_like('publishing logic')
11
+
12
+ let(:publishing_logic) { described_class }
13
+
14
+ let :model_class do
15
+ klass = Class.new {
16
+ include Mongoid::Document
17
+ store_in collection: 'test_models'
18
+ }
19
+ klass.send(:include, publishing_logic)
20
+ end
21
+
22
+ describe '#publishing_date' do
23
+ let(:publishing_date) { Date.today }
24
+
25
+ it 'falls back to the default locale if unset in other locale' do
26
+ I18n.locale = :en
27
+
28
+ model = model_class.create!(
29
+ published_flag: true,
30
+ publishing_date: publishing_date
31
+ )
32
+
33
+ I18n.locale = :de
34
+ expect(model.publishing_date).to eq(publishing_date)
35
+ end
36
+ end
37
+
38
+ describe '#publishing_end_date' do
39
+ let(:publishing_end_date) { Date.today }
40
+
41
+ it 'falls back to the default locale if unset in other locale' do
42
+ I18n.locale = :en
43
+
44
+ model = model_class.create!(
45
+ published_flag: true,
46
+ publishing_end_date: publishing_end_date
47
+ )
48
+
49
+ I18n.locale = :de
50
+ expect(model.publishing_end_date).to eq(publishing_end_date)
51
+ end
52
+ end
7
53
  end
8
54
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid-publishing_logic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joakim Reinert
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-01 00:00:00.000000000 Z
11
+ date: 2017-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mongoid