Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## test/functionals/addresses_controller_test.rb
- ### Errors occur on lines
- require File.dirname(__FILE__) + '/../test_helper'
- require 'shoulda'
- class AddressesControllerTest < ActionController::TestCase
- context "handle" do
- setup do
- @user = Factory(:user)
- end
- context "without logging in" do
- context ":index" do
- setup do
- get :index
- end
- should_redirect_to("new_session_path") { new_session_path }
- should_not_set_the_flash
- should_not_assign_to :addresses
- end
- context ":show" do
- setup do
- get :show, :address => Factory(:address)
- end
- should_redirect_to("new_session_path") { new_session_path }
- should_not_set_the_flash
- should_not_assign_to :addresses
- end
- context ":edit" do
- setup do
- get :edit, :address => Factory(:address)
- end
- should_redirect_to("new_session_path") { new_session_path }
- should_not_set_the_flash
- should_not_assign_to :addresses
- end
- context ":update" do
- setup do
- put :update, :id => Factory(:address), :address => {}
- end
- should_redirect_to("new_session_path") { new_session_path }
- should_not_set_the_flash
- should_not_assign_to :addresses
- end
- context ":new" do
- setup do
- get :new
- end
- should_redirect_to("new_session_path") { new_session_path }
- should_not_set_the_flash
- should_not_assign_to :addresses
- end
- context ":create" do
- setup do
- post :create, :address => Factory.attributes_for(:address)
- end
- should_redirect_to("new_session_path") { new_session_path }
- should_not_set_the_flash
- should_not_assign_to :addresses
- end
- context ":destroy" do
- setup do
- delete :destroy, :id => Factory(:address)
- end
- should_redirect_to("new_session_path") { new_session_path }
- should_not_set_the_flash
- should_not_assign_to :addresses
- end
- end
- context ":index" do
- setup do
- get :index, {}, {:user_id => @user}
- end
- should_respond_with :success
- should_render_template :index
- should_not_set_the_flash
- should_assign_to :addresses
- end
- context ":show" do
- setup do
- get :show, {:id => Factory(:address)}, {:user_id => @user}
- end
- should_respond_with :success
- should_render_template :show
- should_not_set_the_flash
- should_assign_to :address
- end
- context ":edit" do
- setup do
- get :edit, {:id => Factory(:address)}, {:user_id => @user}
- end
- should_respond_with :success
- should_render_template :edit
- should_not_set_the_flash
- should_assign_to :address
- end
- context ":update" do
- setup do
- put :update, {:id => Factory(:address), :address => {}}, {:user_id => @user}
- end
- should_redirect_to("address_path") { address_path(assigns(:address)) }
- should_set_the_flash_to "Address was successfully updated."
- should_assign_to :address
- end
- context ":new" do
- setup do
- get :new, {}, {:user_id => @user}
- end
- should_respond_with :success
- should_render_template :new
- should_not_set_the_flash
- should_assign_to :address
- end
- context ":create" do
- setup do
- post :create, {:address => Factory.attributes_for(:address)}, {:user_id => @user}
- end
- should_redirect_to("address_path") { address_path(assigns(:address)) }
- should_set_the_flash_to "Address was successfully created."
- should_assign_to :address
- should_change("Address.count", :by => 1) { Address.count }
- end
- context ":destroy" do
- setup do
- @address = Factory(:address)
- delete :destroy, {:id => @address}, {:user_id => @user}
- end
- should_redirect_to("addresses_path") { addresses_path }
- should_set_the_flash_to "Address was successfully deleted."
- should_change("Address.count", :by => -1) { Address.count }
- end
- end
- end
Add Comment
Please, Sign In to add comment