2020-07-15 11:57:21 +02:00
require " rails_helper "
feature " User managing casting calls " do
let ( :current_user ) { create ( :user ) }
let ( :project ) { create ( :project , account : current_user . primary_account ) }
before :each do
sign_in current_user
end
scenario " casting calls table is visible " do
visit project_casting_calls_path ( project )
expect ( page ) . to have_content " Created On "
expect ( page ) . to have_content " Title "
expect ( page ) . to have_content " Status "
end
scenario " sees list of casting calls " do
visit project_casting_calls_path ( project )
expect ( page ) . to have_content no_casting_calls_label
casting_call = create ( :casting_call , project : project )
visit project_casting_calls_path ( project )
expect ( page ) . not_to have_content no_casting_calls_label
expect ( page ) . to have_content casting_call . created_at . try ( :strftime , '%D' )
expect ( page ) . to have_content casting_call . title
expect ( page ) . to have_content casting_call . status
end
scenario " can create casting call requests " do
visit project_casting_calls_path ( project )
expect ( page ) . to have_content no_casting_calls_label
click_on add_new_casting_call_label
2020-07-17 04:50:04 +02:00
fill_in title_field , with : " Casting Title "
2020-07-15 11:57:21 +02:00
fill_in description_field , with : " Description "
fill_in project_description_field , with : " Project Description "
2020-07-17 04:50:04 +02:00
fill_in interview_instructions_field , with : " Welcome Message "
fill_in interview_requirements_field , with : " Goodbye Message "
2020-07-15 11:57:21 +02:00
fill_in questions_field , with : " Questions "
click_on " Create Casting call "
expect ( page ) . to have_content ( " Your casting call request was successfully submitted. Thank you. A chat window will pop up on the lower right in a few seconds. " )
end
scenario " can update casting call requests " do
create ( :casting_call , title : " Title " , project : project )
visit project_casting_calls_path ( project )
click_on manage_button
click_on " Edit "
fill_in title_field , with : " New Title "
click_on " Update Casting call "
expect ( page ) . to have_content ( " The casting call request has been updated " )
end
scenario " can cancel a casting call request " do
create ( :casting_call , title : " Title " , project : project )
visit project_casting_calls_path ( project )
click_on manage_button
click_on " Cancel "
expect ( page ) . to have_content ( " The casting call request has been cancelled " )
end
2020-07-15 18:17:36 +02:00
scenario " can open casting call details " do
cc = create ( :casting_call , title : " Dummy title " , project : project )
visit project_casting_calls_path ( project )
click_on manage_button
click_on view_button
expect ( page ) . to have_content cc . title
expect ( page ) . to have_content cc . description
expect ( page ) . to have_content cc . project_description
expect ( page ) . to have_content cc . created_at
expect ( page ) . to have_content cc . status
expect ( page ) . to have_content cc . interview_instructions
expect ( page ) . to have_content cc . interview_requirements
expect ( page ) . to have_content cc . questions
end
context " when signed out " do
scenario " user opens public accessible casting call URL " do
cc = create ( :casting_call , title : " Dummy title " , project : project )
sign_out
public_url = " /casting_calls/ #{ cc . token } "
visit public_url
expect ( page ) . to have_content cc . title
expect ( page ) . to have_content cc . description
expect ( page ) . to have_content cc . project_description
expect ( page ) . not_to have_content cc . created_at
expect ( page ) . not_to have_content cc . status
expect ( page ) . not_to have_content cc . interview_instructions
expect ( page ) . not_to have_content cc . interview_requirements
expect ( page ) . not_to have_content cc . questions
end
end
2020-07-15 11:57:21 +02:00
private
def no_casting_calls_label
" Casting calls will appear here "
end
def manage_button
t " casting_calls.casting_call.actions.manage "
end
2020-07-15 18:17:36 +02:00
def view_button
'View'
end
2020-07-15 11:57:21 +02:00
def add_new_casting_call_label
t " casting_calls.index.actions.new "
end
def title_field
2020-07-17 04:50:04 +02:00
t " helpers.label.casting_call.title "
2020-07-15 11:57:21 +02:00
end
def description_field
2020-07-17 04:50:04 +02:00
t " helpers.label.casting_call.description "
2020-07-15 11:57:21 +02:00
end
def project_description_field
2020-07-17 04:50:04 +02:00
t " helpers.label.casting_call.project_description "
2020-07-15 11:57:21 +02:00
end
def interview_instructions_field
2020-07-17 04:50:04 +02:00
t " helpers.label.casting_call.interview_instructions "
2020-07-15 11:57:21 +02:00
end
def interview_requirements_field
2020-07-17 04:50:04 +02:00
t " helpers.label.casting_call.interview_requirements "
2020-07-15 11:57:21 +02:00
end
def questions_field
2020-07-17 04:50:04 +02:00
t " helpers.label.casting_call.questions "
2020-07-15 11:57:21 +02:00
end
2020-07-17 04:50:04 +02:00
end