stark_parameters 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module StarkParameters
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -28,7 +28,7 @@ module StarkParameters
28
28
  self.class.permitted_params.each_with_object({}) do |permitted_param, hash|
29
29
  param_key = permitted_param.is_a?(Hash) ? permitted_param.keys.first : permitted_param
30
30
  permitted_value = @params.permit(permitted_param).values.first
31
- hash[(self.class.aliases[param_key] || param_key).to_s] = permitted_value if permitted_value
31
+ hash[(self.class.aliases[param_key] || param_key).to_s] = permitted_value unless permitted_value.nil?
32
32
  end
33
33
  end
34
34
 
@@ -10,6 +10,7 @@ describe StarkParameters do
10
10
  require :email, as: :login
11
11
  permit author: [:id, :name]
12
12
  permit :password, as: :pword
13
+ permit :awesome
13
14
  require [:last_name, :surname]
14
15
  end
15
16
  end
@@ -80,6 +81,13 @@ describe StarkParameters do
80
81
  it { expect(validator.params.to_hash.keys).to_not include("author") }
81
82
  end
82
83
 
84
+ context "when permitted param is false" do
85
+ let(:params) { full_params.merge("awesome" => false) }
86
+
87
+ it { expect{ validator.params }.to_not raise_error }
88
+ it { expect(validator.params.to_hash.keys).to include("awesome") }
89
+ end
90
+
83
91
  context "with multiple params" do
84
92
  let(:validator) { test_klass.new(full_params.except("name"), {"name" => "Ryan"}) }
85
93
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stark_parameters
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-03-17 00:00:00.000000000 Z
12
+ date: 2014-03-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: actionpack