<commit_before>require 'spec_helper'

describe UpdatesController do
  let(:update){ Factory(:update) }
  let(:user){ update.project.user }
  subject{ response }

  shared_examples_for "READ updates" do
    describe "GET index" do
      before{ get :index, :project_id => update.project.id, :locale => 'pt', :format => 'html' }
      its(:status){ should == 200 }
    end
  end

  shared_examples_for "DELETE updates" do |status = 200|
    describe "DELETE destroy" do
      before { delete :destroy, :project_id => update.project.id, :id => update.id, :locale => 'pt' }
      its(:status) { should == status}
    end
  end

  shared_examples_for "CREATE updates" do |total_updates = 0|
    describe "POST create" do
      before{ post :create, :project_id => update.project.id, :locale => 'pt', :update => {:title => 'title', :comment => 'update comment'} }
      it{ Update.where(:user_id => user.id, :project_id => update.project.id).count.should == total_updates }
    end
  end

  context 'When user is admin' do
    let(:user) { Factory(:user, admin: true) }
    before{ request.session[:user_id] = user.id }

    it_should_behave_like "READ updates"

    it_should_behave_like "DELETE updates"

    it_should_behave_like "CREATE updates", 1
  end

  context 'When user is a guest' do
    it_should_behave_like "READ updates"

    it_should_behave_like "DELETE updates", 302

    it_should_behave_like "CREATE updates"
  end

  context 'When user is project_owner' do
    before{ request.session[:user_id] = user.id }

    it_should_behave_like "READ updates"

    it_should_behave_like "DELETE updates"

    it_should_behave_like "CREATE updates", 1
  end

  context "When user is a registered user but don't the project owner" do
    before{ request.session[:user_id] = Factory(:user).id }

    it_should_behave_like "READ updates"

    it_should_behave_like "DELETE updates", 302

    it_should_behave_like "CREATE updates", 0
  end

end<commit_msg>just removed some unecessary lines from the updates_controller_spec<commit_after>require 'spec_helper'

describe UpdatesController do
  let(:update){ Factory(:update) }
  let(:user){ update.project.user }
  subject{ response }

  shared_examples_for "GET index" do
    before{ get :index, :project_id => update.project.id, :locale => 'pt', :format => 'html' }
    its(:status){ should == 200 }
  end

  shared_examples_for "DELETE destroy" do |status = 200|
    before { delete :destroy, :project_id => update.project.id, :id => update.id, :locale => 'pt' }
    its(:status) { should == status}
  end

  shared_examples_for "POST create" do |total_updates = 0|
    before{ post :create, :project_id => update.project.id, :locale => 'pt', :update => {:title => 'title', :comment => 'update comment'} }
    it{ Update.where(:user_id => user.id, :project_id => update.project.id).count.should == total_updates }
  end

  context 'When user is admin' do
    let(:user) { Factory(:user, admin: true) }
    before{ request.session[:user_id] = user.id }

    it_should_behave_like "GET index"

    it_should_behave_like "DELETE destroy"

    it_should_behave_like "POST create", 1
  end

  context 'When user is a guest' do
    it_should_behave_like "GET index"

    it_should_behave_like "DELETE destroy", 302

    it_should_behave_like "POST create"
  end

  context 'When user is project_owner' do
    before{ request.session[:user_id] = user.id }

    it_should_behave_like "GET index"

    it_should_behave_like "DELETE destroy"

    it_should_behave_like "POST create", 1
  end

  context "When user is a registered user but don't the project owner" do
    before{ request.session[:user_id] = Factory(:user).id }

    it_should_behave_like "GET index"

    it_should_behave_like "DELETE destroy", 302

    it_should_behave_like "POST create", 0
  end

end
{'fraction_non_alphanumeric': 0.11440566780372606, 'fraction_numerical': 0.00839674626082393, 'mean_word_length': 3.86845466155811, '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': '242275', 'n_tokens_mistral': 1287, 'n_tokens_neox': 1206, 'n_words': 349}