Show More
Commit Description:
added message hiding for admin in msg console...
Commit Description:
added message hiding for admin in msg console git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@371 6386c4cd-e34a-4fa8-8920-d93eb39b512e
File last commit:
Show/Diff file:
Action:
spec/models/configuration_spec.rb | 95 lines | 2.7 KiB | text/x-ruby | RubyLexer |
jittat
[web] added configurations...
r76
require File.dirname(__FILE__) + '/../spec_helper'
describe Configuration do
jittat
start working on e-mail registration...
r155 # only work with cached configuration
class Configuration
@@cache = true
end
jittat
[web] added configurations...
r76 before(:each) do
@int_config = mock(Configuration,
:id => 1,
:key => 'mode',
:value_type => 'integer',
:value => '30')
@string_config = mock(Configuration,
:id => 2,
:key => 'title',
:value_type => 'string',
:value => 'Hello')
@boolean_config = mock(Configuration,
:id => 3,
:key => 'single_user_mode',
:value_type => 'boolean',
:value => 'true')
end
it "should retrieve int config" do
Configuration.should_receive(:find).once.with(:all).
and_return([@int_config, @string_config, @boolean_config])
Configuration.clear
val = Configuration.get('mode')
val.should == 30
end
it "should retrieve boolean config" do
Configuration.should_receive(:find).once.with(:all).
and_return([@int_config, @string_config, @boolean_config])
Configuration.clear
val = Configuration.get('single_user_mode')
val.should == true
end
it "should retrieve string config" do
Configuration.should_receive(:find).once.with(:all).
and_return([@int_config, @string_config, @boolean_config])
Configuration.clear
val = Configuration.get('title')
val.should == "Hello"
end
it "should retrieve config with []" do
Configuration.should_receive(:find).once.with(:all).
and_return([@int_config, @string_config, @boolean_config])
Configuration.clear
val = Configuration['title']
val.should == "Hello"
end
it "should read config table once" do
Configuration.should_receive(:find).once.with(:all).
and_return([@int_config, @string_config, @boolean_config])
Configuration.clear
val = Configuration.get('title')
val.should == "Hello"
val = Configuration.get('single_user_mode')
val.should == true
val = Configuration.get('mode')
val.should == 30
end
it "should be able to reload config" do
Configuration.should_receive(:find).twice.with(:all).
and_return([@int_config, @string_config, @boolean_config],
[mock(Configuration,
:key => 'title', :value_type => 'string',
:value => 'Goodbye')])
Configuration.clear
val = Configuration.get('title')
val.should == "Hello"
Configuration.reload
val = Configuration.get('title')
val.should == "Goodbye"
end
end