<commit_before>require 'rails_helper'

describe ExperimentsController do
  let(:experiment) { Experiment.create( title: "this is the title",
                                        summary: "this is the summary",
                                        abstract: "this is the abstract",
                                        introduction: "this is the introduction",
                                        hypothesis: "this is the hypothesis",
                                        methods: "these are the methods",
                                        observations: "these are the observations",
                                        results: "these are the results",
                                        conclusion: "this is the conclusion",
                                        staff_needed: 2,
                                        contact_info: "this is the contact info" )}
  let(:user) { User.create( name: "Geraldine",
                            email: "<EMAIL>",
                            password: "<PASSWORD>",
                            role: "staff"
    )}

  describe 'GET #index for a logged user' do
    before(:each){ session[:user_id] = user.id }

    it 'assigns all the experiments as @experiments' do
      get :index
      expect(assigns(:experiments)).to eq Experiment.all
    end

    it 'renders a list of articles' do
      expect(get :index).to render_template(:index)
    end
  end

  xdescribe 'GET #show' do
    it 'responds with status code 200' do
      get :show, params: { id: experiment.id }
      expect(response).to have_http_status 200
    end

    it 'assigns the correct experiment as @experiment' do
      get :show, params: { id: experiment.id }
      expect(assigns(:experiment)).to eq(experiment)
    end

    it 'renders the :show template' do
      get :show, params: { id: experiment.id }
      expect(response).to render_template(:show)
    end
  end

end<commit_msg>Make GET experiments#show tests work for a logged user<commit_after>require 'rails_helper'

describe ExperimentsController do
  let(:experiment) { Experiment.create( title: "this is the title",
                                        summary: "this is the summary",
                                        abstract: "this is the abstract",
                                        introduction: "this is the introduction",
                                        hypothesis: "this is the hypothesis",
                                        methods: "these are the methods",
                                        observations: "these are the observations",
                                        results: "these are the results",
                                        conclusion: "this is the conclusion",
                                        staff_needed: 2,
                                        contact_info: "this is the contact info" )}
  let(:user) { User.create( name: "Geraldine",
                            email: "<EMAIL>",
                            password: "<PASSWORD>",
                            role: "staff"
    )}

  describe 'GET #index for a logged user' do
    before(:each){ session[:user_id] = user.id }

    it 'assigns all the experiments as @experiments' do
      get :index
      expect(assigns(:experiments)).to eq Experiment.all
    end

    it 'renders a list of articles' do
      expect(get :index).to render_template(:index)
    end
  end

  describe 'GET #show for a logged user' do
    before(:each){ session[:user_id] = user.id }

    it 'responds with status code 200' do
      get :show, params: { id: experiment.id }
      expect(response).to have_http_status 200
    end

    it 'assigns the correct experiment as @experiment' do
      get :show, params: { id: experiment.id }
      expect(assigns(:experiment)).to eq(experiment)
    end

    it 'renders the :show template' do
      get :show, params: { id: experiment.id }
      expect(response).to render_template(:show)
    end
  end

end
{'fraction_non_alphanumeric': 0.08463083877448518, 'fraction_numerical': 0.0035158211953792064, 'mean_word_length': 1.489375, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 20, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3825670', 'n_tokens_mistral': 945, 'n_tokens_neox': 894, 'n_words': 332}