Refactor AcceptanceHelpers
This commit is contained in:
parent
896fe661bd
commit
9c9fdcf4da
@ -1,38 +1,39 @@
|
|||||||
module AcceptanceHelpers
|
module AcceptanceHelpers
|
||||||
def sign_in
|
def sign_in
|
||||||
user = FactoryGirl.create(:user)
|
create :user do |o|
|
||||||
visit new_session_path
|
visit new_session_path
|
||||||
fill_in 'Email', with: user.email
|
fill_in 'Email', with: o.email
|
||||||
fill_in 'Password', with: user.password
|
fill_in 'Password', with: o.password
|
||||||
click_button('Sign in')
|
click_button 'Sign in'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def api_sign_in
|
def api_sign_in
|
||||||
user = FactoryGirl.create :user
|
create :user do |o|
|
||||||
|
post api_sessions_path, format: :json, session: {
|
||||||
post_via_redirect api_sessions_path, format: :json, session: {
|
email: o.email,
|
||||||
email: user.email,
|
password: o.password
|
||||||
password: user.password
|
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def create_playlist
|
def create_playlist
|
||||||
playlist = attributes_for :playlist
|
attributes_for :playlist do |o|
|
||||||
visit playlists_path
|
visit playlists_path
|
||||||
click_link 'Create playlist'
|
click_link 'Create playlist'
|
||||||
fill_in 'Name', with: playlist[:name]
|
fill_in 'Name', with: o[:name]
|
||||||
click_button 'Create'
|
click_button 'Create'
|
||||||
playlist
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_track file: false
|
def create_track file: false
|
||||||
track = attributes_for(file ? :track_with_sound : :track)
|
attributes_for file ? :track_with_sound : :track do |o|
|
||||||
visit tracks_path
|
visit tracks_path
|
||||||
click_link 'Create track'
|
click_link 'Create track'
|
||||||
fill_in 'Name', with: track[:name]
|
fill_in 'Name', with: o[:name]
|
||||||
attach_file 'File', track[:file].path if file
|
attach_file 'File', o[:file].path if file
|
||||||
click_button 'Upload'
|
click_button 'Upload'
|
||||||
track
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def json
|
def json
|
||||||
|
Loading…
x
Reference in New Issue
Block a user