Skip to content
Extraits de code Groupes Projets
application_helper_spec.rb 2,16 ko
Newer Older
  • Learn to ignore specific revisions
  • Raphael's avatar
    Raphael a validé
    #   Copyright (c) 2010, Diaspora Inc.  This file is
    
    Raphael's avatar
    Raphael a validé
    #   licensed under the Affero General Public License version 3 or later.  See
    
    Raphael's avatar
    Raphael a validé
    #   the COPYRIGHT file.
    
    require 'spec_helper'
    
    
    describe ApplicationHelper do
      before do
    
      describe "#object_path" do
        it "returns an empty string if object is nil" do
          object_path(nil).should == ""
        end
        it "returns person path if it's a person" do
          object_path(@person).should == person_path(@person)
        end
        it "returns person path if it's a user" do
          object_path(@user).should == person_path(@user.person)
        end
      end
    
      describe "#person_image_link" do
        it "returns an empty string if person is nil" do
          person_image_link(nil).should == ""
        end
        it "returns a link containing the person's photo" do
    
    Raphael's avatar
    Raphael a validé
          person_image_link(@person).should include(@person.profile.image_url)
    
        end
        it "returns a link to the person's profile" do
    
    danielvincent's avatar
    danielvincent a validé
          person_image_link(@person).should include(person_path(@person))
    
      describe "#person_image_tag" do
        it "should not allow basic XSS/HTML" do
          @person.profile.first_name = "I'm <h1>Evil"
          @person.profile.last_name = "I'm <h1>Evil"
          person_image_tag(@person).should_not include("<h1>")
        end
      end
    
      describe '#person_link' do
        before do
        @person = Factory(:person)
    
        it 'includes the name of the person if they have a first name' do
          person_link(@person).should include @person.profile.first_name
    
        it 'uses diaspora handle if the person has no first or last name' do
          @person.profile.first_name = nil
          @person.profile.last_name = nil
    
          person_link(@person).should include @person.diaspora_handle
    
        it 'uses diaspora handle if first name and first name are rails#blank?' do
          @person.profile.first_name = " "
          @person.profile.last_name = " "
    
          person_link(@person).should include @person.diaspora_handle
    
        it "should not allow basic XSS/HTML" do
          @person.profile.first_name = "I'm <h1>Evil"
          @person.profile.last_name = "I'm <h1>Evil"
          person_link(@person).should_not include("<h1>")
    
    Raphael's avatar
    Raphael a validé
        end