Skip to content

Commit

Permalink
Refactor Image::PAGES_PER_DIALOG_THAT_HAS_SIZE_OPTIONS constant into …
Browse files Browse the repository at this point in the history
…Engine configurable option pages_per_dialog_that_have_size_options
  • Loading branch information
Jamie Winsor committed Sep 7, 2011
1 parent 1448654 commit 7eccdc1
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
6 changes: 1 addition & 5 deletions images/app/models/refinery/image.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ class Image < ActiveRecord::Base
# Docs for acts_as_indexed http://github.com/dougal/acts_as_indexed
acts_as_indexed :fields => [:title]

# when a dialog pops up with images, but that dialog has image resize options
# how many images per page should there be
PAGES_PER_DIALOG_THAT_HAS_SIZE_OPTIONS = 12

# when listing images out in the admin area, how many images should show per page
PAGES_PER_ADMIN_INDEX = 20

Expand All @@ -31,7 +27,7 @@ def per_page(dialog = false, has_size_options = false)
unless has_size_options
Images::Options.pages_per_dialog
else
PAGES_PER_DIALOG_THAT_HAS_SIZE_OPTIONS
Images::Options.pages_per_dialog_that_have_size_options
end
else
PAGES_PER_ADMIN_INDEX
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
# Configures the maximum allowed upload size for an image
# config.max_image_size = 5242880

# Configure how many images per page should be displayed when a dialog is that contains images
# Configure how many images per page should be displayed when a dialog is presented that
# contains images
# config.pages_per_dialog = 18

# Configure how many images per page should be displayed when a dialog is presented that
# contains images and image resize options
# config.pages_per_dialog_that_have_size_options = 12
end
3 changes: 3 additions & 0 deletions images/lib/refinerycms-images.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ class Options

cattr_accessor :pages_per_dialog
self.pages_per_dialog = 18

cattr_accessor :pages_per_dialog_that_have_size_options
self.pages_per_dialog_that_have_size_options = 12
end

class << self
Expand Down
4 changes: 2 additions & 2 deletions images/spec/models/refinery/image_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ module Refinery
describe ".per_page" do
context "dialog is true" do
context "has_size_options is true" do
it "returns image count specified by PAGES_PER_DIALOG_THAT_HAS_SIZE_OPTIONS constant" do
::Refinery::Image.per_page(true, true).should == Image::PAGES_PER_DIALOG_THAT_HAS_SIZE_OPTIONS
it "returns image count specified by Images::Options.pages_per_dialog_that_have_size_options option" do
::Refinery::Image.per_page(true, true).should == Images::Options.pages_per_dialog_that_have_size_options
end
end

Expand Down

0 comments on commit 7eccdc1

Please sign in to comment.