diff --git a/Gemfile b/Gemfile index d1b87008938e39981eee1fc3b3d6e81187c50ae3..24d694d4b49da65975eeba16f78065bca69e4b27 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ source 'https://rubygems.org' -gem 'rails', '4.0.9' +gem 'rails', '4.1.5' # Legacy Rails features, remove me! diff --git a/Gemfile.lock b/Gemfile.lock index 01b8f1622d4b199222dcb39a230291b108b346b5..dfa113a283101da63edbdeed249c3e2a4449f934 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,40 +1,42 @@ GEM remote: https://rubygems.org/ specs: - actionmailer (4.0.9) - actionpack (= 4.0.9) + actionmailer (4.1.5) + actionpack (= 4.1.5) + actionview (= 4.1.5) mail (~> 2.5.4) - actionpack (4.0.9) - activesupport (= 4.0.9) - builder (~> 3.1.0) - erubis (~> 2.7.0) + actionpack (4.1.5) + actionview (= 4.1.5) + activesupport (= 4.1.5) rack (~> 1.5.2) rack-test (~> 0.6.2) actionpack-action_caching (1.1.1) actionpack (>= 4.0.0, < 5.0) actionpack-page_caching (1.0.2) actionpack (>= 4.0.0, < 5) - activemodel (4.0.9) - activesupport (= 4.0.9) - builder (~> 3.1.0) - activerecord (4.0.9) - activemodel (= 4.0.9) - activerecord-deprecated_finders (~> 1.0.2) - activesupport (= 4.0.9) - arel (~> 4.0.0) - activerecord-deprecated_finders (1.0.3) + actionview (4.1.5) + activesupport (= 4.1.5) + builder (~> 3.1) + erubis (~> 2.7.0) + activemodel (4.1.5) + activesupport (= 4.1.5) + builder (~> 3.1) + activerecord (4.1.5) + activemodel (= 4.1.5) + activesupport (= 4.1.5) + arel (~> 5.0.0) activerecord-import (0.5.0) activerecord (>= 3.0) activeresource (4.0.0) activemodel (~> 4.0) activesupport (~> 4.0) rails-observers (~> 0.1.1) - activesupport (4.0.9) + activesupport (4.1.5) i18n (~> 0.6, >= 0.6.9) - minitest (~> 4.2) - multi_json (~> 1.3) + json (~> 1.7, >= 1.7.7) + minitest (~> 5.1) thread_safe (~> 0.1) - tzinfo (~> 0.3.37) + tzinfo (~> 1.1) acts-as-taggable-on (3.2.6) activerecord (>= 3, < 5) acts_as_api (0.4.2) @@ -42,7 +44,7 @@ GEM activesupport (>= 3.0.0) rack (>= 1.1.0) addressable (2.3.6) - arel (4.0.2) + arel (5.0.1.20140414130214) asset_sync (1.0.0) activemodel fog (>= 1.8.0) @@ -58,7 +60,7 @@ GEM bcrypt (3.1.7) bootstrap-sass (2.3.2.2) sass (~> 3.2) - builder (3.1.4) + builder (3.2.2) capybara (2.4.1) mime-types (>= 1.16) nokogiri (>= 1.3.3) @@ -254,7 +256,7 @@ GEM mini_magick (3.7.0) subexec (~> 0.2.1) mini_portile (0.5.3) - minitest (4.7.5) + minitest (5.4.0) mobile-fu (1.3.1) rack-mobile-detect rails @@ -321,13 +323,15 @@ GEM rack rack-test (0.6.2) rack (>= 1.0) - rails (4.0.9) - actionmailer (= 4.0.9) - actionpack (= 4.0.9) - activerecord (= 4.0.9) - activesupport (= 4.0.9) + rails (4.1.5) + actionmailer (= 4.1.5) + actionpack (= 4.1.5) + actionview (= 4.1.5) + activemodel (= 4.1.5) + activerecord (= 4.1.5) + activesupport (= 4.1.5) bundler (>= 1.3.0, < 2.0) - railties (= 4.0.9) + railties (= 4.1.5) sprockets-rails (~> 2.0) rails-i18n (4.0.2) i18n (~> 0.6) @@ -353,9 +357,9 @@ GEM sass-rails (~> 4.0) rails_autolink (1.1.5) rails (> 3.1) - railties (4.0.9) - actionpack (= 4.0.9) - activesupport (= 4.0.9) + railties (4.1.5) + actionpack (= 4.1.5) + activesupport (= 4.1.5) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) raindrops (0.13.0) @@ -446,7 +450,8 @@ GEM simple_oauth (~> 0.2) typhoeus (0.6.8) ethon (>= 0.7.0) - tzinfo (0.3.41) + tzinfo (1.2.2) + thread_safe (~> 0.1) uglifier (2.5.0) execjs (>= 0.3.0) json (>= 1.8.0) @@ -528,7 +533,7 @@ DEPENDENCIES rack-protection (= 1.2) rack-rewrite (= 1.5.0) rack-ssl (= 1.4.1) - rails (= 4.0.9) + rails (= 4.1.5) rails-i18n (= 4.0.2) rails-timeago (= 2.4.0) rails_admin (= 0.6.2) diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb index df95f3d92a4ad3b42f7833b09b1d280b871e1692..f160c599284883f212646f7ed1a44546638b6f4c 100644 --- a/app/controllers/people_controller.rb +++ b/app/controllers/people_controller.rb @@ -92,7 +92,7 @@ class PeopleController < ApplicationController @block = current_user.blocks.where(:person_id => @person.id).first @contact = current_user.contact_for(@person) if @contact && !params[:only_posts] - @contacts_of_contact_count = @contact.contacts.count + @contacts_of_contact_count = @contact.contacts.count(:all) @contacts_of_contact = @contact.contacts.limit(8) else @contact ||= Contact.new @@ -147,7 +147,7 @@ class PeopleController < ApplicationController @contact = current_user.contact_for(@person) @aspect = :profile @contacts_of_contact = @contact.contacts.paginate(:page => params[:page], :per_page => (params[:limit] || 15)) - @contacts_of_contact_count = @contact.contacts.count + @contacts_of_contact_count = @contact.contacts.count(:all) @hashes = hashes_for_people @contacts_of_contact, @aspects else flash[:error] = I18n.t 'people.show.does_not_exist' diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index 7e1fad0a6f55d096efc383dea3d64000e47cfcde..bce6c78656b01072dcdab7abca841ce4c08f3da4 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -26,7 +26,7 @@ class PhotosController < ApplicationController if @contact @contacts_of_contact = @contact.contacts - @contacts_of_contact_count = @contact.contacts.count + @contacts_of_contact_count = @contact.contacts.count(:all) else @contact = Contact.new end diff --git a/app/models/profile.rb b/app/models/profile.rb index 64b059bb9842069495fba73fea8e8cc9162bc026..2ea8bca795f6e16c40877cad18c6398629fc6d40 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -53,6 +53,7 @@ class Profile < ActiveRecord::Base end def receive(user, person) + person.reload # make sure to have old profile referenced Rails.logger.info("event=receive payload_type=profile sender=#{person} to=#{user}") profiles_attr = self.attributes.merge('tag_string' => self.tag_string).slice('diaspora_handle', 'first_name', 'last_name', 'image_url', 'image_url_small', 'image_url_medium', 'birthday', 'gender', 'bio', 'location', 'searchable', 'nsfw', 'tag_string') person.profile.update_attributes(profiles_attr) diff --git a/app/views/people/_profile_sidebar.html.haml b/app/views/people/_profile_sidebar.html.haml index 1cb71e4481dc14e9746df8d4c10bc2daea08a409..ef54366465be9121c0444eba61dbb57157ae1642 100644 --- a/app/views/people/_profile_sidebar.html.haml +++ b/app/views/people/_profile_sidebar.html.haml @@ -61,7 +61,7 @@ %h4 = t('.photos') .item_count - = "#{@photos.count}" + = "#{@photos.count(:all)}" - @photos.limit(8).each do |photo| = image_tag(photo.url(:thumb_small)) %br diff --git a/lib/postzord/receiver/private.rb b/lib/postzord/receiver/private.rb index f2d560e504931ea7883a705aa0380f7787f0f0e2..0a45f9744fccfdb376bb435f7e4ce2f6b42b28ab 100644 --- a/lib/postzord/receiver/private.rb +++ b/lib/postzord/receiver/private.rb @@ -16,18 +16,16 @@ class Postzord::Receiver::Private < Postzord::Receiver end def receive! - begin - if @sender && self.salmon.verified_for_key?(@sender.public_key) - parse_and_receive(salmon.parsed_data) - else - FEDERATION_LOGGER.info("event=receive status=abort recipient=#{@user.diaspora_handle} sender=#{@salmon.author_id} reason='not_verified for key'") - false - end - rescue => e - #this sucks - FEDERATION_LOGGER.error("Failure to receive #{@object.class} from sender:#{@sender.id} for user:#{@user.id}: #{e.message}\n#{@object.inspect}") - raise e + if @sender && self.salmon.verified_for_key?(@sender.public_key) + parse_and_receive(salmon.parsed_data) + else + FEDERATION_LOGGER.info("event=receive status=abort recipient=#{@user.diaspora_handle} sender=#{@salmon.author_id} reason='not_verified for key'") + false end + rescue => e + #this sucks + FEDERATION_LOGGER.error("Failure to receive #{@object.class} from sender:#{@sender.id} for user:#{@user.id}: #{e.message}\n#{@object.inspect}") + raise e end def parse_and_receive(xml) @@ -101,7 +99,7 @@ class Postzord::Receiver::Private < Postzord::Receiver def contact_required_unless_request unless @object.is_a?(Request) || @user.contact_for(@sender) FEDERATION_LOGGER.error("event=receive status=abort reason='sender not connected to recipient' recipient=#{@user_person.diaspora_handle} sender=#{@sender.diaspora_handle}") - return true + return true end end diff --git a/lib/postzord/receiver/public.rb b/lib/postzord/receiver/public.rb index e60da9083a70b2d82d26b4b5c4a8580ffcfe0bc5..686e9a5b3d5cb89894d654a3049f0e00d8900294 100644 --- a/lib/postzord/receiver/public.rb +++ b/lib/postzord/receiver/public.rb @@ -64,7 +64,7 @@ class Postzord::Receiver::Public < Postzord::Receiver # @return [Array<Integer>] User ids def recipient_user_ids - User.all_sharing_with_person(@author).select('users.id').map!{ |u| u.id } + User.all_sharing_with_person(@author).pluck('users.id') end def xml_author diff --git a/spec/controllers/aspects_controller_spec.rb b/spec/controllers/aspects_controller_spec.rb index 1e68047e3231832ae8fd84278a13a2c00cd3fcdb..86adf58953d7467ddae608b2512c675e425e5524 100644 --- a/spec/controllers/aspects_controller_spec.rb +++ b/spec/controllers/aspects_controller_spec.rb @@ -162,7 +162,7 @@ describe AspectsController do @alices_aspect_1.contacts_visible = false @alices_aspect_1.save - get :toggle_contact_visibility, :format => 'js', :aspect_id => @alices_aspect_1.id + xhr :get, :toggle_contact_visibility, :format => 'js', :aspect_id => @alices_aspect_1.id @alices_aspect_1.reload.contacts_visible.should be_true end @@ -170,7 +170,7 @@ describe AspectsController do @alices_aspect_1.contacts_visible = true @alices_aspect_1.save - get :toggle_contact_visibility, :format => 'js', :aspect_id => @alices_aspect_1.id + xhr :get, :toggle_contact_visibility, :format => 'js', :aspect_id => @alices_aspect_1.id @alices_aspect_1.reload.contacts_visible.should be_false end end diff --git a/spec/controllers/conversations_controller_spec.rb b/spec/controllers/conversations_controller_spec.rb index f1617cd9511ef063ddbfc2c2696df2fa46b2bdbf..54c9d7e68b2fc6613a8611db691b5234f4ffdf89 100644 --- a/spec/controllers/conversations_controller_spec.rb +++ b/spec/controllers/conversations_controller_spec.rb @@ -261,7 +261,7 @@ describe ConversationsController do end it 'succeeds with js' do - get :show, :id => @conversation.id, :format => :js + xhr :get, :show, :id => @conversation.id, :format => :js response.should be_success assigns[:conversation].should == @conversation end diff --git a/spec/controllers/people_controller_spec.rb b/spec/controllers/people_controller_spec.rb index bc11af200a397cb6244e155ae0c1cf15fa3dffd3..c65a2960a77fe50692e3b74375af1d689ea3e100 100644 --- a/spec/controllers/people_controller_spec.rb +++ b/spec/controllers/people_controller_spec.rb @@ -118,7 +118,7 @@ describe PeopleController do describe '#tag_index' do it 'works for js' do - get :tag_index, :name => 'jellybeans', :format => :js + xhr :get, :tag_index, :name => 'jellybeans', :format => :js response.should be_success end @@ -126,7 +126,7 @@ describe PeopleController do f = FactoryGirl.create(:person) f.profile.tag_string = "#seeded" f.profile.save - get :tag_index, :name => 'seeded', :format => :js + xhr :get, :tag_index, :name => 'seeded', :format => :js assigns[:people].count.should == 1 end end diff --git a/spec/controllers/photos_controller_spec.rb b/spec/controllers/photos_controller_spec.rb index dede4a72ced4cd9c9f2623511d3a0c7fba820530..68d97823c17ca7d412ea6424a3cb3f5153b4382f 100644 --- a/spec/controllers/photos_controller_spec.rb +++ b/spec/controllers/photos_controller_spec.rb @@ -101,10 +101,10 @@ describe PhotosController do response.headers['Content-Type'].should match 'application/json.*' save_fixture(response.body, "photos_json") end - + it 'displays by date of creation' do max_time = bob.photos.first.created_at - 1.day - get :index, person_id: bob.person.guid.to_s, + get :index, person_id: bob.person.guid.to_s, max_time: max_time.to_i assigns[:posts].should be_empty @@ -130,7 +130,7 @@ describe PhotosController do end it 'will let you delete your profile picture' do - get :make_profile_photo, :photo_id => @alices_photo.id, :format => :js + xhr :get, :make_profile_photo, :photo_id => @alices_photo.id, :format => :js delete :destroy, :id => @alices_photo.id Photo.find_by_id(@alices_photo.id).should be_nil end @@ -182,7 +182,7 @@ describe PhotosController do describe "#make_profile_photo" do it 'should return a 201 on a js success' do - get :make_profile_photo, :photo_id => @alices_photo.id, :format => 'js' + xhr :get, :make_profile_photo, :photo_id => @alices_photo.id, :format => 'js' response.code.should == "201" end diff --git a/spec/integration/attack_vectors_spec.rb b/spec/integration/attack_vectors_spec.rb index 7e7f9f126587f79166d287f80c263af32eedc89e..8683d866a8ba25ea4f895b6e773547a1db8fc766 100644 --- a/spec/integration/attack_vectors_spec.rb +++ b/spec/integration/attack_vectors_spec.rb @@ -212,7 +212,7 @@ describe "attack vectors" do expect { receive_post(retraction, :from => alice, :by => bob) }.to raise_error Diaspora::AuthorXMLAuthorMismatch - }.to_not change(bob.visible_shareables(Post), :count) + }.to_not change { bob.visible_shareables(Post).count(:all) } end diff --git a/spec/integration/receiving_spec.rb b/spec/integration/receiving_spec.rb index 231d92d7c44ea3115abdd9da5d77a01caaad2e70..319f996c1348642d61ed2598ca33bfe5b3ac95d4 100644 --- a/spec/integration/receiving_spec.rb +++ b/spec/integration/receiving_spec.rb @@ -51,7 +51,7 @@ describe 'a user receives a post' do bob.dispatch_post(sm, :to => @bobs_aspect) end - alice.visible_shareables(Post).count.should == 1 + alice.visible_shareables(Post).count(:all).should == 1 end context 'with mentions, ' do @@ -259,7 +259,7 @@ describe 'a user receives a post' do inlined_jobs do @comment = bob.comment!(@post, 'tada') @xml = @comment.to_diaspora_xml - + expect { receive_with_zord(alice, bob.person, @xml) }.to_not raise_exception @@ -362,7 +362,6 @@ describe 'a user receives a post' do #Build xml for profile xml = new_profile.to_diaspora_xml - #Marshal profile zord = Postzord::Receiver::Private.new(alice, :person => person) zord.parse_and_receive(xml) diff --git a/spec/lib/postzord/receiver/public_spec.rb b/spec/lib/postzord/receiver/public_spec.rb index c291b14c5c30275ca8f9cbf3fbf0f69c3204dfcb..9f802c102d07d169e6c56ca4c597c309d64f1de6 100644 --- a/spec/lib/postzord/receiver/public_spec.rb +++ b/spec/lib/postzord/receiver/public_spec.rb @@ -22,7 +22,7 @@ describe Postzord::Receiver::Public do bob.destroy comment.destroy expect{ - receiver = Postzord::Receiver::Public.new(xml) + receiver = Postzord::Receiver::Public.new(xml) receiver.perform! }.to change(Comment, :count).by(1) end @@ -61,7 +61,7 @@ describe Postzord::Receiver::Public do @receiver.perform! end - it 'enqueues a Workers::ReceiveLocalBatch' do + it 'enqueues a Workers::ReceiveLocalBatch' do Workers::ReceiveLocalBatch.should_receive(:perform_async).with(anything, anything, anything) @receiver.perform! end @@ -84,13 +84,13 @@ describe Postzord::Receiver::Public do describe '#recipient_user_ids' do it 'calls User.all_sharing_with_person' do - User.should_receive(:all_sharing_with_person).and_return(double(:select => [])) + User.should_receive(:all_sharing_with_person).and_return(double(:pluck => [])) receiver = Postzord::Receiver::Public.new(@xml) receiver.perform! end end - describe '#receive_relayable' do + describe '#receive_relayable' do before do @comment = bob.build_comment(:text => 'yo', :post => FactoryGirl.create(:status_message)) @comment.save diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rb index 9d9f5f7b7dedc9798388544c2f47f5c217bfd846..aa2cb29d6b23d01a4f68f648ccf77ea0aead6c73 100644 --- a/spec/models/post_spec.rb +++ b/spec/models/post_spec.rb @@ -43,7 +43,7 @@ describe Post do end it 'should return the three visible posts' do - StatusMessage.owned_or_visible_by_user(@you).count.should == 3 + StatusMessage.owned_or_visible_by_user(@you).count(:all).should == 3 end end diff --git a/spec/models/user/querying_spec.rb b/spec/models/user/querying_spec.rb index b24a3be00c23f37b68925dde6c523ec2bbdd7366..85c252d02a92d14f9612b460ce0d6e66a70887d4 100644 --- a/spec/models/user/querying_spec.rb +++ b/spec/models/user/querying_spec.rb @@ -111,7 +111,7 @@ describe User::Querying do describe "#visible_shareables" do it 'never contains posts from people not in your aspects' do FactoryGirl.create(:status_message, :public => true) - bob.visible_shareables(Post).count.should == 0 + bob.visible_shareables(Post).count(:all).should == 0 end context 'with two posts with the same timestamp' do