forked from refinery/refinerycms-page-images
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed failing tests, documented wymeditor support.
Conflicts: app/decorators/controllers/refinery/admin/pages_controller_decorator.rb refinerycms-page-images.gemspec
- Loading branch information
Showing
9 changed files
with
95 additions
and
92 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
26 changes: 14 additions & 12 deletions
26
app/decorators/controllers/refinery/admin/pages_controller_decorator.rb
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,20 +1,22 @@ | ||
Refinery::Admin::PagesController.class_eval do | ||
|
||
# We need to add :images_attributes to page_params as it is ignored by strong parameters. (See #100) | ||
def page_params_with_page_image_params | ||
# work around an issue with stack level too deep, due to an issue with decorators. | ||
if self.instance_methods.exclude?(:page_params_with_page_image_params) | ||
# We need to add :images_attributes to page_params as it is ignored by strong parameters. (See #100) | ||
def page_params_with_page_image_params | ||
|
||
# Get the :images_attributes hash from params | ||
page_image_params = params.require(:page).permit(images_attributes: [:id, :caption]) | ||
# Get the :images_attributes hash from params | ||
page_image_params = params.require(:page).permit(images_attributes: [:id, :caption]) | ||
|
||
# If there is no :images_attributes hash use a blank hash (so it removes deleted images) | ||
page_image_params = {images_attributes:{}} if page_image_params[:images_attributes].nil? | ||
# If there is no :images_attributes hash use a blank hash (so it removes deleted images) | ||
page_image_params = {images_attributes:{}} if page_image_params[:images_attributes].nil? | ||
|
||
# Add the :images_attributes hash to the default page_params hash | ||
page_params_without_page_image_params.merge(page_image_params) | ||
# Add the :images_attributes hash to the default page_params hash | ||
page_params_without_page_image_params.merge(page_image_params) | ||
|
||
end | ||
|
||
# Swap out the default page_params method with our new one | ||
alias_method_chain :page_params, :page_image_params | ||
end | ||
|
||
# Swap out the default page_params method with our new one | ||
alias_method_chain :page_params, :page_image_params | ||
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
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,6 +1,6 @@ | ||
Gem::Specification.new do |s| | ||
s.name = %q{refinerycms-page-images} | ||
s.version = %q{3.0.0.dev} | ||
s.version = %q{3.0.0} | ||
s.description = %q{Attach images to pages ins Refinery CMS} | ||
s.summary = %q{Page Images extension for Refinery CMS} | ||
s.email = %q{[email protected]} | ||
|
@@ -14,4 +14,5 @@ Gem::Specification.new do |s| | |
|
||
s.add_dependency 'refinerycms-pages', '~> 3.0.0' | ||
s.add_dependency 'decorators', '~> 1.0.0' | ||
s.add_dependency 'globalize', '~> 4.0' | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
FactoryGirl.define do | ||
factory :page_with_image, :parent => :page do | ||
after(:create) { |p| p.images << FactoryGirl.create(:image) } | ||
after(:create) { |p| p.image_pages.create(image: FactoryGirl.create(:image)) } | ||
end | ||
|
||
factory :blog_post_with_image, :parent => :blog_post do | ||
after(:create) { |b| b.images << FactoryGirl.create(:image) } | ||
after(:create) { |b| b.image_pages.create(image: FactoryGirl.create(:image)) } | ||
end if defined? Refinery::Blog::Post | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,17 @@ | ||
require 'spec_helper' | ||
|
||
module Refinery | ||
describe BlogPost do | ||
it "should not have images" do | ||
blog = FactoryGirl.create(:blog_post) | ||
blog.images.count.should == 0 | ||
end | ||
module Blog | ||
describe Post, type: :model do | ||
it "should not have images" do | ||
blog = FactoryGirl.create(:blog_post) | ||
blog.images.count.should == 0 | ||
end | ||
|
||
it "should have images" do | ||
blog = FactoryGirl.create(:blog_post_with_image) | ||
blog.images.count.should == 1 | ||
it "should have images" do | ||
blog = FactoryGirl.create(:blog_post_with_image) | ||
blog.images.count.should == 1 | ||
end | ||
end | ||
end | ||
end if defined?(Refinery::Blog::Post) |
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