mournful_settings 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -16,7 +16,12 @@ ActiveAdmin.register Setting do
16
16
  f.input :name
17
17
  f.input :description
18
18
  f.input :value, :input_html => {:value => setting.value}
19
- f.input :encrypted
19
+ f.input(
20
+ :encrypted,
21
+ :input_html => {
22
+ :checked => (setting.encrypted == false ? false : true)
23
+ }
24
+ )
20
25
  end
21
26
  f.buttons
22
27
  end
@@ -7,6 +7,7 @@ module MournfulSettings
7
7
 
8
8
  VALUE_TYPES = ['text', 'number', 'decimal']
9
9
 
10
+ before_save :set_encrypted_true_unless_false
10
11
  before_save :encrypt_value
11
12
 
12
13
  validates :value_type, :presence => true, :inclusion => {:in => VALUE_TYPES}
@@ -66,6 +67,10 @@ module MournfulSettings
66
67
  def non_white_space_with_equal_sign_packing
67
68
  /\S+=*/
68
69
  end
70
+
71
+ def set_encrypted_true_unless_false
72
+ self.encrypted = true unless self.encrypted == false
73
+ end
69
74
 
70
75
 
71
76
  def encrypt_value
@@ -1,10 +1,16 @@
1
1
  module MournfulSettings
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
4
4
 
5
5
  # History
6
6
  # =======
7
7
  #
8
+ # 0.0.3: Encrypted by default
9
+ # ---------------------------
10
+ # Modifies model and active admin registration file to make encrypting settings
11
+ # the default behaviour.
12
+ #
13
+ #
8
14
  # 0.0.2: Add active admin option
9
15
  # ------------------------------
10
16
  # Adds active admin integration options.
Binary file
@@ -44,7 +44,7 @@ class SettingTest < Test::Unit::TestCase
44
44
  'number' => 1.33333333,
45
45
  'decimal' => 1.44
46
46
  }.each do |value_type, value|
47
- setting = Setting.create(:name => value_type, :value => value, :value_type => value_type, :encrypted => true)
47
+ setting = Setting.create(:name => value_type, :value => value, :value_type => value_type)
48
48
  assert_equal(value, setting.value)
49
49
  assert_not_equal(database_value_for(setting), setting.value)
50
50
  assert_not_equal(database_value_for(setting).to_s, setting.value.to_s)
@@ -94,19 +94,19 @@ class SettingTest < Test::Unit::TestCase
94
94
 
95
95
  private
96
96
  def text_setting
97
- @text_setting ||= Setting.create(:name => 'text_setting', :value => 'foo', :value_type => 'text')
97
+ @text_setting ||= Setting.create(:name => 'text_setting', :value => 'foo', :value_type => 'text', :encrypted => false)
98
98
  end
99
99
 
100
100
  def number_setting
101
- @number_setting ||= Setting.create(:name => 'number_setting', :value => '1.33333333333333', :value_type => 'number')
101
+ @number_setting ||= Setting.create(:name => 'number_setting', :value => '1.33333333333333', :value_type => 'number', :encrypted => false)
102
102
  end
103
103
 
104
104
  def decimal_setting
105
- @decimal_setting ||= Setting.create(:name => 'decimal_setting', :value => '4.55', :value_type => 'decimal')
105
+ @decimal_setting ||= Setting.create(:name => 'decimal_setting', :value => '4.55', :value_type => 'decimal', :encrypted => false)
106
106
  end
107
107
 
108
108
  def encrypted_setting
109
- @encrypted_setting ||= Setting.create(:name => 'encrypted_setting', :value => @value, :value_type => 'text', :encrypted => true)
109
+ @encrypted_setting ||= Setting.create(:name => 'encrypted_setting', :value => @value, :value_type => 'text')
110
110
  end
111
111
 
112
112
  def database_value_for(setting)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mournful_settings
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: