Skip to content
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

Disable 15 minutes validation for New Case Contact Form #5288

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion app/models/case_contact.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ class CaseContact < ApplicationRecord
attr_accessor :duration_hours

validate :contact_made_chosen
validates :duration_minutes, numericality: {greater_than_or_equal_to: 15, message: "Minimum case contact duration should be 15 minutes."}
validates :miles_driven, numericality: {greater_than_or_equal_to: 0, less_than: 10000}
validates :medium_type, presence: true
validates :occurred_at, presence: true
Expand Down
10 changes: 4 additions & 6 deletions spec/models/case_contact_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,14 @@
expect(case_contact.errors[:occurred_at]).to eq(["can't be blank"])
end

it "validates duration_minutes is only numeric values" do
it "validates duration_minutes to allow nil value" do
case_contact = build_stubbed(:case_contact, duration_minutes: nil)
expect(case_contact).to_not be_valid
expect(case_contact.errors[:duration_minutes]).to eq(["Minimum case contact duration should be 15 minutes."])
expect(case_contact).to be_valid
end

it "validates duration_minutes cannot be less than 15 minutes." do
it "validates duration_minutes can be less than 15 minutes." do
case_contact = build_stubbed(:case_contact, duration_minutes: 10)
expect(case_contact).to_not be_valid
expect(case_contact.errors[:duration_minutes]).to eq(["Minimum case contact duration should be 15 minutes."])
expect(case_contact).to be_valid
end

it "verifies occurred at is not in the future" do
Expand Down
2 changes: 1 addition & 1 deletion spec/requests/case_contacts_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@

context "with invalid parameters" do
let!(:other_casa_case) { create(:casa_case, casa_org: organization) }
let(:invalid_attributes) { {creator: volunteer, casa_case_id: [other_casa_case.id]} }
let(:invalid_attributes) { {creator: volunteer, casa_case_id: [other_casa_case.id], occurred_at: Time.now + 1.week} }
let(:params) { {case_contact: invalid_attributes} }

it { is_expected.to have_http_status(:success) }
Expand Down
1 change: 0 additions & 1 deletion spec/system/case_contacts/new_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@
within "#enter-contact-details" do
choose "Yes"
end
choose "Video"
fill_in "case_contact_occurred_at", with: "04/04/2020"
fill_in "case-contact-duration-hours-display", with: "0"
fill_in "case-contact-duration-minutes-display", with: "5"
Expand Down