<commit_before>require 'spec_helper'

describe Projects::Challenges::MatchesController do
  let(:project) { create(:project, state: :online, online_date: Date.current, online_days: 30) }
  let(:user)    { create(:user) }
  let(:create_params) do
    {
      "projects_challenges_match" => {
        "value"         => "3",
        "starts_at"     => Date.tomorrow.to_time.strftime('%m/%d/%y'),
        "finishes_at"   => (Date.tomorrow + 2.days).to_time.strftime('%m/%d/%y'),
        "maximum_value" => "9999"
      }
    }
  end

  context 'signed in' do
    before { sign_in(user) }

    describe 'GET \'new\'' do
      it 'assigns match variable' do
        get :new, project_id: project.to_param
        expect(assigns(:match)).to_not be_nil
      end

      it 'renders match template' do
        get :new, project_id: project.to_param
        expect(response).to render_template('projects/challenges/matches/new')
      end
    end

    describe 'POST \'create\'' do
      it 'creates a new match' do
        expect {
          post :create, create_params.merge(project_id: project.to_param)
        }.to change(Projects::Challenges::Match, :count).by(1)
      end

      it 'redirects to project page' do
        post :create, create_params.merge(project_id: project.to_param)
        expect(response).to redirect_to(project)
      end
    end
  end

  context 'unsigned in' do
    describe 'GET \'new\'' do
      it 'asks for user to login' do
        get :new, project_id: project.to_param
        expect(response).to redirect_to(new_user_session_path)
      end
    end

    describe 'POST \'create\'' do
      it 'asks for user to login' do
        post :create, create_params.merge(project_id: project.to_param)
        expect(response).to redirect_to(new_user_session_path)
      end
    end
  end
end
<commit_msg>Prefer single quotes over quotes when using string literal<commit_after>require 'spec_helper'

describe Projects::Challenges::MatchesController do
  let(:project) { create(:project, state: :online, online_date: Date.current, online_days: 30) }
  let(:user)    { create(:user) }
  let(:create_params) do
    {
      'projects_challenges_match' => {
        'value'         => '3',
        'starts_at'     => Date.tomorrow.to_time.strftime('%m/%d/%y'),
        'finishes_at'   => (Date.tomorrow + 2.days).to_time.strftime('%m/%d/%y'),
        'maximum_value' => '9999'
      }
    }
  end

  context 'signed in' do
    before { sign_in(user) }

    describe 'GET \'new\'' do
      it 'assigns match variable' do
        get :new, project_id: project.to_param
        expect(assigns(:match)).to_not be_nil
      end

      it 'renders match template' do
        get :new, project_id: project.to_param
        expect(response).to render_template('projects/challenges/matches/new')
      end
    end

    describe 'POST \'create\'' do
      it 'creates a new match' do
        expect {
          post :create, create_params.merge(project_id: project.to_param)
        }.to change(Projects::Challenges::Match, :count).by(1)
      end

      it 'redirects to project page' do
        post :create, create_params.merge(project_id: project.to_param)
        expect(response).to redirect_to(project)
      end
    end
  end

  context 'unsigned in' do
    describe 'GET \'new\'' do
      it 'asks for user to login' do
        get :new, project_id: project.to_param
        expect(response).to redirect_to(new_user_session_path)
      end
    end

    describe 'POST \'create\'' do
      it 'asks for user to login' do
        post :create, create_params.merge(project_id: project.to_param)
        expect(response).to redirect_to(new_user_session_path)
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.11732900783995674, 'fraction_numerical': 0.004866180048661801, 'mean_word_length': 2.6381514257620453, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '2560215', 'n_tokens_mistral': 1234, 'n_tokens_neox': 1172, 'n_words': 290}