Skip to content

Commit

Permalink
add specs for user to add positions to own profile
Browse files Browse the repository at this point in the history
  • Loading branch information
christinalcole committed Sep 29, 2017
1 parent 0c2954a commit 3a98639
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 4 deletions.
10 changes: 10 additions & 0 deletions spec/factories/users.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,15 @@
phone_number Faker::PhoneNumber.cell_phone
weight Faker::Number.between(85, 250)
password Faker::Internet.password(8)

factory :user_with_positions do
transient do
positions_count 2
end

after(:create) do |user, evaluator|
create_list(:position, evaluator.positions_count, user: user)
end
end
end
end
36 changes: 32 additions & 4 deletions spec/features/position_features_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,45 @@
context 'user wants to add positions to their profile' do
scenario 'there is a link to add new position(s)' do
user = create(:user)
signin(user.email, user.password)

visit user_path(user.id)
expect(page).to have_link("Add Crew Positions")
end

scenario 'there is no link to add position(s) if a user profile already has positions'

scenario 'there is a form to add new position(s)' do
visit user_path
user = create(:user)
signin(user.email, user.password)
visit user_path(user.id)
click_link("Add Crew Positions")
expect(page).to have(css"form#new_position")
expect(page).to have_css("form#new_position")
end

scenario 'the form should display existing positions in the db' do
position1 = create(:position)
position2 = create(:position)
user = create(:user)
signin(user.email, user.password)
visit new_user_position_path(user.id)

expect(page).to have_content(position1.name)
expect(page).to have_content(position2.name)
end

scenario 'the user should gain new position(s) after the form is submitted' do
position1 = create(:position)
position2 = create(:position)
user = create(:user)
signin(user.email, user.password)
visit new_user_position_path(user.id)

page.check(position1.name)
click_button("Create Position")

expect(user.positions).to include(position1)
end
scenario 'the form should display existing positions in the db'
scenario 'the user should gain new position(s) after the form is submitted'
end

context 'user wants to update positions in their profile' do
Expand Down
1 change: 1 addition & 0 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,6 @@

#support for Devise
config.include Devise::Test::ControllerHelpers, type: :controller
config.include Devise::Test::ControllerHelpers, type: :view
config.include Features::SessionHelpers, type: :feature
end

0 comments on commit 3a98639

Please sign in to comment.