Resource import working
* added rake tasks
This commit is contained in:
@@ -27,15 +27,16 @@ describe Refinery::WordPress::Attachment, :type => :model do
|
||||
end
|
||||
end
|
||||
|
||||
describe "#replace_image_url" do
|
||||
describe "#replace_url" do
|
||||
let(:post) { BlogPost.first }
|
||||
|
||||
before do
|
||||
test_dump.authors.each(&:to_refinery)
|
||||
test_dump.posts.each(&:to_refinery)
|
||||
|
||||
@image = attachment.to_refinery
|
||||
|
||||
attachment.replace_image_url_in_blog_posts
|
||||
attachment.replace_url
|
||||
end
|
||||
|
||||
specify { post.body.should_not include attachment.url }
|
||||
@@ -45,8 +46,6 @@ describe Refinery::WordPress::Attachment, :type => :model do
|
||||
it "should replace attachment urls in the generated BlogPosts" do
|
||||
post.body.should include(@image.image.url)
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -60,8 +59,34 @@ describe Refinery::WordPress::Attachment, :type => :model do
|
||||
specify { attachment.should_not be_an_image }
|
||||
|
||||
describe '#to_refinery' do
|
||||
it "should raise an exception for now" do
|
||||
lambda { attachment.to_refinery }.should raise_error
|
||||
before do
|
||||
@resource = attachment.to_refinery
|
||||
end
|
||||
|
||||
specify { Resource.should have(1).record }
|
||||
specify { @resource.should be_a(Resource) }
|
||||
|
||||
it "should copy the attributes from Attachment" do
|
||||
@resource.created_at.should == attachment.post_date
|
||||
@resource.file.url.end_with?(attachment.file_name).should be_true
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe '#replace_resource_url' do
|
||||
let(:page_part) { Page.last.parts.first }
|
||||
|
||||
before do
|
||||
test_dump.pages.each(&:to_refinery)
|
||||
@resource = attachment.to_refinery
|
||||
attachment.replace_url
|
||||
end
|
||||
|
||||
specify { page_part.body.should_not include attachment.url }
|
||||
specify { page_part.body.should_not include 'wp-content' }
|
||||
|
||||
it "should replace attachment urls in the generated BlogPosts" do
|
||||
page_part.body.should include(@resource.file.url)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -5,18 +5,6 @@ require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
||||
require "rails/test_help"
|
||||
require "rspec/rails"
|
||||
require "database_cleaner"
|
||||
require "fakeweb"
|
||||
|
||||
FakeWeb.allow_net_connect = false
|
||||
|
||||
# Simulating download of wordpress file attachments. The dump expects the files
|
||||
# to be at the given URLs
|
||||
FakeWeb.register_uri(:get,
|
||||
"http://localhost/wordpress/wp-content/uploads/2011/05/200px-Tux.svg_.png",
|
||||
:body => File.new('spec/fixtures/200px-Tux.svg_.png').read,
|
||||
:content_type => "image/png")
|
||||
|
||||
FakeWeb.register_uri(:get, "http://localhost/wordpress/wp-content/uploads/2011/05/cv.txt", :body => "Hello World!", :content_type => "text/plain")
|
||||
|
||||
ActionMailer::Base.delivery_method = :test
|
||||
ActionMailer::Base.perform_deliveries = true
|
||||
|
||||
12
spec/support/fakeweb.rb
Normal file
12
spec/support/fakeweb.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
require "fakeweb"
|
||||
|
||||
FakeWeb.allow_net_connect = false
|
||||
|
||||
# Simulating download of wordpress file attachments. The dump expects the files
|
||||
# to be at the given URLs
|
||||
FakeWeb.register_uri(:get,
|
||||
"http://localhost/wordpress/wp-content/uploads/2011/05/200px-Tux.svg_.png",
|
||||
:body => File.new('spec/fixtures/200px-Tux.svg_.png').read,
|
||||
:content_type => "image/png")
|
||||
|
||||
FakeWeb.register_uri(:get, "http://localhost/wordpress/wp-content/uploads/2011/05/cv.txt", :body => "Hello World!", :content_type => "text/plain")
|
||||
Reference in New Issue
Block a user