Permalink
Browse files

Modify Config loading/saving behavior.

  • Loading branch information...
1 parent 79acfc6 commit a23f29614c79d23de4beb52d0dee7a0e996f78f8 @hmans committed Apr 3, 2012
Showing with 9 additions and 3 deletions.
  1. +1 −1 lib/schnitzelpress/app.rb
  2. +6 −1 lib/schnitzelpress/config.rb
  3. +1 −1 spec/app_spec.rb
  4. +1 −0 spec/spec_helper.rb
View
2 lib/schnitzelpress/app.rb
@@ -33,7 +33,7 @@ class App < Sinatra::Base
# but right now it's the easiest way to get the configuration in synch
# across multiple instances of the app.
#
- Config.instance.reload unless Config.instance.new_record?
+ Config.instance.reload
end
def fresh_when(options)
View
7 lib/schnitzelpress/config.rb
@@ -20,13 +20,18 @@ class Config
field :cache_timestamp, :type => DateTime
- validates :blog_title, :author_name, :author_email, :presence => true
+ validates :blog_title, :author_name, :presence => true
+ validates :author_email, :presence => true, :on => :update
class << self
def instance
@@instance ||= find_or_create_by(:id => 'schnitzelpress')
end
+ def forget_instance
+ @@instance = nil
+ end
+
def get(k)
instance.send(k)
end
View
2 spec/app_spec.rb
@@ -37,7 +37,7 @@ def app
subject { last_response }
it { should be_redirect }
its(:status) { should == 307 }
- specify { subject["Location"].should == 'http://feeds.feedburner.com/example_org' }
+ specify { subject["Location"].should == 'http://example.org/blog.atom' }
end
describe 'viewing a single post' do
View
1 spec/spec_helper.rb
@@ -28,6 +28,7 @@
config.before(:each) do
DatabaseCleaner[:mongoid].start
+ Schnitzelpress::Config.forget_instance
end
config.after(:each) do

0 comments on commit a23f296

Please sign in to comment.