Created
April 9, 2010 17:49
-
-
Save jedschneider/361392 to your computer and use it in GitHub Desktop.
a little integration test trick
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 ReleaseFormLifeCycleTest < ActionController::IntegrationTest | |
context "a release form lifecycle" do | |
setup do | |
@admin = Factory(:administrator) | |
login | |
end | |
should "sign a new release, go to the clients page, revoke, and prompt for a new release" do | |
@client = create_client | |
@client.reload # => assures temp objects are cleared | |
sign_a_release_form @client | |
revoke_release_form @client | |
end | |
end | |
def login | |
get "/login" | |
assert_equal 200, status | |
post_via_redirect session_path, :login => @admin.login, :password => "secret" | |
assert_equal root_path, path | |
end | |
def create_client | |
get "/clients/new" | |
assert_equal 200, status | |
post_via_redirect clients_path, :client => Factory.build(:client).attributes | |
assert_equal new_client_release_form_path(assigns(:client)), path | |
assigns :client | |
end | |
def sign_a_release_form client | |
get new_client_release_form_path client | |
assert_equal 200, status | |
release_form = Factory.build(:release_form).attributes | |
release_form[:agency_ids] = [Agency.get(:dmh).id] | |
post_via_redirect client_release_forms_path(client), :release_form => release_form | |
assert_equal 200, status | |
assert_equal client_path(client), path | |
end | |
def revoke_release_form client | |
get client_path client | |
assert_equal 200, status | |
assert_equal 1, client.release_forms.size # => makes sure the @client.reload is successful | |
release_form = client.release_forms.flatten | |
delete_via_redirect release_form_path(release_form) | |
assert_equal new_client_release_form_path(client), path | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment