Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require "#{File.dirname(__FILE__)}/../test_helper"
- class StudyTest < ActionController::IntegrationTest
- def test_add_a_basic_new_protocol
- # login to begin integration test
- user = login("xxxx", "xxxx")
- user.choose_create_new_protocol
- study = user.create_study
- user.add_participations(study)
- user.add_contacts(study)
- # we are going to edit all regulatory info in this test
- user.add_regulatory_info(study, true)
- user.add_regulatory_cro_info(study)
- user.add_financials(study)
- user.add_sponsors(study)
- end
- end
- private
- def login(user, pass)
- open_session do |sess|
- sess.extend(StudyTestDSL)
- sess.post_via_redirect "/user/login", :user => {:login => user, :password => pass}, :redirect_user_to => "", :redirect_key => ""
- end
- end
- module StudyTestDSL
- def choose_create_new_protocol
- get "/studies/new"
- assert_response :success
- assert_template "studies/new"
- end
- def create_study
- study_title = "new integration study"
- post "/studies/create", :commit=>"Next: Study Team", :study=>{ :title => "integration study", :gcrc=>"0", :study_status_id=>"7", :study_gender_id=>"3", :research_program_id=>"12"}, :pi=>{"name"=>"Damron, Dorothy"}
- study = assigns(:study)
- assert_not_nil study
- assert_valid study
- assert_valid study.study_status
- assert_redirected_to :controller => "participations", :action => "edit", :study_id => study.id
- study
- end
- def add_participations(study)
- # TODO implement adding participants using XHR
- # after adding participants...
- # there is a button here to use javascript to change the web page location
- get "/study_contacts/create_study_contacts?study_id=#{study.id}"
- assert_template "study_contacts/create_study_contacts"
- end
- def add_contacts(study)
- # TODO implement adding internal/external contacts using XHR
- # after adding contacts
- # there is a button here to use javascript to change the web page location
- get "/regulatory_non_cro/new?study_id=#{study.id}"
- assert_template "regulatory_non_cro/new"
- end
- def add_regulatory_info(study, edit_all_cro = true)
- # TODO implement adding regulatory_non_cro info
- redirect, post_options = case edit_all_cro
- when true
- [{:controller => "regulatory_cro", :action => "new", :study_id => study.id}, {:commit => "Next: CRO Info"}]
- else
- [{:controller => "study_financials", :action => "new", :study_id => study.id}, {:commit => "Next: Financial"}]
- end
- post "/regulatory_non_cro/update?study_id=#{study.id}", post_options
- assert_redirected_to redirect
- end
- def add_regulatory_cro_info(study)
- # TODO implement adding regulatory_cro info
- post "/regulatory_cro/update?study_id=#{study.id}", :commit => "Next: Financial"
- assert_redirected_to :controller => "study_financials", :action => "new", :study_id => study.id
- end
- def add_financials(study)
- # TODO implement adding financials
- post "/study_financials/update?study_id=#{study.id}", :commit => "Next: Study Sponsors"
- assert_redirected_to :controller => "study_sponsorships", :action => "create_study_sponsorships", :study_id => study.id
- end
- def add_sponsors(study)
- # TODO implement adding sponsors
- get "/studies/show?study_id=#{study.id}"
- assert_template "studies/show"
- end
- end
Add Comment
Please, Sign In to add comment