configvars_rails 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/app/helpers/config_vars_helper.rb +5 -0
- data/configvars_rails.gemspec +5 -2
- data/lib/configvars_rails/controller.rb +2 -3
- data/lib/configvars_rails/generators/all_generator.rb +2 -0
- data/lib/configvars_rails/generators/templates/config_vars/edit.html.erb +2 -2
- data/lib/configvars_rails/generators/templates/config_vars/index.html.erb +2 -2
- data/lib/configvars_rails/generators/templates/layouts/config_vars.html.erb +11 -0
- data/test/config_vars_controller_api_test.rb +3 -6
- data/test/helpers/rails.rb +22 -0
- data/test/test_helper.rb +1 -0
- metadata +7 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.1
|
data/configvars_rails.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{configvars_rails}
|
8
|
-
s.version = "0.4.
|
8
|
+
s.version = "0.4.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Victor Costan"]
|
12
|
-
s.date = %q{2011-03-
|
12
|
+
s.date = %q{2011-03-21}
|
13
13
|
s.description = %q{This gem provides a model and simple controller for
|
14
14
|
storing global application configuration in a database. This allows the
|
15
15
|
configuration to change without source code modifications.}
|
@@ -39,6 +39,7 @@ Gem::Specification.new do |s|
|
|
39
39
|
"lib/configvars_rails/generators/templates/config_vars_controller.rb",
|
40
40
|
"lib/configvars_rails/generators/templates/config_vars_controller_test.rb",
|
41
41
|
"lib/configvars_rails/generators/templates/config_vars_initializer.rb",
|
42
|
+
"lib/configvars_rails/generators/templates/layouts/config_vars.html.erb",
|
42
43
|
"lib/configvars_rails/model.rb",
|
43
44
|
"lib/configvars_rails/routes.rb",
|
44
45
|
"test/config_var_test.rb",
|
@@ -47,6 +48,7 @@ Gem::Specification.new do |s|
|
|
47
48
|
"test/helpers/application_controller.rb",
|
48
49
|
"test/helpers/db_setup.rb",
|
49
50
|
"test/helpers/initializers.rb",
|
51
|
+
"test/helpers/rails.rb",
|
50
52
|
"test/helpers/routes.rb",
|
51
53
|
"test/helpers/view_helpers.rb",
|
52
54
|
"test/routes_test.rb",
|
@@ -63,6 +65,7 @@ Gem::Specification.new do |s|
|
|
63
65
|
"test/helpers/application_controller.rb",
|
64
66
|
"test/helpers/db_setup.rb",
|
65
67
|
"test/helpers/initializers.rb",
|
68
|
+
"test/helpers/rails.rb",
|
66
69
|
"test/helpers/routes.rb",
|
67
70
|
"test/helpers/view_helpers.rb",
|
68
71
|
"test/routes_test.rb",
|
@@ -28,13 +28,13 @@ module ControllerClassMethods
|
|
28
28
|
def config_vars_auth(*args)
|
29
29
|
include AuthInstanceMethods
|
30
30
|
before_filter :config_vars_http_basic_check, *args
|
31
|
+
layout 'config_vars'
|
31
32
|
end
|
32
33
|
end
|
33
34
|
|
34
35
|
# Included in controllers that call config_vars_controller.
|
35
36
|
module ControllerInstanceMethods
|
36
37
|
# GET /config_vars
|
37
|
-
# GET /config_vars.xml
|
38
38
|
def index
|
39
39
|
@config_vars = ConfigVar.order(:name).all
|
40
40
|
|
@@ -91,8 +91,7 @@ module ControllerInstanceMethods
|
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
94
|
-
# DELETE /config_vars/
|
95
|
-
# DELETE /config_vars/1.xml
|
94
|
+
# DELETE /config_vars/http_user
|
96
95
|
def destroy
|
97
96
|
@config_var = ConfigVar.where(:name => params[:name]).first
|
98
97
|
@config_var.destroy
|
@@ -24,6 +24,8 @@ class AllGenerator < Rails::Generators::Base
|
|
24
24
|
copy_file File.join('config_vars', view_name),
|
25
25
|
File.join('app', 'views', 'config_vars', view_name)
|
26
26
|
end
|
27
|
+
copy_file File.join('layouts', 'config_vars.html.erb'),
|
28
|
+
File.join('app', 'views', 'layouts', 'config_vars.html.erb')
|
27
29
|
route 'config_vars'
|
28
30
|
|
29
31
|
copy_file 'config_vars_initializer.rb',
|
@@ -1,10 +1,10 @@
|
|
1
|
-
<
|
1
|
+
<h2>Editing Configuration Variable</h2>
|
2
2
|
|
3
3
|
<%= form_for(@config_var, :url => config_var_path(@config_var),
|
4
4
|
:html => { :method => :put }) do |f| %>
|
5
5
|
<% if @config_var.errors.any? %>
|
6
6
|
<div id="error_explanation">
|
7
|
-
<
|
7
|
+
<h3><%= pluralize(@config_var.errors.count, "error") %> prohibited this config_var from being saved:</h3>
|
8
8
|
|
9
9
|
<ul>
|
10
10
|
<% @config_var.errors.full_messages.each do |msg| %>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<
|
1
|
+
<h2>Set Configuration Variables</h2>
|
2
2
|
|
3
3
|
<table class="configuration_variables">
|
4
4
|
<tr>
|
@@ -29,7 +29,7 @@
|
|
29
29
|
<% end %>
|
30
30
|
</table>
|
31
31
|
|
32
|
-
<
|
32
|
+
<h2>Available Configuration Variables</h2>
|
33
33
|
|
34
34
|
<table class="configuration_variables">
|
35
35
|
<tr>
|
@@ -11,7 +11,9 @@ class ConfigVarsControllerApiTest < ActionController::TestCase
|
|
11
11
|
|
12
12
|
setup do
|
13
13
|
@config_var = config_vars(:app_uri)
|
14
|
-
request.env['HTTP_AUTHORIZATION'] =
|
14
|
+
request.env['HTTP_AUTHORIZATION'] =
|
15
|
+
ActionController::HttpAuthentication::Basic.encode_credentials('config',
|
16
|
+
'vars')
|
15
17
|
end
|
16
18
|
|
17
19
|
test "should get index" do
|
@@ -72,9 +74,4 @@ class ConfigVarsControllerApiTest < ActionController::TestCase
|
|
72
74
|
get :index
|
73
75
|
assert_response :unauthorized
|
74
76
|
end
|
75
|
-
|
76
|
-
# Verbatim, from ActiveController's own unit tests.
|
77
|
-
def encode_credentials(username, password)
|
78
|
-
"Basic #{ActiveSupport::Base64.encode64("#{username}:#{password}")}"
|
79
|
-
end
|
80
77
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# Fake application.
|
2
|
+
module ConfigVarsApp
|
3
|
+
class Application
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
7
|
+
# Mock Rails.application used in the config_vars layout.
|
8
|
+
#
|
9
|
+
# This mocks Rails for ConfigVars classes, but not for everything else.
|
10
|
+
module ConfigVarsHelper
|
11
|
+
module Rails
|
12
|
+
def self.application
|
13
|
+
ConfigVarsApp::Application.new
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
# For javascript_include_tag in the config_vars layout.
|
19
|
+
ActionController::Base.config.assets_dir = '.'
|
20
|
+
ActionController::Base.config.javascripts_dir = '.'
|
21
|
+
ActionView::Helpers::AssetTagHelper.
|
22
|
+
register_javascript_expansion(:defaults => ['rails.js'])
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: configvars_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 13
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
version: 0.4.
|
9
|
+
- 1
|
10
|
+
version: 0.4.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Victor Costan
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-03-
|
18
|
+
date: 2011-03-21 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -83,6 +83,7 @@ files:
|
|
83
83
|
- lib/configvars_rails/generators/templates/config_vars_controller.rb
|
84
84
|
- lib/configvars_rails/generators/templates/config_vars_controller_test.rb
|
85
85
|
- lib/configvars_rails/generators/templates/config_vars_initializer.rb
|
86
|
+
- lib/configvars_rails/generators/templates/layouts/config_vars.html.erb
|
86
87
|
- lib/configvars_rails/model.rb
|
87
88
|
- lib/configvars_rails/routes.rb
|
88
89
|
- test/config_var_test.rb
|
@@ -91,6 +92,7 @@ files:
|
|
91
92
|
- test/helpers/application_controller.rb
|
92
93
|
- test/helpers/db_setup.rb
|
93
94
|
- test/helpers/initializers.rb
|
95
|
+
- test/helpers/rails.rb
|
94
96
|
- test/helpers/routes.rb
|
95
97
|
- test/helpers/view_helpers.rb
|
96
98
|
- test/routes_test.rb
|
@@ -136,6 +138,7 @@ test_files:
|
|
136
138
|
- test/helpers/application_controller.rb
|
137
139
|
- test/helpers/db_setup.rb
|
138
140
|
- test/helpers/initializers.rb
|
141
|
+
- test/helpers/rails.rb
|
139
142
|
- test/helpers/routes.rb
|
140
143
|
- test/helpers/view_helpers.rb
|
141
144
|
- test/routes_test.rb
|