Skip to content

Commit

Permalink
Revise position_features specs
Browse files Browse the repository at this point in the history
These specs test how a user will manage crew positions associated with their profile.  Made a design change to the user flow, mostly to better meet project requirements while preserving controller organization.  When a user logs in, a link to "Crew Positions" (e.g.) will be displayed.  Clicking the link will route to user/id/positions.  From this page, the user can click a link to manage positions.

This commit marks the revision of these specs, documents the rationale for the change.
  • Loading branch information
christinalcole committed Nov 1, 2017
1 parent fe8372f commit 0d71f31
Showing 1 changed file with 29 additions and 28 deletions.
57 changes: 29 additions & 28 deletions spec/features/position_features_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,54 +2,55 @@

RSpec.feature 'Users and Positions', type: :feature do
context 'as a logged-in user' do
it 'has an add-position page nested under a user' do
it 'has a position index page nested under a user' do
user = create(:user)
visit new_user_position_path(user.id)

visit user_positions_path(user.id)
expect(page.status_code).to eq(200)
end
end

context 'user wants to add positions to their profile' do
scenario 'there is a link to add new position(s)' do
context 'user wants to manage positions on their profile' do
scenario 'there is a link to manage positions' do
user = create(:user)
signin(user.email, user.password)

visit user_path(user.id)
expect(page).to have_link("Add Crew Positions")
visit user_positions_path(user.id)
expect(page).to have_link("Manage 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
scenario 'there is a form to update positions associated with user profile' do
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")
# visit user_path(user.id)
# click_link("Add Crew Positions")
# 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)
# 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)
# 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
end

Expand Down

0 comments on commit 0d71f31

Please sign in to comment.