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 all 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
2 changes: 2 additions & 0 deletions app/controllers/profiles_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ def edit_profile_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 be checked if you have not provided any of Website, Twitter, Facebook, or Instagram."}, if: :has_no_social_media?

self.ignored_columns = %w[
evidence_based_description
program_client_improvement
Expand Down Expand Up @@ -183,6 +187,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
6 changes: 6 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,12 @@

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

<dt>Instagram</dt>
<dd><%= partner.instagram %></dd>

<dt>No Social Media Presence</dt>
<dd><%= humanize_boolean(partner.no_social_media_presence) %></dd>
</dl>
</div>
</div>
2 changes: 2 additions & 0 deletions app/views/profiles/_show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
<p>Website: <%= partner_profile.website %></p>
<p>Facebook: <%= partner_profile.facebook %></p>
<p>Twitter: <%= partner_profile.twitter %></p>
<p>Instagram: <%= partner_profile.instagram %></p>
<p>No Social Media Presence: <%= humanize_boolean(partner_profile.no_social_media_presence) %></p>
<br>
<% end %>
<% if partner_profile_fields.include?('agency_stability') || partner_profile_fields.empty? %>
Expand Down
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
2 changes: 2 additions & 0 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,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
49 changes: 49 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,53 @@
end
end

describe "social media info validation for partners" 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, no_social_media_presence: false) }

it "with just a website it should be valid" do
partner.update(website: "some website URL", twitter: "", facebook: "", instagram: "")
expect(partner.valid?).to eq(true)
end

it "with just twitter it should be valid" do
partner.update(website: "", twitter: "some twitter URL", facebook: "", instagram: "")
expect(partner.valid?).to eq(true)
end

it "with just facebook it should be valid" do
partner.update(website: "", twitter: "", facebook: "some facebook URL", instagram: "")
expect(partner.valid?).to eq(true)
end

it "with just instagram it should be valid" do
partner.update(website: "", twitter: "", facebook: "", instagram: "some instagram URL")
expect(partner.valid?).to eq(true)
end

it "with every social media option it should be valid" do
partner.update(website: "some website URL", twitter: "some twitter URL", facebook: "some facebook URL", instagram: "some instagram URL")
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
1 change: 1 addition & 0 deletions spec/system/partners/approval_process_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
fill_in 'Executive Director Phone', with: '8889990000'
fill_in 'Executive Director Email', with: 'lorem@example.com'
fill_in 'Primary Contact Phone', with: '8889990000'
check 'No Social Media Presence'

click_on 'Update Information'
assert page.has_content? 'Details were successfully updated.'
Expand Down