<commit_before>require 'spec_helper'

describe ContentsController do

  context 'GET new content action' do
    before do
      @user = create(:admin)
      sign_in :user, @user
    end

    it "responds successfully with an HTTP 200 status code" do
      get :new
      expect(response).to be_success
      assigns(:content).should_not be_nil
    end
  end

  context 'POST create new content' do
    before do
      @user = create(:admin)
      sign_in :user, @user
    end

    it 'should create new content' do      
      topic = create(:topic)
      content = build(:content).attributes
      post :create, {:content => content, :topic_id => topic.id}
      assigns(:content).persisted?.should be_true
    end

    it "should upload audio file and create content" do
      topic = create(:topic)
      content = build(:audio_file).attributes
      post :create, {:audio_file => content, :topic_id => topic.id}
      assigns(:audio_file).persisted?.should be_true
    end

    it "should upload vidio file and create content" do
      topic = create(:topic)
      content = build(:vidio_file).attributes
      post :create, {:vidio_file => content, :topic_id => topic.id}
      assigns(:vidio_file).persisted?.should be_true
      response.should redirect_to(:action => 'show', :id => assigns(:vidio_file).id)
    end

  end

  context 'edit content' do
    before(:each) do
      @user = create(:admin)
      sign_in :user, @user
      @content = create(:content)
    end
    
    it 'should be valid' do
      get :edit, {:id => @content.id}
      expect(response).to be_success
      assigns(:content).should eq(@content)
    end

    it 'should update the content' do
      @content.title = 'Updated Title'
      content = @content.attributes
      post :update, {:content => content, :id => @content.id}      
      assigns(:content).title.should eq('Updated Title')
    end
  end
<commit_msg>modified the content controller spec file.<commit_after>require 'spec_helper'

describe ContentsController do

  context 'GET new content action' do
    before do
      @user = create(:admin)
      sign_in :user, @user
    end

    it "responds successfully with an HTTP 200 status code" do
      get :new
      expect(response).to be_success
      assigns(:content).should_not be_nil
    end
  end

  context 'POST create new content' do
    before do
      @user = create(:admin)
      sign_in :user, @user
    end

    it 'should create new content' do      
      topic = create(:topic)
      content = build(:content).attributes
      post :create, {:content => content, :topic_id => topic.id}
      assigns(:content).persisted?.should be_true
    end

    it "should upload audio file and create content" do
      topic = create(:topic)
      content = build(:audio_file).attributes
      post :create, {:audio_file => content, :topic_id => topic.id}
      @content =  assigns(:content).persisted?.should be_true
      @content.topic_content_content_type.should eq("audio/mp3")
    end

    it "should upload vidio file and create content" do
      topic = create(:topic)
      content = build(:vidio_file).attributes
      post :create, {:vidio_file => content, :topic_id => topic.id}
      @content = assigns(:content).persisted?.should be_true
      @content.topic_content_content_type.should eq("vidio/mp4")
      response.should redirect_to(:action => 'show', :id => assigns(:vidio_file).id)
    end

  end

  context 'edit content' do
    before(:each) do
      @user = create(:admin)
      sign_in :user, @user
      @content = create(:content)
    end
    
    it 'should be valid' do
      get :edit, {:id => @content.id}
      expect(response).to be_success
      assigns(:content).should eq(@content)
    end

    it 'should update the content' do
      @content.title = 'Updated Title'
      content = @content.attributes
      post :update, {:content => content, :id => @content.id}      
      assigns(:content).title.should eq('Updated Title')
    end
  end

{'fraction_non_alphanumeric': 0.11024610748367654, 'fraction_numerical': 0.0020090406830738324, 'mean_word_length': 2.7933333333333334, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5821445', 'n_tokens_mistral': 1195, 'n_tokens_neox': 1153, 'n_words': 351}