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

describe ProfilesController do
  integrate_views
  include CMS::AuthenticationTestHelper
  fixtures :users , :spaces
  
  def mock_profile(stubs={})
    @mock_profile ||= mock_model(Profile, stubs)
  end
  
  
  describe "responding to GET show" do

    describe "when you are logged in" do
      describe "as SuperAdmin" do
        before(:each) do
          login_as(:user_admin)
        end
        describe "in a private space" do
          before(:each) do
            @space = spaces(:private_no_roles)
            @user = users(:user_normal2)
          end
          
          it "should let the user to see the user's profile of this space" do
            get :show, :user_id => @user.id
            assert_response 200
          end
          
          it "should redirect to the associated user's profile view " do
            get :show , :user_id => @user.id
            response.should render_template("show")
          end
          
        end
        
        describe "in the public space" do
          before(:each) do
            @space = spaces(:public)
            @user = users(:user_normal2)
          end
          
          it "should NOT let the user to see the user's profile of a user of this space" do
            get :show, :user_id => @user.id
            assert_response 200
          end
          
          it "should redirect to the associated user view" do
            get :show, :user_id => @user.id
            response.should render_template("show")
          end    
        end
    
      end
      describe "as normal_user" do
        before(:each) do
          login_as(:user_normal)
        end
        describe "in a private space where the user has the role Admin " do
          before(:each) do
            @space = spaces(:private_admin)
            @user = users(:user_normal2)
          end
          
          it "should NOT let the user to see the user's profile of a user of this space" do
            get :show , :user_id => @user.id
            assert_response 403
          end
          
        end
        
        describe "in a private space where the user has the role User" do
          before(:each) do
            @space = spaces(:private_user)
            @user = users(:user_normal2)
          end
          
          it "should NOT let the user to see the user's profile of a user of this space" do
            get :show, :user_id => @user.id
            assert_response 403
          end
          
        end
        describe "in a private space where the user has the role Invited " do
          before(:each) do
            @space = spaces(:private_invited)
            @user = users(:user_normal2)
          end
          
          it "should NOT let the user to see the user's profile of a user of this space" do
            get :show, :user_id => @user.id
            assert_response 403
          end
          
        end
        
        describe "in a private space where the user has not any roles" do
          before(:each) do
            @space = spaces(:private_no_roles)
            @user = users(:user_normal2)
          end
          
          it "should NOT let the user to see the user's profile of a user of this space" do
            get :show , :user_id => @user.id
            assert_response 403
          end       
        end
        
        describe "without space" do
          before(:each) do
            @user = users(:user_normal2)
          end
          
          it "should NOT let the user to see the user's profile of a user of this space" do
            get :show, :user_id => @user.id
            assert_response 403
          end     
        end
        
        
        describe "in the public space" do
          
          before(:each) do
            @space = spaces(:public)
            @user = users(:user_normal2)
          end
          
          it "should NOT let the user to see the user's profile of a user of this space" do
            get :show, :user_id => @user.id
            assert_response 403
          end   
        end 
      end 
    end
    
    describe "if you are not logged in" do
      describe "in a private space" do<commit_msg>actualizados los test de profiles controller con las descripciones bien escritas en el controlador<commit_after>require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe ProfilesController do
  integrate_views
  include CMS::AuthenticationTestHelper
  fixtures :users , :spaces
  
  def mock_profile(stubs={})
    @mock_profile ||= mock_model(Profile, stubs)
  end
  
  
  describe "responding to GET show" do

    describe "when you are logged in" do
      describe "as SuperAdmin" do
        before(:each) do
          login_as(:user_admin)
        end
        describe "in a private space" do
          before(:each) do
            @space = spaces(:private_no_roles)
            @user = users(:user_normal2)
          end
          
          it "should let the user to see the user's profile of this space" do
            get :show, :user_id => @user.id
            assert_response 200
          end
          
          it "should redirect to the associated user's profile view " do
            get :show , :user_id => @user.id
            response.should render_template("show")
          end
          
        end
        
        describe "in the public space" do
          before(:each) do
            @space = spaces(:public)
            @user = users(:user_normal2)
          end
          
          it "should let the user to see the user's profile of a user of this space" do
            get :show, :user_id => @user.id
            assert_response 200
          end
          
          it "should redirect to the associated user view" do
            get :show, :user_id => @user.id
            response.should render_template("show")
          end    
        end
    
      end
      describe "as normal_user" do
        before(:each) do
          login_as(:user_normal)
        end
        describe "in a private space where the user has the role Admin " do
          before(:each) do
            @space = spaces(:private_admin)
            @user = users(:user_normal2)
          end
          
          it "should let the user to see the user's profile of a user of this space" do
            get :show , :user_id => @user.id
            assert_response 200
          end
          
        end
        
        describe "in a private space where the user has the role User" do
          before(:each) do
            @space = spaces(:private_user)
            @user = users(:user_normal2)
          end
          
          it "should let the user to see the user's profile of a user of this space" do
            get :show, :user_id => @user.id
            assert_response 200
          end
          
        end
        describe "in a private space where the user has the role Invited " do
          before(:each) do
            @space = spaces(:private_invited)
            @user = users(:user_normal2)
          end
          
          it "should let the user to see the user's profile of a user of this space" do
            get :show, :user_id => @user.id
            assert_response 200
          end
          
        end
        
        describe "in a private space where the user has not any roles" do
          before(:each) do
            @space = spaces(:private_no_roles)
            @user = users(:user_normal2)
          end
          
          it "should NOT let the user to see the user's profile of a user of this space" do
            get :show , :user_id => @user.id
            assert_response 403
          end       
        end
               
        describe "in the public space" do
          
          before(:each) do
            @space = spaces(:public)
            @user = users(:user_normal2)
          end
          
          it "should let the user to see the user's profile of a user of this space where the user has roles" do
            get :show, :user_id => @user.id
            assert_response 200
          end   
        end 
      end 
    end
    
    describe "if you are not logged in" do
      describe "in a private space" do
{'fraction_non_alphanumeric': 0.06535632461111782, 'fraction_numerical': 0.007235017484625588, 'mean_word_length': 1.4574814814814814, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7579713', 'n_tokens_mistral': 2211, 'n_tokens_neox': 2136, 'n_words': 835}