Sha256: 1745aad07031409bfec6c5812ac140331a60e872bed097ffb299ab610bc1cdf3

Contents?: true

Size: 1.77 KB

Versions: 231

Compression:

Stored size: 1.77 KB

Contents

require '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, :contact => Factory(:group_contact, :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, :contact => Factory(:group_contact, :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

231 entries across 231 versions & 4 rubygems

Version Path
social_stream-2.2.2 base/spec/controllers/representations_spec.rb
social_stream-base-2.2.2 spec/controllers/representations_spec.rb
social_stream-2.2.1 base/spec/controllers/representations_spec.rb
social_stream-base-2.2.1 spec/controllers/representations_spec.rb
social_stream-2.2.0 base/spec/controllers/representations_spec.rb
social_stream-base-2.2.0 spec/controllers/representations_spec.rb
social_stream-2.1.1 base/spec/controllers/representations_spec.rb
social_stream-1.1.12 base/spec/controllers/representations_spec.rb
social_stream-base-1.1.11 spec/controllers/representations_spec.rb
social_stream-2.1.0 base/spec/controllers/representations_spec.rb
social_stream-base-2.1.0 spec/controllers/representations_spec.rb
social_stream-2.0.4 base/spec/controllers/representations_spec.rb
social_stream-base-2.0.4 spec/controllers/representations_spec.rb
social_stream-2.0.3 base/spec/controllers/representations_spec.rb
social_stream-base-2.0.3 spec/controllers/representations_spec.rb
social_stream-1.1.11 base/spec/controllers/representations_spec.rb
social_stream-base-1.1.10 spec/controllers/representations_spec.rb
social_stream-1.1.10 base/spec/controllers/representations_spec.rb
social_stream-base-1.1.9 spec/controllers/representations_spec.rb
social_stream-1.1.9 base/spec/controllers/representations_spec.rb