-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] - Feature absences spec #82
Changes from 7 commits
d1a7b35
d8bdd38
f583691
6d9b776
68205c0
1c197b4
51c2d31
408f7b0
8f9d8a3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,4 +24,4 @@ production: | |
host: localhost | ||
pool: 5 | ||
timeout: 5000 | ||
|
||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe AbsencesController do | ||
let(:volunteer) { create :volunteer_with_assignment } | ||
let(:volunteer_with_assignment) { create :volunteer_with_assignment } | ||
|
||
it_behaves_like 'an authenticated indexable resource' | ||
|
||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,15 @@ | |
waiver_signed true | ||
waiver_signed_at Time.zone.now | ||
|
||
factory :volunteer_with_region do | ||
after(:create) do |v| | ||
region = create(:region) | ||
v.regions << region | ||
v.assigned = true | ||
v.save | ||
end | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe this added factory actually ends up doing the same thing as the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @ericfreese There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like the new factory ( If we put a > volunteer_without_assignment.assignments.count
=> 1 The This actually is the same outcome as the This explains why you're not seeing the login failure error for this user. If the user truly had no assignments, they would never be able to log in.
Because it is not possible for a volunteer with no assignments to log into the system to get to the "Schedule an Absence" form, I think it would be best to test other cases. I think it would be best to start with the happy path: A volunteer with a shift successfully scheduling an absence for that shift. |
||
|
||
factory :volunteer_with_assignment do | ||
after(:create) do |v| | ||
a = create(:assignment,volunteer:v) | ||
|
@@ -15,7 +24,7 @@ | |
v.save | ||
end | ||
end | ||
|
||
trait :not_waived do | ||
waiver_signed false | ||
waiver_signed_at nil | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe 'Scheduling an Absence' do | ||
|
||
let(:volunteer_with_assignment) { create :volunteer_with_assignment } | ||
let(:volunteer_without_assignment) { create :volunteer_with_region } | ||
let(:admin) { create :volunteer_with_assignment, admin: true } | ||
|
||
context 'non-admin user' do | ||
context 'WITHOUT assignment' do | ||
it 'cannot schedule' do | ||
login volunteer_without_assignment | ||
|
||
within '.navbar' do | ||
click_on 'Schedule An Absence' | ||
end | ||
|
||
expect(current_path).to eq(new_absence_path) | ||
|
||
click_on 'Save changes' | ||
|
||
expect(current_path).to eq(absences_path) | ||
within('.alert') do | ||
expect(page).to have_content('No shifts of yours was found in that timeframe') | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indentation still looks a little off for lines 14-23 and line 25. |
||
end | ||
end | ||
end | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The indentation is a little funky in this file. It looks like lines 9-28 are indented by two extra spaces and lines 14-23 and line 25 are indented by an extra space. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commit message says:
I would have expected this commit to change the
test
section of this file, moving fromsqlite3
topostgresql
, but leave the rest of the file alone.I think it would be good to keep this file around for now, since it's used as kind of a template for people getting the project running locally. The readme has a step: "Next, copy /config/database.yml.dist to /config/database.yml and make any necessary changes".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ericfreese Thank you for the comment. You are right. I just realized that
database.yml
was listed in.gitignore
. I will have this corrected.