diff --git a/app/assets/javascripts/app/models/person.js b/app/assets/javascripts/app/models/person.js index 634f6b6f0..de68510d7 100644 --- a/app/assets/javascripts/app/models/person.js +++ b/app/assets/javascripts/app/models/person.js @@ -1,8 +1,6 @@ app.models.Person = Backbone.Model.extend({ - urlRoot: '/people', - url: function() { - return this.urlRoot + '/' + this.get('guid'); + return Routes.person_path(this.get('guid')); }, initialize: function() { diff --git a/app/assets/templates/profile_sidebar_tpl.jst.hbs b/app/assets/templates/profile_sidebar_tpl.jst.hbs index e65cfd9ae..5f70552e7 100644 --- a/app/assets/templates/profile_sidebar_tpl.jst.hbs +++ b/app/assets/templates/profile_sidebar_tpl.jst.hbs @@ -1,7 +1,7 @@
{{#linkToPerson this}} - {{{personImage this "l"}}} + {{{personImage this "large"}}} {{/linkToPerson}}
@@ -74,7 +74,7 @@
{{#each photos.items}} - {{guid}} + {{guid}} {{/each}}

@@ -90,7 +90,7 @@

{{#each contacts.items}} - {{#linkToPerson this}}{{{personImage this "s"}}}{{/linkToPerson}} + {{#linkToPerson this}}{{{personImage this "small"}}}{{/linkToPerson}} {{/each}}

diff --git a/app/helpers/aspect_global_helper.rb b/app/helpers/aspect_global_helper.rb index c35131e0b..fa47ccc05 100644 --- a/app/helpers/aspect_global_helper.rb +++ b/app/helpers/aspect_global_helper.rb @@ -65,6 +65,6 @@ LISTITEM return {} end - { aspects: aspects, aspect: aspect, aspect_ids: aspect_ids } + { selected_aspects: aspects, aspect: aspect, aspect_ids: aspect_ids } end end diff --git a/app/models/user/querying.rb b/app/models/user/querying.rb index 663564b25..e10fbe036 100644 --- a/app/models/user/querying.rb +++ b/app/models/user/querying.rb @@ -106,7 +106,7 @@ module User::Querying def block_for(person) return nil unless person - self.blocks.where(person_id: person.id).limit(1).first + self.blocks.where(person_id: person.id).first end def aspects_with_shareable(base_class_name_or_class, shareable_id) diff --git a/app/presenters/avatar_presenter.rb b/app/presenters/avatar_presenter.rb index 10cabb949..5cb0060d8 100644 --- a/app/presenters/avatar_presenter.rb +++ b/app/presenters/avatar_presenter.rb @@ -4,9 +4,9 @@ class AvatarPresenter < BasePresenter DEFAULT_IMAGE = ActionController::Base.helpers.image_path('user/default.png') def base_hash - { s: image_url_small || DEFAULT_IMAGE, - m: image_url_medium || DEFAULT_IMAGE, - l: image_url || DEFAULT_IMAGE + { small: image_url_small || DEFAULT_IMAGE, + medium: image_url_medium || DEFAULT_IMAGE, + large: image_url || DEFAULT_IMAGE } end end diff --git a/app/presenters/person_presenter.rb b/app/presenters/person_presenter.rb index 77dfd3928..37f759353 100644 --- a/app/presenters/person_presenter.rb +++ b/app/presenters/person_presenter.rb @@ -46,18 +46,14 @@ class PersonPresenter < BasePresenter def relationship return false unless current_user + return :blocked if is_blocked? + contact = current_user_person_contact + return :not_sharing unless contact - is_mutual = contact ? contact.mutual? : false - is_sharing = contact ? contact.sharing? : false - is_receiving = contact ? contact.receiving? : false - - if is_blocked? then :blocked - elsif is_mutual then :mutual - elsif is_sharing then :sharing - elsif is_receiving then :receiving - else :not_sharing - end + [:mutual, :sharing, :receiving].find do |status| + contact.public_send("#{status}?") + end || :not_sharing end def person_is_following_current_user diff --git a/app/presenters/photo_presenter.rb b/app/presenters/photo_presenter.rb index 59993733b..defed1d9b 100644 --- a/app/presenters/photo_presenter.rb +++ b/app/presenters/photo_presenter.rb @@ -3,13 +3,13 @@ class PhotoPresenter < BasePresenter { id: id, guid: guid, dimensions: { - h: height, - w: width + height: height, + width: width }, sizes: { - s: url(:thumb_small), - m: url(:thumb_medium), - l: url(:scaled_full) + small: url(:thumb_small), + medium: url(:thumb_medium), + large: url(:scaled_full) } } end diff --git a/app/views/people/show.html.haml b/app/views/people/show.html.haml index e65ad4f8c..fed0296f7 100644 --- a/app/views/people/show.html.haml +++ b/app/views/people/show.html.haml @@ -13,18 +13,16 @@ .span-6 #profile - -# = render :partial => 'people/profile_sidebar', :locals => {:person => @person, :contact => @contact } + -# here be JS .span-18.last .profile_header - -# = render 'people/sub_header', :person => @person, :contact => @contact + -# more JS .stream_container #main_stream.stream - -# - if @block.present? - .dull - = t('.ignoring', :name => @person.first_name) + -# JS #paginate diff --git a/spec/models/user/querying_spec.rb b/spec/models/user/querying_spec.rb index 8a3eecee0..9d8a0ff14 100644 --- a/spec/models/user/querying_spec.rb +++ b/spec/models/user/querying_spec.rb @@ -307,6 +307,20 @@ describe User::Querying, :type => :model do end end + describe "#block_for" do + let(:person) { FactoryGirl.create :person } + + before do + eve.blocks.create({person: person}) + end + + it 'returns the block' do + block = eve.block_for(person) + expect(block).to be_present + expect(block.person.id).to be person.id + end + end + describe '#posts_from' do before do @user3 = FactoryGirl.create(:user) diff --git a/spec/presenters/person_presenter_spec.rb b/spec/presenters/person_presenter_spec.rb index 6010da5d5..97f01887c 100644 --- a/spec/presenters/person_presenter_spec.rb +++ b/spec/presenters/person_presenter_spec.rb @@ -7,7 +7,7 @@ describe PersonPresenter do describe "#as_json" do context "with no current_user" do it "returns the user's public information if a user is not logged in" do - expect(PersonPresenter.new(person, nil).as_json).to include(person.as_api_response(:backbone).reject { |k,v| k == :avatar }) + expect(PersonPresenter.new(person, nil).as_json).to include(person.as_api_response(:backbone).except(:avatar)) end end @@ -32,10 +32,10 @@ describe PersonPresenter do describe "#full_hash" do let(:current_user) { FactoryGirl.create(:user) } - let(:m_contact) { double(:id => 1, :mutual? => true, :sharing? => true, :receiving? => true ) } - let(:r_contact) { double(:id => 1, :mutual? => false, :sharing? => false, :receiving? => true) } - let(:s_contact) { double(:id => 1, :mutual? => false, :sharing? => true, :receiving? => false) } - let(:n_contact) { double(:id => 1, :mutual? => false, :sharing? => false, :receiving? => false) } + let(:mutual_contact) { double(:id => 1, :mutual? => true, :sharing? => true, :receiving? => true ) } + let(:receiving_contact) { double(:id => 1, :mutual? => false, :sharing? => false, :receiving? => true) } + let(:sharing_contact) { double(:id => 1, :mutual? => false, :sharing? => true, :receiving? => false) } + let(:non_contact) { double(:id => 1, :mutual? => false, :sharing? => false, :receiving? => false) } before do @p = PersonPresenter.new(person, current_user) @@ -44,27 +44,27 @@ describe PersonPresenter do context "relationship" do it "is blocked?" do allow(current_user).to receive(:block_for) { double(id: 1) } - allow(current_user).to receive(:contact_for) { n_contact } + allow(current_user).to receive(:contact_for) { non_contact } expect(@p.full_hash[:relationship]).to be(:blocked) end it "is mutual?" do - allow(current_user).to receive(:contact_for) { m_contact } + allow(current_user).to receive(:contact_for) { mutual_contact } expect(@p.full_hash[:relationship]).to be(:mutual) end it "is receiving?" do - allow(current_user).to receive(:contact_for) { r_contact } + allow(current_user).to receive(:contact_for) { receiving_contact } expect(@p.full_hash[:relationship]).to be(:receiving) end it "is sharing?" do - allow(current_user).to receive(:contact_for) { s_contact } + allow(current_user).to receive(:contact_for) { sharing_contact } expect(@p.full_hash[:relationship]).to be(:sharing) end it "isn't sharing?" do - allow(current_user).to receive(:contact_for) { n_contact } + allow(current_user).to receive(:contact_for) { non_contact } expect(@p.full_hash[:relationship]).to be(:not_sharing) end end