rails-settings-ui 0.1.1 → 0.2.0
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 +4 -4
- data/README.md +1 -0
- data/app/assets/stylesheets/rails_settings_ui/application.css.scss +1 -1
- data/app/controllers/rails_settings_ui/settings_controller.rb +3 -3
- data/app/helpers/rails_settings_ui/settings_helper.rb +8 -2
- data/app/views/rails_settings_ui/settings/index.html.haml +2 -2
- data/config/locales/en.yml +2 -1
- data/config/locales/ru.yml +2 -1
- data/lib/rails-settings-ui.rb +7 -0
- data/lib/rails-settings-ui/type_converter.rb +2 -2
- data/lib/rails-settings-ui/version.rb +1 -1
- data/spec/dummy/log/test.log +1421 -0
- data/spec/dummy/tmp/cache/702/EF0/settings%3Acompany +2 -0
- data/spec/dummy/tmp/capybara/capybara-201407142218044166461911.html +101 -0
- data/spec/features/settings_spec.rb +29 -7
- data/spec/lib/rails-settings-ui/type_converter_spec.rb +1 -1
- data/spec/lib/rails-settings-ui/value_types/base_spec.rb +3 -3
- data/spec/lib/rails-settings-ui/value_types/fixnum_spec.rb +1 -1
- data/spec/lib/rails-settings-ui/value_types/float_spec.rb +1 -1
- data/spec/lib/rails-settings-ui/value_types/hash_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -2
- metadata +14 -10
@@ -0,0 +1,101 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Rails settings</title>
|
5
|
+
<meta charset='utf-8'>
|
6
|
+
<meta content='IE=edge,chrome=1' http-equiv='X-UA-Compatible'>
|
7
|
+
<meta content='width=device-width, initial-scale=1, maximum-scale=1' name='viewport'>
|
8
|
+
<link href="/assets/application.css" media="screen" rel="stylesheet" />
|
9
|
+
|
10
|
+
</head>
|
11
|
+
<body>
|
12
|
+
<div class='navbar navbar-fixed-top'>
|
13
|
+
<div class='navbar-inner'>
|
14
|
+
<div class='container-fluid'>
|
15
|
+
<a class='brand' href='/'>Rails settings ui</a>
|
16
|
+
</div>
|
17
|
+
</div>
|
18
|
+
</div>
|
19
|
+
<div class='container-fluid'>
|
20
|
+
<div class='row-fluid'>
|
21
|
+
<div class='content'><ul class='breadcrumb'>
|
22
|
+
<li class='active'>Settings</li>
|
23
|
+
</ul>
|
24
|
+
<form accept-charset="UTF-8" action="/settings/update_all" class="form-inline" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="✓" /><input name="_method" type="hidden" value="put" /></div>
|
25
|
+
<table class='table table-striped'>
|
26
|
+
<thead>
|
27
|
+
<tr>
|
28
|
+
<th>Description</th>
|
29
|
+
<th>Value</th>
|
30
|
+
</tr>
|
31
|
+
</thead>
|
32
|
+
<tbody>
|
33
|
+
<tr>
|
34
|
+
<td>translation missing: en.settings.attributes.project_name.name</td>
|
35
|
+
<td>
|
36
|
+
<div class='control-group '>
|
37
|
+
<input id="settings_project_name" name="settings[project_name]" type="text" value="Dummy" />
|
38
|
+
</div>
|
39
|
+
</td>
|
40
|
+
</tr>
|
41
|
+
<tr>
|
42
|
+
<td>translation missing: en.settings.attributes.limit.name</td>
|
43
|
+
<td>
|
44
|
+
<div class='control-group '>
|
45
|
+
<input id="settings_limit" name="settings[limit]" type="text" value="150" />
|
46
|
+
</div>
|
47
|
+
</td>
|
48
|
+
</tr>
|
49
|
+
<tr>
|
50
|
+
<td>translation missing: en.settings.attributes.style.name</td>
|
51
|
+
<td>
|
52
|
+
<div class='control-group '>
|
53
|
+
<textarea id="settings_style" name="settings[style]" rows="10">
|
54
|
+
{"border_color"=>"e0e0e0", "block_color"=>"ffffff", "title"=>{"font"=>"Tahoma", "size"=>"12", "color"=>"107821"}}</textarea>
|
55
|
+
</div>
|
56
|
+
</td>
|
57
|
+
</tr>
|
58
|
+
<tr>
|
59
|
+
<td>translation missing: en.settings.attributes.check_something.name</td>
|
60
|
+
<td>
|
61
|
+
<div class='control-group '>
|
62
|
+
<input checked="checked" id="settings_check_something" name="settings[check_something]" type="checkbox" />
|
63
|
+
</div>
|
64
|
+
</td>
|
65
|
+
</tr>
|
66
|
+
<tr>
|
67
|
+
<td>translation missing: en.settings.attributes.description.name</td>
|
68
|
+
<td>
|
69
|
+
<div class='control-group '>
|
70
|
+
<textarea id="settings_description" name="settings[description]" rows="10">
|
71
|
+
But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful.</textarea>
|
72
|
+
</div>
|
73
|
+
</td>
|
74
|
+
</tr>
|
75
|
+
<tr>
|
76
|
+
<td>translation missing: en.settings.attributes.mode.name</td>
|
77
|
+
<td>
|
78
|
+
<div class='control-group '>
|
79
|
+
<input checked="checked" id="settings_mode_auto" name="settings[mode][auto]" style="margin: 0 10px;" type="checkbox" /><label for="settings_mode_auto" style="display: inline-block;">auto</label><input checked="checked" id="settings_mode_manual" name="settings[mode][manual]" style="margin: 0 10px;" type="checkbox" /><label for="settings_mode_manual" style="display: inline-block;">manual</label>
|
80
|
+
</div>
|
81
|
+
</td>
|
82
|
+
</tr>
|
83
|
+
<tr>
|
84
|
+
<td>translation missing: en.settings.attributes.company.name</td>
|
85
|
+
<td>
|
86
|
+
<div class='control-group '>
|
87
|
+
<p class="text-error">Default value missing</p>
|
88
|
+
</div>
|
89
|
+
</td>
|
90
|
+
</tr>
|
91
|
+
</tbody>
|
92
|
+
</table>
|
93
|
+
<input class="btn btn-info" name="commit" type="submit" value="Save all" />
|
94
|
+
</form>
|
95
|
+
|
96
|
+
</div>
|
97
|
+
</div>
|
98
|
+
<footer></footer>
|
99
|
+
</div>
|
100
|
+
</body>
|
101
|
+
</html>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe "Settings interface" do
|
3
|
+
describe "Settings interface", :type => :feature do
|
4
4
|
after do
|
5
5
|
RailsSettingsUi.settings_displayed_as_select_tag = []
|
6
6
|
RailsSettingsUi.ignored_settings = []
|
@@ -14,25 +14,25 @@ describe "Settings interface" do
|
|
14
14
|
|
15
15
|
it "long text" do
|
16
16
|
visit "/settings"
|
17
|
-
page.
|
17
|
+
expect(page).to have_selector('textarea#settings_description')
|
18
18
|
end
|
19
19
|
|
20
20
|
it "boolean" do
|
21
21
|
visit "/settings"
|
22
|
-
page.
|
22
|
+
expect(page).to have_selector('input#settings_check_something[type=checkbox]')
|
23
23
|
end
|
24
24
|
|
25
25
|
describe "array" do
|
26
26
|
it "should display as checkboxes group by default" do
|
27
27
|
visit "/settings"
|
28
|
-
page.
|
29
|
-
page.
|
28
|
+
expect(page).to have_selector('input#settings_mode_manual[type=checkbox]')
|
29
|
+
expect(page).to have_selector('input#settings_mode_auto[type=checkbox]')
|
30
30
|
end
|
31
31
|
|
32
32
|
it "should display as select if setting defined in RailsSettingsUi.settings_displayed_as_select_tag" do
|
33
33
|
RailsSettingsUi.settings_displayed_as_select_tag = [:mode]
|
34
34
|
visit "/settings"
|
35
|
-
page.
|
35
|
+
expect(page).to have_selector('select#settings_mode')
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
@@ -60,4 +60,26 @@ describe "Settings interface" do
|
|
60
60
|
expect(page).to have_content("Invalid hash")
|
61
61
|
end
|
62
62
|
end
|
63
|
-
|
63
|
+
|
64
|
+
describe "settings missing in defaults, but present in db" do
|
65
|
+
it "should show info message" do
|
66
|
+
create_settings_in_db_which_missing_in_defaults
|
67
|
+
visit "/settings"
|
68
|
+
expect_setting_row_to_have_default_missing_message("company")
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def create_settings_in_db_which_missing_in_defaults
|
73
|
+
Settings.create!(var: "company", value: "apple")
|
74
|
+
end
|
75
|
+
|
76
|
+
def setting_tr_element_for_name(setting_name)
|
77
|
+
find("tr[data-name='#{setting_name}']")
|
78
|
+
end
|
79
|
+
|
80
|
+
def expect_setting_row_to_have_default_missing_message(setting_name)
|
81
|
+
within tr = setting_tr_element_for_name(setting_name) do
|
82
|
+
expect(tr.find(".setting-value")).to have_content(I18n.t("settings.errors.default_missing"))
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -16,7 +16,7 @@ describe RailsSettingsUi::TypeConverter do
|
|
16
16
|
it "should to set false" do
|
17
17
|
Settings.defaults[:check_something] = true
|
18
18
|
settings = RailsSettingsUi::TypeConverter.cast({})
|
19
|
-
expect(settings[:check_something]).to
|
19
|
+
expect(settings[:check_something]).to be_falsey
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
@@ -5,19 +5,19 @@ describe RailsSettingsUi::ValueTypes::Base do
|
|
5
5
|
it "should not be valid" do
|
6
6
|
base_type = RailsSettingsUi::ValueTypes::Base.new("test")
|
7
7
|
base_type.errors << "Invalid"
|
8
|
-
expect(base_type.valid?).to
|
8
|
+
expect(base_type.valid?).to be_falsey
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
12
|
describe "#value_numeric?" do
|
13
13
|
it "if value is numeric should return true" do
|
14
14
|
base_type = RailsSettingsUi::ValueTypes::Base.new(349)
|
15
|
-
expect(base_type.value_numeric?).to
|
15
|
+
expect(base_type.value_numeric?).to be_truthy
|
16
16
|
end
|
17
17
|
|
18
18
|
it "if value is not numeric should return false" do
|
19
19
|
base_type = RailsSettingsUi::ValueTypes::Base.new("str")
|
20
|
-
expect(base_type.value_numeric?).to
|
20
|
+
expect(base_type.value_numeric?).to be_falsey
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
@@ -11,7 +11,7 @@ describe RailsSettingsUi::ValueTypes::Fixnum do
|
|
11
11
|
describe "if value not numeric" do
|
12
12
|
it "should be not valid" do
|
13
13
|
fixnum_type = RailsSettingsUi::ValueTypes::Fixnum.new("qwerty")
|
14
|
-
expect(fixnum_type.valid?).to
|
14
|
+
expect(fixnum_type.valid?).to be_falsey
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
@@ -11,7 +11,7 @@ describe RailsSettingsUi::ValueTypes::Float do
|
|
11
11
|
describe "if value not numeric" do
|
12
12
|
it "should be not valid" do
|
13
13
|
fixnum_type = RailsSettingsUi::ValueTypes::Float.new("qwerty")
|
14
|
-
expect(fixnum_type.valid?).to
|
14
|
+
expect(fixnum_type.valid?).to be_falsey
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
@@ -20,7 +20,7 @@ describe RailsSettingsUi::ValueTypes::Hash do
|
|
20
20
|
describe "if value not valid hash" do
|
21
21
|
it "should be not valid" do
|
22
22
|
fixnum_type = RailsSettingsUi::ValueTypes::Hash.new("{\"border_color\"=>, \"block_color\"=>\"ffffff\"")
|
23
|
-
expect(fixnum_type.valid?).to
|
23
|
+
expect(fixnum_type.valid?).to be_falsey
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -2,7 +2,6 @@ ENV['RAILS_ENV'] ||= 'test'
|
|
2
2
|
|
3
3
|
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
4
4
|
require 'rspec/rails'
|
5
|
-
require 'rspec/autorun'
|
6
5
|
require 'capybara/rails'
|
7
6
|
require 'capybara/rspec'
|
8
7
|
require 'factory_girl_rails'
|
@@ -24,4 +23,4 @@ RSpec.configure do |config|
|
|
24
23
|
Capybara.reset_sessions! # Forget the (simulated) browser state
|
25
24
|
Capybara.use_default_driver # Revert Capybara.current_driver to Capybara.default_driver
|
26
25
|
end
|
27
|
-
end
|
26
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-settings-ui
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrey Morskov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -70,14 +70,14 @@ dependencies:
|
|
70
70
|
name: bootstrap-sass
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: 3.1.1
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 3.1.1
|
83
83
|
- !ruby/object:Gem::Dependency
|
@@ -86,28 +86,28 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: 3.0.1
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
96
|
+
version: 3.0.1
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: capybara
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - "
|
101
|
+
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
103
|
+
version: 2.4.1
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - "
|
108
|
+
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
110
|
+
version: 2.4.1
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: bundler
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -207,11 +207,13 @@ files:
|
|
207
207
|
- spec/dummy/public/422.html
|
208
208
|
- spec/dummy/public/500.html
|
209
209
|
- spec/dummy/public/favicon.ico
|
210
|
+
- spec/dummy/tmp/cache/702/EF0/settings%3Acompany
|
210
211
|
- spec/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705
|
211
212
|
- spec/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953
|
212
213
|
- spec/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6
|
213
214
|
- spec/dummy/tmp/capybara/capybara-201403251000145108838835.html
|
214
215
|
- spec/dummy/tmp/capybara/capybara-201403251029034025293240.html
|
216
|
+
- spec/dummy/tmp/capybara/capybara-201407142218044166461911.html
|
215
217
|
- spec/features/settings_spec.rb
|
216
218
|
- spec/lib/rails-settings-ui/type_converter_spec.rb
|
217
219
|
- spec/lib/rails-settings-ui/value_types/array_spec.rb
|
@@ -285,11 +287,13 @@ test_files:
|
|
285
287
|
- spec/dummy/public/favicon.ico
|
286
288
|
- spec/dummy/Rakefile
|
287
289
|
- spec/dummy/README.rdoc
|
290
|
+
- spec/dummy/tmp/cache/702/EF0/settings%3Acompany
|
288
291
|
- spec/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705
|
289
292
|
- spec/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953
|
290
293
|
- spec/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6
|
291
294
|
- spec/dummy/tmp/capybara/capybara-201403251000145108838835.html
|
292
295
|
- spec/dummy/tmp/capybara/capybara-201403251029034025293240.html
|
296
|
+
- spec/dummy/tmp/capybara/capybara-201407142218044166461911.html
|
293
297
|
- spec/features/settings_spec.rb
|
294
298
|
- spec/lib/rails-settings-ui/type_converter_spec.rb
|
295
299
|
- spec/lib/rails-settings-ui/value_types/array_spec.rb
|