Skip to content

Commit

Permalink
Merge pull request #3873 from rubyforgood/revert-3691-mandatory_field…
Browse files Browse the repository at this point in the history
…s_for_partner_profile

Revert "add mandatory fields for partner profile"
  • Loading branch information
awwaiid committed Sep 10, 2023
2 parents 0cad8cf + c7da079 commit edd09a9
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 33 deletions.
4 changes: 1 addition & 3 deletions app/models/partners/profile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,7 @@ class Profile < Base
accepts_nested_attributes_for :served_areas, allow_destroy: true

has_many_attached :documents

validate :check_social_media, on: :edit
validates :agency_type, :city, :state, :zip_code, :address1, :program_name, :program_description, presence: true, on: :edit

validate :client_share_is_0_or_100
validate :has_at_least_one_request_setting
Expand All @@ -123,7 +121,7 @@ def client_share_total

def check_social_media
return if website.present? || twitter.present? || facebook.present? || instagram.present?
return if partner&.partials_to_show&.exclude?("media_information")
return if partner.partials_to_show.exclude?("media_information")

unless no_social_media_presence
errors.add(:no_social_media_presence, "must be checked if you have not provided any of Website, Twitter, Facebook, or Instagram.")
Expand Down
10 changes: 5 additions & 5 deletions app/views/partners/profiles/edit/_agency_information.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</div>
<div class="card-body">
<%= form.input :name, label: "Agency Name", class: "form-control", wrapper: :input_group %>
<%= profile_form.input :agency_type, required: true, collection: Partner::AGENCY_TYPES.values, label: "Agency Type", class: "form-control", wrapper: :input_group %>
<%= profile_form.input :agency_type, collection: Partner::AGENCY_TYPES.values, label: "Agency Type", class: "form-control", wrapper: :input_group %>
<%= profile_form.input :other_agency_type, label: "Other Agency Type", class: "form-control", wrapper: :input_group %>
<div class="form-group row">
<label class="control-label col-md-3">501(c)(3) IRS Determination Letter</label>
Expand All @@ -25,11 +25,11 @@
<% end %>
</div>
<%= profile_form.input :agency_mission, label: "Agency Mission", class: "form-control", wrapper: :input_group %>
<%= profile_form.input :address1, label: "Address (line 1)", required: true, class: "form-control", wrapper: :input_group %>
<%= profile_form.input :address1, label: "Address (line 1)", class: "form-control", wrapper: :input_group %>
<%= profile_form.input :address2, label: "Address (line 2)", class: "form-control", wrapper: :input_group %>
<%= profile_form.input :city, label: "City", required: true, class: "form-control", wrapper: :input_group %>
<%= profile_form.input :state, label: "State", required: true, class: "form-control", wrapper: :input_group %>
<%= profile_form.input :zip_code, label: "Zip Code", required: true, class: "form-control", wrapper: :input_group %>
<%= profile_form.input :city, label: "City", class: "form-control", wrapper: :input_group %>
<%= profile_form.input :state, label: "State", class: "form-control", wrapper: :input_group %>
<%= profile_form.input :zip_code, label: "Zip Code", class: "form-control", wrapper: :input_group %>
</div>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions app/views/partners/profiles/edit/_agency_stability.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
<%= form.file_field :proof_of_form_990, class: "form-control-file" %>
</div>
<% end %>
<%= form.input :program_name, label: "Program Name(s)", required: true, class: "form-control", wrapper: :input_group %>
<%= form.input :program_description, label: "Program Description(s)", required: true, class: "form-control", wrapper: :input_group %>
<%= form.input :program_name, label: "Program Name(s)", class: "form-control", wrapper: :input_group %>
<%= form.input :program_description, label: "Program Description(s)", class: "form-control", wrapper: :input_group %>
<%= form.input :program_age, label: "Agency Age", class: "form-control", wrapper: :input_group %>
<%= form.input :evidence_based, label: "Evidence Based?", as: :radio_buttons, class: "form-control",
wrapper: :input_group, wrapper_html: {class: "form-yesno"}, input_html: {class: "radio-yesno"} %>
Expand Down
8 changes: 0 additions & 8 deletions spec/factories/partners/profile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,5 @@
partner { Partner.first || create(:partner) }
essentials_bank_id { Organization.try(:first).id || create(:organization).id }
website { "http://some-site.org" }
name { Faker::Company.name }
agency_type { Partner::AGENCY_TYPES["CAREER"] }
city { Faker::Address.city }
state { Faker::Address.state }
zip_code { Faker::Address.zip }
address1 { Faker::Address.street_address }
program_name { Faker::Lorem.characters(number: 5) }
program_description { Faker::Lorem.characters(number: 15) }
end
end
10 changes: 0 additions & 10 deletions spec/models/partners/profile_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,6 @@
it { should have_many(:served_areas) }
end

describe "validations" do
it { should validate_presence_of(:agency_type).on(:edit) }
it { should validate_presence_of(:city).on(:edit) }
it { should validate_presence_of(:state).on(:edit) }
it { should validate_presence_of(:zip_code).on(:edit) }
it { should validate_presence_of(:address1).on(:edit) }
it { should validate_presence_of(:program_name).on(:edit) }
it { should validate_presence_of(:program_description).on(:edit) }
end

it "must allow deleting served_areas" do
should accept_nested_attributes_for(:served_areas).allow_destroy(true)
end
Expand Down
6 changes: 3 additions & 3 deletions spec/requests/partners/profiles_requests_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@

context "when updating an existing value to a blank value" do
before do
partner.profile.update!(instagram: "")
partner.profile.update!(city: "")
put partners_profile_path(partner,
partner: {name: "Partnerdude", profile: {instagram: "", website: "N/A"}})
partner: {name: "Partnerdude", profile: {city: "", website: "N/A"}})
end

it "updates the partner profile attribute to a blank value" do
expect(partner.profile.reload.instagram).to eq ""
expect(partner.profile.reload.city).to eq ""
end

it "does not update other partner profile attributes to blank" do
Expand Down
4 changes: 3 additions & 1 deletion spec/services/partners/request_approval_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
.to include("No social media presence must be checked if you have not provided any of Website, Twitter, Facebook, or Instagram.")
end

it 'should return an error re agency_type' do
# TODO: This test is disabled until we sort out required fields, per
# https://github.com/rubyforgood/human-essentials/issues/3875
xit 'should return an error re agency_type' do
partner.profile.update(agency_type: "")

expect(subject.errors.full_messages)
Expand Down
2 changes: 1 addition & 1 deletion spec/services/profile_update_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
let(:params) { {address2: "Washington, DC"} }

it "updates the profile with the filtered and prepared params" do
expect(partner.profile.instagram).to be_nil
expect(partner.profile.address1).to be_nil

result = described_class.update(partner.profile, params)
expect(result).to eq(true)
Expand Down

0 comments on commit edd09a9

Please sign in to comment.