<commit_before>require 'rails_helper'

RSpec.describe ReviewsController, type: :controller do
  let!(:review) {Review.create!(title: "awesome movie", content: "This movie was super awesome", photography: 5, directing: 5, cast: 5, score: 5, overall_effect:5)}
  let!(:movie) {Movie.create!(id: 1, title: "Skyfall", director: "<NAME>", release_year: 2012, runtime: 143, mppa_rating: "PG13", cast: "<NAME>, <NAME>, <NAME>, <NAME>")}

  describe 'Get #index' do
    it "assigns all movies as @users" do
      get :index, { :movie_id => 1 }
      expect(assigns(:reviews)).to eq(Review.all)
    end
  end

  describe 'GET #show' do
    it "assigns the requested review as @review" do
      get :show, { movie_id: 1, id: review.to_param }
      expect(assigns(:review)).to eq(review)
    end
  end

  describe 'GET #new' do
    it 'renders the new form' do
      get :new, { :movie_id => 1 }
      expect(response).to render_template :new
    end
  end

  describe 'POST #create' do
    context "when valid params are passed" do

      it 'creates a new review' do
        expect{
          post :create, { movie_id: 1, review: {title: "awesome movie", content: "This movie was super awesome", photography: 5, directing: 5, cast: 5, score: 5, overall_effect:5}
        }}.to change(Review, :count).by(1)
      end

      it 'redirects to the movie page after creation' do
        expect(
          post :create, { movie_id: 1, review: {title: "awesome movie", content: "This movie was super awesome", photography: 5, directing: 5, cast: 5, score: 5, overall_effect:5}
        }).to redirect_to("/movies/#{assigns(:movie).id}")
      end
    end
  end

end<commit_msg>add testing for review controller<commit_after>require 'rails_helper'

RSpec.describe ReviewsController, type: :controller do
  let!(:review) {Review.create!(title: "awesome movie", content: "This movie was super awesome", photography: 5, directing: 5, cast: 5, score: 5, overall_effect:5)}
  let!(:movie) {Movie.create!(id: 1, title: "Skyfall", director: "<NAME>", release_year: 2012, runtime: 143, mppa_rating: "PG13", cast: "<NAME>, <NAME>, <NAME>, <NAME>")}

  describe 'Get #index' do
    it "assigns all movies as @users" do
      get :index, { :movie_id => 1 }
      expect(assigns(:reviews)).to eq(Review.all)
    end
  end

  describe 'GET #show' do
    it "assigns the requested review as @review" do
      get :show, { movie_id: 1, id: review.to_param }
      expect(assigns(:review)).to eq(review)
    end
  end

  describe 'GET #new' do
    it 'renders the new form' do
      get :new, { :movie_id => 1 }
      expect(response).to render_template :new
    end
  end

  describe 'POST #create' do
    context "when valid params are passed" do

      it 'creates a new review' do
        expect{
          post :create, { movie_id: 1, review: {title: "awesome movie", content: "This movie was super awesome", photography: 5, directing: 5, cast: 5, score: 5, overall_effect:5}
        }}.to change(Review, :count).by(1)
      end

      it 'redirects to the movie page after creation' do
        expect(
          post :create, { movie_id: 1, review: {title: "awesome movie", content: "This movie was super awesome", photography: 5, directing: 5, cast: 5, score: 5, overall_effect:5}
        }).to redirect_to("/movies/#{assigns(:movie).id}")
      end
    end
  end


end
{'fraction_non_alphanumeric': 0.13580616212982352, 'fraction_numerical': 0.01854621597367634, 'mean_word_length': 3.33160621761658, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 17, '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': '2130377', 'n_tokens_mistral': 1144, 'n_tokens_neox': 1056, 'n_words': 379}