Skip to content
Extraits de code Groupes Projets
contacts_controller_spec.rb 1,76 ko
Newer Older
  • Learn to ignore specific revisions
  • #   Copyright (c) 2010, Diaspora Inc.  This file is
    #   licensed under the Affero General Public License version 3 or later.  See
    #   the COPYRIGHT file.
    
    require 'spec_helper'
    
    describe ContactsController do
      before do
    
        sign_in :user, bob
        @controller.stub(:current_user).and_return(bob)
    
      describe '#sharing' do
        it "succeeds" do
          get :sharing
          response.should be_success
        end
    
    
        it 'eager loads the aspects' do
          get :sharing
    
          assigns[:contacts].first.aspect_memberships.loaded?.should be_true
    
        it "assigns only the people sharing with you with 'share_with' flag" do
          get :sharing, :id => 'share_with'
    
          assigns[:contacts].to_set.should == bob.contacts.sharing.to_set
    
    Raphael Sofaer's avatar
    Raphael Sofaer a validé
    
      describe '#index' do
        it "succeeds" do
          get :index
          response.should be_success
        end
    
        it "assigns aspect to manage" do
          get :index
          assigns(:aspect).should == :manage
        end
    
        it "assigns contacts" do
          get :index
          contacts = assigns(:contacts)
    
          contacts.to_set.should == bob.contacts.to_set
        end
    
        it "shows only contacts a user is sharing with" do
          contact = bob.contacts.first
          contact.update_attributes(:sharing => false)
    
          get :index, :set => "mine"
          contacts = assigns(:contacts)
    
          contacts.to_set.should == bob.contacts.receiving.to_set
    
        end
    
        it "shows all contacts (sharing and receiving)" do
          contact = bob.contacts.first
          contact.update_attributes(:sharing => false)
    
          get :index, :set => "all"
          contacts = assigns(:contacts)
          contacts.to_set.should == bob.contacts.to_set
    
    Raphael Sofaer's avatar
    Raphael Sofaer a validé
        end
    
        it "generates a jasmine fixture", :fixture => 'jasmine' do
          get :index
          save_fixture(html_for("body"), "aspects_manage")
        end
      end