Created
April 19, 2013 04:14
-
-
Save bitsandbooks/5418104 to your computer and use it in GitHub Desktop.
Expected response to be a <:redirect>, but was <200>. Failure is on lines 29 and 57 of the test.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LinksController < ApplicationController | |
# GET /links | |
# GET /links.json | |
def index | |
@links = Link.all | |
respond_to do |format| | |
format.html # index.html.erb | |
format.json { render json: @links } | |
end | |
end | |
# GET /links/1 | |
# GET /links/1.json | |
def show | |
@link = Link.find(params[:id]) | |
respond_to do |format| | |
format.html # show.html.erb | |
format.json { render json: @link } | |
end | |
end | |
# GET /links/new | |
# GET /links/new.json | |
def new | |
@link = Link.new | |
respond_to do |format| | |
format.html # new.html.erb | |
format.json { render json: @link } | |
end | |
end | |
# GET /links/1/edit | |
def edit | |
@link = Link.find(params[:id]) | |
end | |
# POST /links | |
# POST /links.json | |
def create | |
@link = Link.new(params[:link]) | |
respond_to do |format| | |
if @link.save | |
format.html { redirect_to links_path, notice: 'Link was successfully created.' } | |
format.json { render json: @link, status: :created, location: @link } | |
else | |
format.html { render action: "new" } | |
format.json { render json: @link.errors, status: :unprocessable_entity } | |
end | |
end | |
end | |
# PUT /links/1 | |
# PUT /links/1.json | |
def update | |
@link = Link.find(params[:id]) | |
respond_to do |format| | |
if @link.update_attributes(params[:link]) | |
format.html { redirect_to links_path, notice: 'Link was successfully updated.' } | |
format.json { head :no_content } | |
else | |
format.html { render action: "edit" } | |
format.json { render json: @link.errors, status: :unprocessable_entity } | |
end | |
end | |
end | |
# DELETE /links/1 | |
# DELETE /links/1.json | |
def destroy | |
@link = Link.find(params[:id]) | |
@link.destroy | |
respond_to do |format| | |
format.html { redirect_to links_url } | |
format.json { head :no_content } | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'test_helper' | |
class LinksControllerTest < ActionController::TestCase | |
setup do | |
@link = links(:one) | |
@update = { | |
title: 'Testing', | |
url: 'http://www.lipsum.com/' | |
} | |
end | |
test "should get index" do | |
get :index | |
assert_response :success | |
assert_not_nil assigns(:links) | |
end | |
test "should get new" do | |
get :new | |
assert_response :success | |
end | |
test "should create link" do | |
assert_no_difference('Link.count') do | |
# post :create, link: { title: @link.title, url: @link.url } | |
post :create, link: @update | |
end | |
assert_redirected_to links_path(assigns(:link)) | |
=begin | |
[7/7] LinksControllerTest#test_should_update_link = 0.01 s | |
2) Failure: | |
test_should_update_link(LinksControllerTest) [/Users/rob/Projects/portaportal/test/functional/links_controller_test.rb:45]: | |
Expected response to be a <:redirect>, but was <200> | |
Finished tests in 0.214639s, 32.6129 tests/s, 46.5899 assertions/s. | |
7 tests, 10 assertions, 2 failures, 0 errors, 0 skips | |
ruby -v: ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-darwin12.3.0] | |
Errors running test:functionals! #<RuntimeError: Command failed with status (2): [ruby -I"lib:test" -I"/Users/rob/.rvm/gems/ruby-2.0.0-p0@global/gems/rake-10.0.4/lib" "/Users/rob/.rvm/gems/ruby-2.0.0-p0@global/gems/rake-10.0.4/lib/rake/rake_test_loader.rb" "test/functional/**/*_test.rb" ]> | |
=end | |
end | |
test "should show link" do | |
get :show, id: @link | |
assert_response :success | |
end | |
test "should get edit" do | |
get :edit, id: @link | |
assert_response :success | |
end | |
test "should update link" do | |
# put :update, id: @link, link: { title: @link.title, url: @link.url } | |
put :update, id: @link, link: @update | |
assert_redirected_to links_path | |
=begin | |
[1/7] LinksControllerTest#test_should_create_link = 0.11 s | |
1) Failure: | |
test_should_create_link(LinksControllerTest) [/Users/rob/Projects/portaportal/test/functional/links_controller_test.rb:29]: | |
Expected response to be a <:redirect>, but was <200> | |
=end | |
end | |
test "should destroy link" do | |
assert_difference('Link.count', -1) do | |
delete :destroy, id: @link | |
end | |
assert_redirected_to links_path | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment