<commit_before>require 'spec_helper'

describe Api::V1::Users::ProjectsController do
  let(:user) {User.make(:dora)}

  before(:each) do
    @request.env["HTTP_ACCEPT"] = "application/xml"
  end

  describe "a GET to index" do
    def perform_request
      get :index, :user_id => user.login
    end


    context "with valid parameters" do
      it "returns a status code of '200 OK'" do
        perform_request
        response.status.should == "200 OK"
      end

      it "returns an XML representation of a Payload" do
        perform_request
        response.should render_template('api/v1/projects/index.xml.haml')
      end


      it "loads all the specified user's public projects" do
        public_projects = 2.times.map {Project.make(:owner => user, :visibility => 'public')}
        Project.make(:owner => user, :visibility => 'private')
        Project.make # extra project not owned by user...testing scoping
        user.projects.private.should_not be_empty #confirm test setup
        perform_request
        assigns[:projects].should == public_projects
      end
    end
  end
end
<commit_msg>Fixed spec require, resolving rcov calc issue.<commit_after>require File.expand_path(File.dirname(__FILE__) + '/../../../../spec_helper')

describe Api::V1::Users::ProjectsController do
  let(:user) {User.make(:dora)}

  before(:each) do
    @request.env["HTTP_ACCEPT"] = "application/xml"
  end

  describe "a GET to index" do
    def perform_request
      get :index, :user_id => user.login
    end


    context "with valid parameters" do
      it "returns a status code of '200 OK'" do
        perform_request
        response.status.should == "200 OK"
      end

      it "returns an XML representation of a Payload" do
        perform_request
        response.should render_template('api/v1/projects/index.xml.haml')
      end


      it "loads all the specified user's public projects" do
        public_projects = 2.times.map {Project.make(:owner => user, :visibility => 'public')}
        Project.make(:owner => user, :visibility => 'private')
        Project.make # extra project not owned by user...testing scoping
        user.projects.private.should_not be_empty #confirm test setup
        perform_request
        assigns[:projects].should == public_projects
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.10635538261997406, 'fraction_numerical': 0.007782101167315175, 'mean_word_length': 2.824793388429752, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '4624408', 'n_tokens_mistral': 679, 'n_tokens_neox': 649, 'n_words': 199}