forked from refinery/refinerycms
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor Images::Options class into it's own file
Add reset! class method to reset the Images::Options class to it's default values Images::Options will reset after and before each spec
- Loading branch information
Jamie Winsor
committed
Sep 7, 2011
1 parent
b5ac6d4
commit 85d2314
Showing
5 changed files
with
57 additions
and
24 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,33 @@ | ||
module Refinery | ||
module Images | ||
class Options | ||
include Rails::Railtie::Configurable | ||
|
||
DEFAULT_MAX_IMAGE_SIZE = 5242880 | ||
DEFAULT_PAGES_PER_DIALOG = 18 | ||
DEFAULT_PAGES_PER_DIALOG_THAT_HAVE_SIZE_OPTIONS = 12 | ||
DEFAULT_PAGES_PER_ADMIN_INDEX = 20 | ||
|
||
cattr_accessor :max_image_size | ||
self.max_image_size = DEFAULT_MAX_IMAGE_SIZE | ||
|
||
cattr_accessor :pages_per_dialog | ||
self.pages_per_dialog = DEFAULT_PAGES_PER_DIALOG | ||
|
||
cattr_accessor :pages_per_dialog_that_have_size_options | ||
self.pages_per_dialog_that_have_size_options = DEFAULT_PAGES_PER_DIALOG_THAT_HAVE_SIZE_OPTIONS | ||
|
||
cattr_accessor :pages_per_admin_index | ||
self.pages_per_admin_index = DEFAULT_PAGES_PER_ADMIN_INDEX | ||
|
||
class << self | ||
def reset! | ||
self.max_image_size = DEFAULT_MAX_IMAGE_SIZE | ||
self.pages_per_dialog = DEFAULT_PAGES_PER_DIALOG | ||
self.pages_per_dialog_that_have_size_options = DEFAULT_PAGES_PER_DIALOG_THAT_HAVE_SIZE_OPTIONS | ||
self.pages_per_admin_index = DEFAULT_PAGES_PER_ADMIN_INDEX | ||
end | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
require 'spec_helper' | ||
|
||
module Refinery | ||
describe Images::Options do | ||
describe ".reset!" do | ||
it "should set options back to their default values" do | ||
Images::Options.max_image_size.should == Images::Options::DEFAULT_MAX_IMAGE_SIZE | ||
Images::Options.max_image_size += 1 | ||
Images::Options.max_image_size.should_not == Images::Options::DEFAULT_MAX_IMAGE_SIZE | ||
Images::Options.reset! | ||
Images::Options.max_image_size.should == Images::Options::DEFAULT_MAX_IMAGE_SIZE | ||
end | ||
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