<commit_before>require 'spec_helper'

describe GroupsController do
  let(:user) { users(:owner) }
  let (:a_group) { groups(:group) }

  before do
    log_in user
  end

  describe '#index' do
    before :each do
      get :index
    end

    it_behaves_like "an action that requires authentication", :get, :index

    it "succeeds" do
      response.code.should == "200"
    end

    it "returns a list of roles" do
      response.decoded_body.length.should == Group.count
    end
  end

  describe '#create' do
    let (:params) {
      {
          :name => "new_group",
          :description => "here's that new group you're always talking about"
      }
    }
    before :each do
      post :create, params
    end

    it_behaves_like "an action that requires authentication", :post, :create

    it "should create a role" do
      Group.find_by_name(params[:name]).should be_present
    end
  end

  describe '#new' do
  end

  describe '#edit' do
  end

  describe '#show' do

    it "succeeds when the role exists" do
      get :show, :id => a_group.id
      response.should be_success
    end

    it "finds the right role" do
      get :show, :id => a_group.id
      response.decoded_body.id.should == a_group.id
      response.decoded_body.name.should == a_group.name
      response.decoded_body.description.should == a_group.description
    end

    it "fails when the role doesn't exist" do
      get :show, :id => 'garbage_id'
      response.should be_not_found
    end
  end

  describe '#update' do
    let (:old_params ){
      {
          :id => a_group.id,
          :name => a_group.name,
          :description => a_group.description
      }
    }

    let (:new_params) {
      {
          :name => 'different name',
          :description => 'different description'
      }
    }

    it "updates the correct attributes" do
      put :update, old_params.merge(:group => new_params)
      response.decoded_body.name.should == new_params[:name]
      response.decoded_body.description.should == new_params[:description]
    end
  end

  describe '#destroy' do
    let (:new_group) { FactoryGirl.create(:group, :name => "destory me!") }

    it "destroys the role given the proepr id" do
      old_count = Role.count
      new_group

      Group.count.should == old_count + 1
      delete :destroy, { :id => new_group.id }
      Group.count.should == old_count
    end
  end
end
<commit_msg>fixed some typos in the groups_controller_spec<commit_after>require 'spec_helper'

describe GroupsController do
  let(:user) { users(:owner) }
  let (:a_group) { groups(:group) }

  before do
    log_in user
  end

  describe '#index' do
    before :each do
      get :index
    end

    it_behaves_like "an action that requires authentication", :get, :index

    it "succeeds" do
      response.code.should == "200"
    end

    it "returns a list of groups" do
      response.decoded_body.length.should == Group.count
    end
  end

  describe '#create' do
    let (:params) {
      {
          :name => "new_group",
          :description => "here's that new group you're always talking about"
      }
    }
    before :each do
      post :create, params
    end

    it_behaves_like "an action that requires authentication", :post, :create

    it "should create a group" do
      Group.find_by_name(params[:name]).should be_present
    end
  end

  describe '#new' do
  end

  describe '#edit' do
  end

  describe '#show' do

    it "succeeds when the group exists" do
      get :show, :id => a_group.id
      response.should be_success
    end

    it "finds the right group" do
      get :show, :id => a_group.id
      response.decoded_body.id.should == a_group.id
      response.decoded_body.name.should == a_group.name
      response.decoded_body.description.should == a_group.description
    end

    it "fails when the group doesn't exist" do
      get :show, :id => 'garbage_id'
      response.should be_not_found
    end
  end

  describe '#update' do
    let (:old_params ){
      {
          :id => a_group.id,
          :name => a_group.name,
          :description => a_group.description
      }
    }

    let (:new_params) {
      {
          :name => 'different name',
          :description => 'different description'
      }
    }

    it "updates the correct attributes" do
      put :update, old_params.merge(:group => new_params)
      response.decoded_body.name.should == new_params[:name]
      response.decoded_body.description.should == new_params[:description]
    end
  end

  describe '#destroy' do
    let (:new_group) { FactoryGirl.create(:group, :name => "destory me!") }

    it "destroys the group given the proper id" do
      old_count = Group.count
      new_group

      Group.count.should == old_count + 1
      delete :destroy, { :id => new_group.id }
      Group.count.should == old_count
    end
  end
end

{'fraction_non_alphanumeric': 0.10361842105263158, 'fraction_numerical': 0.001644736842105263, 'mean_word_length': 2.41164095371669, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 29, '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': '5552363', 'n_tokens_mistral': 1581, 'n_tokens_neox': 1500, 'n_words': 437}