Sha256: de20238885ef8f43901d20d10c0bb645c2ffea0c1b2cc1429a6d6c45c39529d0

Contents?: true

Size: 1.75 KB

Versions: 5

Compression:

Stored size: 1.75 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe HomeController do
  include ActionController::RecordIdentifier
  include SocialStream::TestHelpers

  render_views

  describe "create" do
    context "with logged user" do
      before do
        @user = Factory(:user)
        sign_in @user
      end

      context "to represent herself" do
        it "should redirect_to root" do
          get :index, :s => @user.slug

          assigns(:current_subject).should == @user
          response.should be_success
        end
      end

      context "to represent own group" do
        before do
          @group = Factory(:member, :receiver => @user.actor).sender_subject
        end

        it "should redirect_to root" do
          get :index, :s => @group.slug

          assigns(:current_subject).should == @group
          response.should be_success
        end
      end

      context "representing own group" do
        before do
          @group = Factory(:member, :receiver => @user.actor).sender_subject
          represent @group
        end

        context "to represent herself" do
          it "should redirect_to root" do
            get :index, :s => @user.slug

            assigns(:current_subject).should == @user
            response.should be_success
          end
        end
      end

      context "to represent other group" do
        before do
          @group = Factory(:group)
        end

        it "should deny access" do
          begin
            get :index, :s => @group.slug

            assert false
          rescue ActionView::Template::Error => e
            assert e.message == "Not authorized!"
          rescue CanCan::AccessDenied
            assert true
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
social_stream-base-0.5.2 spec/controllers/representations_spec.rb
social_stream-base-0.5.1 spec/controllers/representations_spec.rb
social_stream-base-0.5.0 spec/controllers/representations_spec.rb
social_stream-0.4.6 spec/controllers/representations_spec.rb
social_stream-0.4.5 spec/controllers/representations_spec.rb