diff --git a/app/models/photo.rb b/app/models/photo.rb index 5c0c57080dee350ada3e7505676976d8683b5ae1..706570903eb68e0b6b0d7880302b1a83f9c08665 100644 --- a/app/models/photo.rb +++ b/app/models/photo.rb @@ -36,8 +36,8 @@ class Photo < Post photo.image.store! image_file unless photo.image.url.match(/^https?:\/\//) - pod_url = APP_CONFIG[:pod_url].dup - pod_url.chop! if APP_CONFIG[:pod_url][-1,1] == '/' + pod_url = AppConfig[:pod_url].dup + pod_url.chop! if AppConfig[:pod_url][-1,1] == '/' remote_path = "#{pod_url}#{photo.image.url}" else remote_path = photo.image.url @@ -60,7 +60,7 @@ class Photo < Post end def ensure_user_picture - profiles = Profile.where(:image_url => absolute_url(:thumb_large)) + profiles = Profile.where(:image_url => url(:thumb_large)) profiles.each { |profile| profile.image_url = nil profile.save diff --git a/app/models/post.rb b/app/models/post.rb index d95ebd32647ff62a010b27aba7af775837cf4649..456fce36e507301ec04b5f3a67c3f530d7395327 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -75,7 +75,7 @@ class Post < ActiveRecord::Base known_post = user.visible_posts(:guid => self.guid).first if known_post if known_post.mutable? - known_post.save_update(self) + known_post.update_attributes(self.attributes) else Rails.logger.info("event=receive payload_type=#{self.class} update=true status=abort sender=#{self.diaspora_handle} reason=immutable existing_post=#{known_post.id}") end diff --git a/spec/lib/tasks/migrations_spec.rb b/spec/lib/tasks/migrations_spec.rb index 1dd6a6aa840b3878502a6fa1c7eb95b31b64e123..49e281121fe171f3d9f1a13f3fa75ec016f6121d 100644 --- a/spec/lib/tasks/migrations_spec.rb +++ b/spec/lib/tasks/migrations_spec.rb @@ -50,7 +50,7 @@ describe 'migrations' do photo.url.match(/$http.*jpg^/) end - @photos[0].remote_photo_path.should include("http://google-") + @photos[0].remote_photo_path.should include("http") @photos[1].remote_photo_path.should include("https://remote.com/") end diff --git a/spec/models/photo_spec.rb b/spec/models/photo_spec.rb index d2aa63572653e374627bde6a2e6051b27c773951..3609e84d724c801355e3c49371c79ad3ec769d59 100644 --- a/spec/models/photo_spec.rb +++ b/spec/models/photo_spec.rb @@ -56,7 +56,7 @@ describe Photo do end it 'sets a remote url' do image = File.open(@fixture_name) - photo = Photo.instantiate( + photo = Photo.diaspora_initialize( :person => @user.person, :user_file => image) photo.remote_photo_path.should include("http") photo.remote_photo_name.should include(".png") diff --git a/spec/models/profile_spec.rb b/spec/models/profile_spec.rb index 863785126400131142dc8d6ff4313d880c823a2c..44182b519c25630aa6edbd9bdfd124370f876c26 100644 --- a/spec/models/profile_spec.rb +++ b/spec/models/profile_spec.rb @@ -52,16 +52,18 @@ describe Profile do lambda {@profile.image_url = ""}.should_not change(@profile, :image_url) end it 'makes relative urls absolute' do - @profile.image_url = @photo.url(:thumb_large) - - @profile.image_url.should == @photo.url(:thumb_large) + @profile.image_url = "/relative/url" + @profile.image_url.should == "#{@pod_url}/relative/url" + end + it "doesn't change absolute urls" do + @profile.image_url = "http://not/a/relative/url" + @profile.image_url.should == "http://not/a/relative/url" end end describe 'serialization' do - let(:person) {Factory.create(:person)} + let(:person) {Factory.create(:person,:diaspora_handle => "foobar" )} it 'should include persons diaspora handle' do - xml = person.profile.to_diaspora_xml xml = person.profile.to_diaspora_xml xml.should include "foobar" end