rspec should now be running a green build

This commit is contained in:
Florian Staudacher 2014-09-11 19:44:07 +02:00
parent 89d468cdcc
commit be86014540
10 changed files with 47 additions and 41 deletions

View file

@ -1,8 +1,6 @@
app.models.Person = Backbone.Model.extend({ app.models.Person = Backbone.Model.extend({
urlRoot: '/people',
url: function() { url: function() {
return this.urlRoot + '/' + this.get('guid'); return Routes.person_path(this.get('guid'));
}, },
initialize: function() { initialize: function() {

View file

@ -1,7 +1,7 @@
<div id="profile_photo" class="profile_photo"> <div id="profile_photo" class="profile_photo">
{{#linkToPerson this}} {{#linkToPerson this}}
{{{personImage this "l"}}} {{{personImage this "large"}}}
{{/linkToPerson}} {{/linkToPerson}}
</div> </div>
@ -74,7 +74,7 @@
</h4> </h4>
<div class="section photo_pictures"> <div class="section photo_pictures">
{{#each photos.items}} {{#each photos.items}}
<img src="{{sizes.s}}" alt="{{guid}}" /> <img src="{{sizes.small}}" alt="{{guid}}" />
{{/each}} {{/each}}
</div> </div>
<p class="see_all"> <p class="see_all">
@ -90,7 +90,7 @@
</h4> </h4>
<div class="section contact_pictures"> <div class="section contact_pictures">
{{#each contacts.items}} {{#each contacts.items}}
{{#linkToPerson this}}{{{personImage this "s"}}}{{/linkToPerson}} {{#linkToPerson this}}{{{personImage this "small"}}}{{/linkToPerson}}
{{/each}} {{/each}}
</div> </div>
<p class="see_all"> <p class="see_all">

View file

@ -65,6 +65,6 @@ LISTITEM
return {} return {}
end end
{ aspects: aspects, aspect: aspect, aspect_ids: aspect_ids } { selected_aspects: aspects, aspect: aspect, aspect_ids: aspect_ids }
end end
end end

View file

@ -106,7 +106,7 @@ module User::Querying
def block_for(person) def block_for(person)
return nil unless person return nil unless person
self.blocks.where(person_id: person.id).limit(1).first self.blocks.where(person_id: person.id).first
end end
def aspects_with_shareable(base_class_name_or_class, shareable_id) def aspects_with_shareable(base_class_name_or_class, shareable_id)

View file

@ -4,9 +4,9 @@ class AvatarPresenter < BasePresenter
DEFAULT_IMAGE = ActionController::Base.helpers.image_path('user/default.png') DEFAULT_IMAGE = ActionController::Base.helpers.image_path('user/default.png')
def base_hash def base_hash
{ s: image_url_small || DEFAULT_IMAGE, { small: image_url_small || DEFAULT_IMAGE,
m: image_url_medium || DEFAULT_IMAGE, medium: image_url_medium || DEFAULT_IMAGE,
l: image_url || DEFAULT_IMAGE large: image_url || DEFAULT_IMAGE
} }
end end
end end

View file

@ -46,18 +46,14 @@ class PersonPresenter < BasePresenter
def relationship def relationship
return false unless current_user return false unless current_user
return :blocked if is_blocked?
contact = current_user_person_contact contact = current_user_person_contact
return :not_sharing unless contact
is_mutual = contact ? contact.mutual? : false [:mutual, :sharing, :receiving].find do |status|
is_sharing = contact ? contact.sharing? : false contact.public_send("#{status}?")
is_receiving = contact ? contact.receiving? : false end || :not_sharing
if is_blocked? then :blocked
elsif is_mutual then :mutual
elsif is_sharing then :sharing
elsif is_receiving then :receiving
else :not_sharing
end
end end
def person_is_following_current_user def person_is_following_current_user

View file

@ -3,13 +3,13 @@ class PhotoPresenter < BasePresenter
{ id: id, { id: id,
guid: guid, guid: guid,
dimensions: { dimensions: {
h: height, height: height,
w: width width: width
}, },
sizes: { sizes: {
s: url(:thumb_small), small: url(:thumb_small),
m: url(:thumb_medium), medium: url(:thumb_medium),
l: url(:scaled_full) large: url(:scaled_full)
} }
} }
end end

View file

@ -13,18 +13,16 @@
.span-6 .span-6
#profile #profile
-# = render :partial => 'people/profile_sidebar', :locals => {:person => @person, :contact => @contact } -# here be JS
.span-18.last .span-18.last
.profile_header .profile_header
-# = render 'people/sub_header', :person => @person, :contact => @contact -# more JS
.stream_container .stream_container
#main_stream.stream #main_stream.stream
-# - if @block.present? -# JS
.dull
= t('.ignoring', :name => @person.first_name)
#paginate #paginate

View file

@ -307,6 +307,20 @@ describe User::Querying, :type => :model do
end end
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 describe '#posts_from' do
before do before do
@user3 = FactoryGirl.create(:user) @user3 = FactoryGirl.create(:user)

View file

@ -7,7 +7,7 @@ describe PersonPresenter do
describe "#as_json" do describe "#as_json" do
context "with no current_user" do context "with no current_user" do
it "returns the user's public information if a user is not logged in" 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
end end
@ -32,10 +32,10 @@ describe PersonPresenter do
describe "#full_hash" do describe "#full_hash" do
let(:current_user) { FactoryGirl.create(:user) } let(:current_user) { FactoryGirl.create(:user) }
let(:m_contact) { double(:id => 1, :mutual? => true, :sharing? => true, :receiving? => true ) } let(:mutual_contact) { double(:id => 1, :mutual? => true, :sharing? => true, :receiving? => true ) }
let(:r_contact) { double(:id => 1, :mutual? => false, :sharing? => false, :receiving? => true) } let(:receiving_contact) { double(:id => 1, :mutual? => false, :sharing? => false, :receiving? => true) }
let(:s_contact) { double(:id => 1, :mutual? => false, :sharing? => true, :receiving? => false) } let(:sharing_contact) { double(:id => 1, :mutual? => false, :sharing? => true, :receiving? => false) }
let(:n_contact) { double(:id => 1, :mutual? => false, :sharing? => false, :receiving? => false) } let(:non_contact) { double(:id => 1, :mutual? => false, :sharing? => false, :receiving? => false) }
before do before do
@p = PersonPresenter.new(person, current_user) @p = PersonPresenter.new(person, current_user)
@ -44,27 +44,27 @@ describe PersonPresenter do
context "relationship" do context "relationship" do
it "is blocked?" do it "is blocked?" do
allow(current_user).to receive(:block_for) { double(id: 1) } 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) expect(@p.full_hash[:relationship]).to be(:blocked)
end end
it "is mutual?" do 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) expect(@p.full_hash[:relationship]).to be(:mutual)
end end
it "is receiving?" do 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) expect(@p.full_hash[:relationship]).to be(:receiving)
end end
it "is sharing?" do 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) expect(@p.full_hash[:relationship]).to be(:sharing)
end end
it "isn't sharing?" do 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) expect(@p.full_hash[:relationship]).to be(:not_sharing)
end end
end end