config_manager 0.0.8 → 0.0.9

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.
@@ -0,0 +1 @@
1
+ 26551
@@ -4,6 +4,60 @@ module ConfigManager
4
4
  describe Setting, :redis => true do
5
5
  let(:name) { "mysetting" }
6
6
 
7
+ describe ".create" do
8
+ subject { Setting.create(:id => id, :value => value, :tags => tags) }
9
+ let(:id) { 'id' }
10
+ let(:value) { 'value' }
11
+ let(:tags) { "soccer, football, futbol" }
12
+
13
+ context" when everything is good" do
14
+ it "returns the created setting" do
15
+ subject.id.should == id
16
+ subject.value.should == value
17
+ subject.tags.should include(*tags.split(', '))
18
+ end
19
+ end
20
+
21
+ context "when id is missing" do
22
+ let(:id) { nil }
23
+
24
+ it "returns an invalid setting" do
25
+ subject.should_not be_valid
26
+ end
27
+
28
+ it "doesn't persist the setting" do
29
+ expect(Setting).to receive(:persist).never
30
+ subject
31
+ end
32
+ end
33
+
34
+ context "when id is blank" do
35
+ let(:id) { "" }
36
+
37
+ it "returns an invalid setting" do
38
+ subject.should_not be_valid
39
+ end
40
+
41
+ it "doesn't persist the setting" do
42
+ expect(Setting).to receive(:persist).never
43
+ subject
44
+ end
45
+ end
46
+
47
+ context "when value is missing" do
48
+ let(:value) { nil }
49
+
50
+ it "returns an invalid setting" do
51
+ subject.should_not be_valid
52
+ end
53
+
54
+ it "doesn't persist the setting" do
55
+ expect(Setting).to receive(:persist).never
56
+ subject
57
+ end
58
+ end
59
+ end
60
+
7
61
  describe ".persist" do
8
62
  let(:key) { Setting.send(:generate_key, name) }
9
63
  let(:global) { Setting.send(:global_key) }
@@ -73,7 +127,7 @@ module ConfigManager
73
127
  subject.value.should == "I am serialized"
74
128
  end
75
129
 
76
- context "when tags are not explicitely request" do
130
+ context "when tags are not explicitely requested" do
77
131
  it "has no tags" do
78
132
  subject.tags.should be_empty
79
133
  end
@@ -92,6 +146,89 @@ module ConfigManager
92
146
  end
93
147
  end
94
148
 
149
+ describe ".value" do
150
+ context "when setting for id doesn't exist" do
151
+ it "returns nil" do
152
+ Setting.value(name).should be_nil
153
+ end
154
+ end
155
+
156
+ context "when setting for id exists" do
157
+ before { Setting.persist("a", "A", "vowels") }
158
+
159
+ it "returns its value" do
160
+ Setting.value("a").should == "A"
161
+ end
162
+ end
163
+ end
164
+
165
+ describe ".all" do
166
+ let(:settings) { Setting.all }
167
+
168
+ context "when there are no settings defined" do
169
+ it "returns an empty array" do
170
+ settings.should be_empty
171
+ end
172
+ end
173
+
174
+ context "when there are several settings defined" do
175
+ before do
176
+ Setting.persist("a", "A", "vowels")
177
+ Setting.persist("b", "B", "consonants")
178
+ Setting.persist("c", "C", "consonants")
179
+ end
180
+
181
+ it "returns an array of all setting instances" do
182
+ settings.should have(3).items
183
+ settings.each do |setting|
184
+ setting.should be_instance_of(Setting)
185
+ end
186
+ end
187
+
188
+ describe "returned settings array" do
189
+ it "contains the settings with correct ids, values and tags" do
190
+ settings.sort_by(&:id).map(&:id).should == ['a', 'b', 'c']
191
+ settings.sort_by(&:id).map(&:value).should == ['A', 'B', 'C']
192
+ settings.sort_by(&:id).map(&:tags).
193
+ should == [["vowels"], ["consonants"], ["consonants"]]
194
+ end
195
+ end
196
+
197
+ context "one of the settings has been deleted" do
198
+ before { Setting.delete("b") }
199
+
200
+ it "returns an array of remaining instances" do
201
+ settings.should have(2).items
202
+ end
203
+
204
+ it "returns an array with correct ids, values and tags" do
205
+ settings.sort_by(&:id).map(&:id).should == ['a', 'c']
206
+ settings.sort_by(&:id).map(&:value).should == ['A', 'C']
207
+ settings.sort_by(&:id).map(&:tags).
208
+ should == [['vowels'], ['consonants']]
209
+ end
210
+
211
+ it "deletes the key from the global index" do
212
+ settings
213
+ $redis.smembers(Setting.send(:global_key)).
214
+ should_not include(Setting.send(:generate_key, 'b'))
215
+ end
216
+ end
217
+ end
218
+ end
219
+
220
+ describe ".tags" do
221
+ before do
222
+ Setting.persist("a", "A", "vowels")
223
+ Setting.persist("b", "B", "consonants")
224
+ Setting.persist("c", "C", "consonants")
225
+ end
226
+
227
+ it "returns all created tags" do
228
+ Setting.tags.should include('vowels', 'consonants')
229
+ end
230
+ end
231
+
95
232
  describe ".delete" do
96
233
  before do
97
234
  Setting.persist(name, "I am serialized", "xyz")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: config_manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pablo Calderon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-06 00:00:00.000000000 Z
11
+ date: 2014-08-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -257,6 +257,7 @@ files:
257
257
  - app/controllers/config_manager/admins_controller.rb
258
258
  - app/controllers/config_manager/application_controller.rb
259
259
  - app/controllers/config_manager/sessions_controller.rb
260
+ - app/controllers/config_manager/settings_controller.rb
260
261
  - app/controllers/config_manager/toggles_controller.rb
261
262
  - app/helpers/config_manager/application_helper.rb
262
263
  - app/helpers/config_manager/toggles_helper.rb
@@ -267,6 +268,8 @@ files:
267
268
  - app/views/config_manager/admins/index.html.slim
268
269
  - app/views/config_manager/admins/new.html.slim
269
270
  - app/views/config_manager/sessions/new.html.slim
271
+ - app/views/config_manager/settings/_form.html.slim
272
+ - app/views/config_manager/settings/index.html.slim
270
273
  - app/views/config_manager/toggles/_form.html.slim
271
274
  - app/views/config_manager/toggles/index.html.slim
272
275
  - app/views/layouts/config_manager/application.html.slim
@@ -354,6 +357,7 @@ files:
354
357
  - spec/dummy/tmp/cache/assets/development/sprockets/f318cd7091c78a646f7e5bed19e774bf
355
358
  - spec/dummy/tmp/cache/assets/development/sprockets/f33a897212fccae3670eab346f4e193e
356
359
  - spec/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655
360
+ - spec/dummy/tmp/pids/server.pid
357
361
  - spec/dummy/tmp/test.yml
358
362
  - spec/integration/navigation_test.rb
359
363
  - spec/lib/config_manager/setting_spec.rb
@@ -460,6 +464,7 @@ test_files:
460
464
  - spec/dummy/tmp/cache/assets/development/sprockets/f318cd7091c78a646f7e5bed19e774bf
461
465
  - spec/dummy/tmp/cache/assets/development/sprockets/f33a897212fccae3670eab346f4e193e
462
466
  - spec/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655
467
+ - spec/dummy/tmp/pids/server.pid
463
468
  - spec/dummy/tmp/test.yml
464
469
  - spec/integration/navigation_test.rb
465
470
  - spec/lib/config_manager/setting_spec.rb