diff --git a/app/controllers/static_controller.rb b/app/controllers/static_controller.rb index 24db97a444..3da738c07c 100644 --- a/app/controllers/static_controller.rb +++ b/app/controllers/static_controller.rb @@ -8,6 +8,7 @@ class StaticController < ApplicationController def index redirect_to dashboard_path_from_current_role if current_user + @casa_logos = CasaOrg.with_logo end def register diff --git a/app/models/casa_org.rb b/app/models/casa_org.rb index 6e25a6946e..9c56efde5f 100644 --- a/app/models/casa_org.rb +++ b/app/models/casa_org.rb @@ -2,6 +2,8 @@ class CasaOrg < ApplicationRecord CASA_DEFAULT_COURT_REPORT = File.new(Rails.root.join("app", "documents", "templates", "default_report_template.docx"), "r") CASA_DEFAULT_LOGO = Rails.root.join("public", "logo.jpeg") + scope :with_logo, -> { joins(:logo_attachment) } + before_create :set_slug before_update :sanitize_svg before_save :normalize_phone_number diff --git a/app/views/static/index.html.erb b/app/views/static/index.html.erb index 497a2093f9..fa1bd4499e 100644 --- a/app/views/static/index.html.erb +++ b/app/views/static/index.html.erb @@ -12,6 +12,10 @@ .app-images { height: 400px; } + +.org_logo { + height: 200px; +} @@ -165,14 +169,29 @@ -
+ +
-

Want to use the CASA Volunteer Tracking App?

- - +

CASA Organizations Powered by Our App

+
+
+ <% @casa_logos.each do |org| %> +
+
+ <%= image_tag org.logo, class: "org_logo" %> +
+
+ <% end %> +
+
-

-

Have questions? Email us at casa@rubyforgood.org

+
+
+
+

Want to use the CASA Volunteer Tracking App?

+

+

Have questions? Email us at casa@rubyforgood.org

+
diff --git a/spec/factories/casa_orgs.rb b/spec/factories/casa_orgs.rb index 46fc375a08..9fd356ec36 100644 --- a/spec/factories/casa_orgs.rb +++ b/spec/factories/casa_orgs.rb @@ -8,6 +8,10 @@ twilio_api_key_secret { "open sesame" } twilio_api_key_sid { "Aladdin" } twilio_phone_number { "+15555555555" } + + trait :with_logo do + logo { Rack::Test::UploadedFile.new(Rails.root.join("spec", "fixtures", "org_logo.jpeg")) } + end twilio_enabled { true } end end diff --git a/spec/fixtures/org_logo.jpeg b/spec/fixtures/org_logo.jpeg new file mode 100644 index 0000000000..1054c718f7 Binary files /dev/null and b/spec/fixtures/org_logo.jpeg differ diff --git a/spec/system/static/index_spec.rb b/spec/system/static/index_spec.rb new file mode 100644 index 0000000000..b1d076fb54 --- /dev/null +++ b/spec/system/static/index_spec.rb @@ -0,0 +1,36 @@ +require "rails_helper" + +RSpec.describe "static/index", type: :system do + context "when visiting the CASA volunteer landing page", js: true do + describe "when all organizations have logos" do + before do + 3.times { create(:casa_org, :with_logo) } + visit root_path + end + + it "has CASA organizations section" do + expect(page).to have_text "CASA Organizations Powered by Our App" + end + + it "displays all organizations that have attached logos" do + within("#organizations") do + expect(page).to have_css(".org_logo", count: 3) + end + end + end + + describe "when some orgs are missing logos" do + before do + 4.times { create(:casa_org, :with_logo) } + 4.times { create(:casa_org) } + visit root_path + end + + it "does not display organizations that don't have attached logos" do + within("#organizations") do + expect(page).to have_css(".org_logo", count: 4) + end + end + end + end +end