populate-me 0.5.0 → 0.5.1

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: 7ff6598db649ef34bc8d9d944eba83353d4efd8c
4
- data.tar.gz: 6a6811373d3f8e17bad20d968888ca628d4561e3
3
+ metadata.gz: 92c2089ed9f39395bbb2082d2509b611dc3edf06
4
+ data.tar.gz: 4df7f1e80399815320841200ce6ed3a34d51f70f
5
5
  SHA512:
6
- metadata.gz: 04e3e69f706b562e5e5d193a279851d7fa6836b45eb5f80da2dc3c560011d02f37eece21dedba802f4cb1be3c7dcf62f8e2092d2824be61a26767bbe24929eb3
7
- data.tar.gz: 5365b1d443fbaadd2b3b44caf932a187546dc174f858c9a53bcae53ff200c7cda44445aca8913a8d8620ca0c12fa6ddcdc8bea029d01db55f792ab254a5bd74c
6
+ metadata.gz: f1ff869f7c0a4dc0f36d0c0ebdff12e670563ff60237fcd620ffff2fd3dcba551faf0f2cd1113cfd287160631f4d8475463cd5d0cd087a1cc5727de88d4821e7
7
+ data.tar.gz: 3bad55309476e3fcb50024dd602738d011e54a8514898f2b22f75004ce8e7807cd9326dc813ac41fc6fb510e9fea4549cb355661696c0a945354a006a3bea953
data/example/config.ru CHANGED
@@ -61,6 +61,7 @@ class Article < PopulateMe::Document
61
61
  field :content, type: :text
62
62
  field :yes_or_no, type: :select, select_options: [:yes,:no]
63
63
  field :tags, type: :select, multiple: true, select_options: ['art','sport','science']
64
+ field :price, type: :price
64
65
  position_field
65
66
 
66
67
  after :save do
@@ -69,6 +69,14 @@ module PopulateMe
69
69
  item
70
70
  end
71
71
 
72
+ def outcast_price field, item, o={}
73
+ item = item.dup
74
+ if item[:input_value].is_a?(Integer)
75
+ item[:input_value] = WebUtils.display_price item[:input_value]
76
+ end
77
+ item
78
+ end
79
+
72
80
  end
73
81
  end
74
82
  end
@@ -1,4 +1,4 @@
1
1
  module PopulateMe
2
- VERSION = '0.5.0'
2
+ VERSION = '0.5.1'
3
3
  end
4
4
 
@@ -16,6 +16,7 @@ class Outcasted < PopulateMe::Document
16
16
  field :pdf, type: :attachment
17
17
  field :authors, type: :list
18
18
  field :weirdo, type: :strange
19
+ field :price, type: :price
19
20
 
20
21
  def get_size_options
21
22
  [
@@ -192,6 +193,25 @@ describe PopulateMe::Document, 'Outcasting' do
192
193
 
193
194
  end
194
195
 
196
+ describe '#outcast_price' do
197
+
198
+ it 'Displays the price in dollars/pounds' do
199
+ original = Outcasted.fields[:price]
200
+ outcasted = Outcasted.new price: 2999
201
+ output = outcasted.outcast(:price, original, {input_name_prefix: 'data'})
202
+ assert_equal '29.99', output[:input_value]
203
+ end
204
+
205
+ it 'Leaves the field alone when value not an integer' do
206
+ original = Outcasted.fields[:price]
207
+ outcasted = Outcasted.new
208
+ output = outcasted.outcast(:price, original, {input_name_prefix: 'data'})
209
+ assert_nil outcasted.price
210
+ assert_nil output[:input_value]
211
+ end
212
+
213
+ end
214
+
195
215
  describe '#outcast_attachment' do
196
216
 
197
217
  it 'Sets url' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: populate-me
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mickael Riga
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-27 00:00:00.000000000 Z
11
+ date: 2018-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: web-utils