SHARE
TWEET

Untitled

a guest Dec 10th, 2018 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. TracksControllerTest#test_should_get_index [/Users/adriancoutsoftides/RubymineProjects/cscades/test/controllers/tracks_controller_test.rb:14]:
  2. Expected response to be a <2XX: success>, but was a <500: Internal Server Error>
  3.    
  4. class TracksController < ApplicationController
  5.  
  6.   skip_before_action :authenticate_user!, raise: false
  7.   before_action :set_track, only: [:show, :edit, :update, :destroy]
  8.   before_action :authenticate_user!, except: [:index, :show]
  9.  
  10.   # GET /tracks
  11.   # GET /tracks.json
  12.   def index
  13.     @tracks = Track.all.order("created_at desc")
  14.   end
  15.  
  16.   # GET /tracks/1
  17.   # GET /tracks/1.json
  18.   def show
  19.   end
  20.  
  21.   # GET /tracks/new
  22.   def new
  23.     @track = current_user.tracks.build
  24.   end
  25.  
  26.   # GET /tracks/1/edit
  27.   def edit
  28.   end
  29.  
  30.   # POST /tracks
  31.   # POST /tracks.json
  32.   def create
  33.     @track = current_user.tracks.build(track_params)
  34.  
  35.     respond_to do |format|
  36.       if @track.save
  37.         format.html { redirect_to root_path, notice: 'Track was successfully created.' }
  38.         format.json { render :show, status: :created, location: @track }
  39.       else
  40.         format.html { render :new }
  41.         format.json { render json: @track.errors, status: :unprocessable_entity }
  42.       end
  43.     end
  44.   end
  45.  
  46.   # PATCH/PUT /tracks/1
  47.   # PATCH/PUT /tracks/1.json
  48.   def update
  49.     respond_to do |format|
  50.       if @track.update(track_params)
  51.         format.html { redirect_to @track, notice: 'Track was successfully updated.' }
  52.         format.json { render :show, status: :ok, location: @track }
  53.       else
  54.         format.html { render :edit }
  55.         format.json { render json: @track.errors, status: :unprocessable_entity }
  56.       end
  57.     end
  58.   end
  59.  
  60.   # DELETE /tracks/1
  61.   # DELETE /tracks/1.json
  62.   def destroy
  63.     @track.destroy
  64.     respond_to do |format|
  65.       format.html { redirect_to tracks_url, notice: 'Track was successfully destroyed.' }
  66.       format.json { head :no_content }
  67.     end
  68.   end
  69.  
  70.   private
  71.  
  72.  
  73.   private
  74.     # Use callbacks to share common setup or constraints between actions.
  75.     def set_track
  76.       @track = Track.find(params[:id])
  77.     end
  78.  
  79.     # Never trust parameters from the scary internet, only allow the white list through.
  80.     def track_params
  81.       params.require(:track).permit(:name, :genre, :bpm, :description, :price, :image)
  82.     end
  83. end
  84.    
  85. class TracksControllerTest < ActionDispatch::IntegrationTest
  86.  
  87.   setup do
  88.     @track = tracks(:one)
  89.     @track.save!
  90.     sign_in users(:cscades) #need to sign in the users in order for tracks to be deleted as only track creators can delete them
  91.  
  92.   end
  93.  
  94.   test "should get index" do
  95.     get tracks_url
  96.     assert_response :success
  97.   end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top