diff --git a/Gemfile.lock b/Gemfile.lock index 7c25f3f7b..2cc62a8bf 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -371,8 +371,8 @@ DEPENDENCIES em-websocket! factory_girl_rails fastercsv (= 1.5.4) - haml (= 3.0.25) fog + haml (= 3.0.25) http_accept_language! jammit (= 0.5.4) jasmine! diff --git a/app/models/photo.rb b/app/models/photo.rb index 7faff65a7..8a1479178 100644 --- a/app/models/photo.rb +++ b/app/models/photo.rb @@ -6,8 +6,8 @@ class Photo < Post require 'carrierwave/orm/activerecord' mount_uploader :image, ImageUploader - xml_reader :remote_photo_path - xml_reader :remote_photo_name + xml_attr :remote_photo_path + xml_attr :remote_photo_name xml_reader :caption xml_reader :status_message_id diff --git a/lib/tasks/migrations.rake b/lib/tasks/migrations.rake index ff75a593f..45d02fc12 100644 --- a/lib/tasks/migrations.rake +++ b/lib/tasks/migrations.rake @@ -41,12 +41,14 @@ namespace :migrations do Photo.all.each do |photo| unless photo.remote_photo_path # extract root - pod_url = photo.person.url - pod_url.chop! if pod_url[-1,1] == '/' + # + pod = URI::parse(photo.person.url) + pod_url = "#{pod.scheme}://#{pod.host}" if photo.image.url remote_path = "#{pod_url}#{photo.image.url}" else + puts pod_url remote_path = "#{pod_url}#{photo.remote_photo_path}/#{photo.remote_photo_name}" end diff --git a/spec/lib/tasks/migrations_spec.rb b/spec/lib/tasks/migrations_spec.rb index 63e700207..1dd6a6aa8 100644 --- a/spec/lib/tasks/migrations_spec.rb +++ b/spec/lib/tasks/migrations_spec.rb @@ -19,13 +19,13 @@ describe 'migrations' do @fixture_name = File.join(File.dirname(__FILE__), '..', '..', 'fixtures', @fixture_filename) @photos = [] + @user = Factory.create(:user) 5.times do |n| if n % 2 == 0 - photo = Photo.instantiate(:user_file => File.open(@fixture_name)) + photo = Photo.diaspora_initialize(:user_file => File.open(@fixture_name), :person => @user.person) photo.remote_photo_path = nil photo.remote_photo_name = nil - photo.person = make_user.person else photo = Photo.new photo.person = Factory(:person, :url => "https://remote.com/") @@ -35,7 +35,7 @@ describe 'migrations' do end @photos[n] = photo - @photos[n].save + @photos[n].save! end end