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

Partner social media changes #3148

Merged
merged 22 commits into from
Oct 29, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
c42e711
Added instagram field and checkbox to social media section
Learningstuff98 Sep 14, 2022
79841f4
Added validation for the checkbox on the social media form
Learningstuff98 Sep 14, 2022
e6b10ef
Small wording change
Learningstuff98 Sep 15, 2022
aa70d70
Added some tests
Learningstuff98 Sep 16, 2022
4edd948
Merge branch 'main' into partner-social-media-changes
Learningstuff98 Sep 17, 2022
fc3e0b3
Added some more tests
Learningstuff98 Sep 18, 2022
274e4a5
Bug fix
Learningstuff98 Sep 21, 2022
7fc935c
Changed the social media validation error message
Learningstuff98 Sep 27, 2022
eb8857d
Added a test for the custom error message
Learningstuff98 Sep 30, 2022
7406aee
Merge branch 'main' into partner-social-media-changes
Learningstuff98 Sep 30, 2022
82c4f0d
Merge branch 'main' into partner-social-media-changes
Learningstuff98 Oct 7, 2022
8c8df05
Merge branch 'main' into partner-social-media-changes
Learningstuff98 Oct 11, 2022
2d4f8f2
Changed error message
Learningstuff98 Oct 11, 2022
27ed0dd
Merge branch 'main' into partner-social-media-changes
Learningstuff98 Oct 14, 2022
f171d31
Partner media info list only renders if partner has social media
Learningstuff98 Oct 14, 2022
20d8f48
Small refactor
Learningstuff98 Oct 16, 2022
6938b01
Updated media info section
Learningstuff98 Oct 16, 2022
185d179
Added social media fields to views for bank admins
Learningstuff98 Oct 16, 2022
36092c2
Merge branch 'main' into partner-social-media-changes
Learningstuff98 Oct 16, 2022
f1d1e46
Fixed linting issue
Learningstuff98 Oct 16, 2022
04e12c0
Added instagram and no_social_media_presence to the other profiles co…
Learningstuff98 Oct 25, 2022
980d9d2
Merge branch 'main' into partner-social-media-changes
Learningstuff98 Oct 25, 2022
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
2 changes: 2 additions & 0 deletions app/controllers/partners/profiles_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ def partner_params
:website,
:facebook,
:twitter,
:instagram,
:no_social_media_presence,
:founded,
:form_990,
:proof_of_form_990,
Expand Down
8 changes: 8 additions & 0 deletions app/models/partners/partner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@
# greater_2_times_fpl :integer
# income_requirement_desc :boolean
# income_verification :boolean
# instagram :string
# more_docs_required :string
# name :string
# new_client_times :string
# no_social_media_presence :boolean
# other_agency_type :string
# partner_status :string default("pending")
# pick_up_email :string
Expand Down Expand Up @@ -92,6 +94,8 @@ class Partner < Base
has_one_attached :proof_of_form_990
has_many_attached :documents

validates :no_social_media_presence, acceptance: {message: "must either be checked or you need to have at least one social media platform filled out."}, if: :has_no_social_media?

self.ignored_columns = %w[
evidence_based_description
program_client_improvement
Expand Down Expand Up @@ -179,6 +183,10 @@ def impact_metrics

private

def has_no_social_media?
website.blank? && twitter.blank? && facebook.blank? && instagram.blank?
end

def families_served_count
families.count
end
Expand Down
2 changes: 2 additions & 0 deletions app/views/partners/profiles/edit/_media_information.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
<%= form.input :website, label: "Website", class: "form-control", wrapper: :input_group %>
<%= form.input :facebook, label: "Facebook", class: "form-control", wrapper: :input_group %>
<%= form.input :twitter, label: "Twitter", class: "form-control", wrapper: :input_group %>
<%= form.input :instagram, label: "Instagram", class: "form-control", wrapper: :input_group %>
<%= form.input :no_social_media_presence, label: "No Social Media Presence", as: :boolean, class: "form-control", wrapper: :input_group %>
</div>
</div>
</div>
Expand Down
3 changes: 3 additions & 0 deletions app/views/partners/profiles/show/_media_information.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@

<dt>Twitter</dt>
<dd><%= partner.twitter %></dd>

<dt>Instagram</dt>
<dd><%= partner.instagram %></dd>
</dl>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddInstagramToPartnerProfiles < ActiveRecord::Migration[7.0]
def change
add_column :partner_profiles, :instagram, :string
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddNoSocialMediaPresenceToPartnerProfiles < ActiveRecord::Migration[7.0]
def change
add_column :partner_profiles, :no_social_media_presence, :boolean
end
end
4 changes: 3 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.0].define(version: 2022_08_25_211052) do
ActiveRecord::Schema[7.0].define(version: 2022_09_14_000010) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"

Expand Down Expand Up @@ -514,6 +514,8 @@
t.string "status_in_diaper_base"
t.boolean "enable_child_based_requests", default: true, null: false
t.boolean "enable_individual_requests", default: true, null: false
t.string "instagram"
t.boolean "no_social_media_presence"
t.index ["essentials_bank_id"], name: "index_partners_on_essentials_bank_id"
end

Expand Down
28 changes: 28 additions & 0 deletions spec/models/partners/partner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@
# greater_2_times_fpl :integer
# income_requirement_desc :boolean
# income_verification :boolean
# instagram :string
# more_docs_required :string
# name :string
# new_client_times :string
# no_social_media_presence :boolean
# other_agency_type :string
# partner_status :string default("pending")
# pick_up_email :string
Expand Down Expand Up @@ -104,6 +106,32 @@
end
end

describe "validations" do
context "no social media presence and the checkbox isn't checked" do
let(:partner) { FactoryBot.build(:partners_partner, website: "", twitter: "", facebook: "", instagram: "", no_social_media_presence: false) }

it "should not be valid" do
expect(partner.valid?).to eq(false)
end
end

context "no social media presence and the checkbox is checked" do
let(:partner) { FactoryBot.build(:partners_partner, website: "", twitter: "", facebook: "", instagram: "", no_social_media_presence: true) }

it "should be valid" do
expect(partner.valid?).to eq(true)
end
end

context "has social media presence and the checkbox is unchecked" do
let(:partner) { FactoryBot.build(:partners_partner, website: "website URL", twitter: "", facebook: "", instagram: "instagram URL", no_social_media_presence: false) }

it "should be valid" do
expect(partner.valid?).to eq(true)
end
end
end

describe '#verified?' do
subject { partner.verified? }
let(:partner) { FactoryBot.build(:partners_partner, partner_status: partner_status) }
Expand Down
2 changes: 1 addition & 1 deletion spec/system/dashboard_system_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ def create_next_product_drive_donation(donation_date:)
drive = @product_drives.sample

create :product_drive_donation, :with_items, product_drive: drive.drive, product_drive_participant: @product_drive_participant, issued_at: donation_date, item_quantity: quantity_in_donation, storage_location: storage_location, organization: @organization,
money_raised: @money_raised_on_each_product_drive
money_raised: @money_raised_on_each_product_drive

OpenStruct.new drive_name: drive.name, quantity: quantity_in_donation, money_raised: @money_raised_on_each_product_drive
end
Expand Down