-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added Config::Db to store db configuration
- Loading branch information
mlomnicki
committed
Aug 7, 2009
1 parent
353c7ae
commit 2db04dd
Showing
5 changed files
with
54 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
host: localhost | ||
user: username | ||
password: secret | ||
driver: pg | ||
database: test | ||
|
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 |
---|---|---|
@@ -1,11 +1,14 @@ | ||
acl: | ||
foo: | ||
sender: [email protected] | ||
bar: | ||
sender: file:///home/michal/test/filetest | ||
recipient: sql://"SELECT * FROM users WHERE login = '%l'" | ||
|
||
action: | ||
pass: REJECT | ||
|
||
access: | ||
pass: foo | ||
|
||
database: "dbconfig.yml" |
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,25 @@ | ||
require 'test_helper' | ||
|
||
describe PostPolicy::Config::Db do | ||
|
||
it "should load config from file and build dbi_params" do | ||
filename = '/tmp/dbconfig' | ||
config = { :host => 'localhost', | ||
:database => 'postpolicy', | ||
:user => 'foo', | ||
:password => 'secret', | ||
:driver => 'pg' } | ||
|
||
File.open( filename, 'w' ) do |f| | ||
f.puts config.to_yaml | ||
end | ||
|
||
PostPolicy::Config::Db.load( filename ) | ||
PostPolicy::Config::Db.dbconfig.should == config | ||
dbi_params = ["DBI:#{config[:driver]}:#{config[:database]}", config[:user], config[:password]] | ||
PostPolicy::Config::Db.dbi_params.should == dbi_params | ||
|
||
FileUtils.rm( filename ) | ||
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