-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved global settings file to a key-value store and modified contents…
… controller and test units accordingly
- Loading branch information
August
committed
Apr 23, 2012
1 parent
98acea1
commit 9308f1a
Showing
8 changed files
with
82 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#Current configuration keys: | ||
#:public_concerto | ||
#:default_upload_type | ||
|
||
class ConcertoConfig < ActiveRecord::Base | ||
|
||
TRUE = "t" | ||
FALSE = "f" | ||
|
||
validates_presence_of :key | ||
validates_uniqueness_of :key | ||
|
||
# Enable hash-like access to table for ease of use | ||
# Returns false if key isn't found | ||
# Example: ConcertoConfig[:public_concerto] => "true" | ||
def self.[](key) | ||
rec = self.find_by_key(key.to_s) | ||
if rec.nil? | ||
return false | ||
end | ||
rec.value | ||
end | ||
|
||
# Override self.method_missing to allow | ||
# instance attribute type access to Configuration | ||
# table. This helps with forms. | ||
def self.method_missing(method, *args) | ||
unless method.to_s.include?('find') # skip AR find methods | ||
value = self[method] | ||
return value unless value.nil? | ||
end | ||
super(method, args) | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class AddConcertoConfig < ActiveRecord::Migration | ||
def change | ||
create_table :concerto_configs do |t| | ||
t.string :key | ||
t.string :value | ||
t.string :value_type | ||
t.string :value_default | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html | ||
|
||
upload_type: | ||
key: default_upload_type | ||
value: graphic |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
require 'test_helper' | ||
|
||
class ConcertoConfigTest < ActiveSupport::TestCase | ||
#Test the fields that should be required | ||
test "Config must return a default upload type of graphic" do | ||
assert_equal(ConcertoConfig[:default_upload_type], "graphic") | ||
end | ||
|
||
end |