From cca27d8651be5332dc71f31c834febf131e05452 Mon Sep 17 00:00:00 2001 From: Mohamed Wael Khobalatte Date: Mon, 19 Oct 2015 16:33:27 +0200 Subject: [PATCH] Centralize favicons in one template and add Apple ones --- .../apple-touch-icon-120x120-precomposed.png | Bin 0 -> 2612 bytes app/views/common/_favicons.html.erb | 6 +++ app/views/layouts/base.html.erb | 2 +- spec/views/layouts/base.html.erb_spec.rb | 37 ++++++++++++++++++ 4 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 app/assets/images/apple-touch-icon-120x120-precomposed.png create mode 100644 app/views/common/_favicons.html.erb diff --git a/app/assets/images/apple-touch-icon-120x120-precomposed.png b/app/assets/images/apple-touch-icon-120x120-precomposed.png new file mode 100644 index 0000000000000000000000000000000000000000..d329190cca34465dd77328ce6922f17d4ba0ac6d GIT binary patch literal 2612 zcmbuBXFMB<0>!lrVwH<)kH(5xwYOBvs-jh@MsR5_f>g~|Ay&DlqNSzxVn5-g_U;IbY8CeEta!&5cIfRVy9l^0+0uhgZ$4G*T!)D4?(44 zMclXmkKfAm2Z!Vg6TE$8@>>mGAuxgN6)uklOae!1#U#qEgw$)sKVq>jMzMDq+)F)E zpR=yf3mmQ1@%xu-j_U77jux|WmS)i&FernN9Q^_jC-_*t3uGQtMcNcm23>B(h{c6^ zOxsphYcy-j=e-!opya@s7BmTsc0d%rm=LP{cwFUl1tZi_PV4f8Z`Y8csybN8&Ea&R z>h>wg3t|V(vJpSi9kqgMb)%{(+n^OYb$h9U^}$;b$;+IfaC6XpZ$V|_aOBtgc1I7y z(cV2G1{sA@g@vrTguCjgu;0@UjN(1rxkJ!*EW88x>)h!owD*bcr5)y-LkFq;D4>?p zR3M^%LLf-N>dJGVK(m*UUrx4h>e@)-*y&tD))zDluN+loNWV#zWd)O1@sid1v?3G9 zG<@1JT^02XAxxqs0^W-{$nqPCx-nnpWx&R2=$aAXuVXN!$DFkmRpT!yDctsl8wcL- zCbEW)>=raGjFl^DNmsYnV)o;-fGU(|UxX<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=9O1Aq+@t&QZ@@VZeoIWnHd%lB-tN;Ff4(r@ zQRnaML>K;Ey;Em%wMzVCwukOw<$gNxbDlY!MMr*!%8z_+oId^io8d? + +<%# In the future we can add more sizes should we see 404 errors in the logs. %> +<%= favicon_link_tag "apple-touch-icon-120x120-precomposed.png", rel: 'apple-touch-icon', + type: 'image/png', + sizes: "120x120" %> diff --git a/app/views/layouts/base.html.erb b/app/views/layouts/base.html.erb index c6d306b8ba..6cf4de2308 100644 --- a/app/views/layouts/base.html.erb +++ b/app/views/layouts/base.html.erb @@ -38,7 +38,7 @@ See doc/COPYRIGHT.rdoc for more details. <%= csrf_meta_tags %> - <%= favicon_link_tag 'favicon.ico' %> + <%= render 'common/favicons' %> <%= stylesheet_link_tag current_theme.stylesheet_manifest, :media => "all" %> <% if User.current.impaired? && accessibility_css_enabled? %> <%= stylesheet_link_tag 'accessibility' %> diff --git a/spec/views/layouts/base.html.erb_spec.rb b/spec/views/layouts/base.html.erb_spec.rb index f1a5e5bdf8..1b6d4f2ba5 100644 --- a/spec/views/layouts/base.html.erb_spec.rb +++ b/spec/views/layouts/base.html.erb_spec.rb @@ -29,6 +29,11 @@ require 'spec_helper' describe 'layouts/base', type: :view do + # This is to make `visit` available. It might be already included by the time + # we reach this spec, but for running this spec alone we need it here. Best + # of both worlds. + include Capybara::DSL + include Redmine::MenuManager::MenuHelper helper Redmine::MenuManager::MenuHelper let!(:user) { FactoryGirl.create :user } @@ -124,4 +129,36 @@ describe 'layouts/base', type: :view do end end end + + + describe 'icons' do + before do + allow(User).to receive(:current).and_return anonymous + allow(view).to receive(:current_user).and_return anonymous + render + end + + it 'renders main favicon' do + expect(rendered).to have_selector("link[rel='shortcut icon'][type='image/x-icon'][href='/assets/favicon.ico']", visible: false) + end + + it 'renders apple icons' do + expect(rendered).to have_selector("link[rel='apple-touch-icon'][type='image/png'][href='/assets/apple-touch-icon-120x120-precomposed.png']", visible: false) + end + + # We perform a get request against the icons to ensure they are there (and + # avoid 404 errors in production). Should you continue to see 404s in production, + # ensure your asset cache is not stale. + + # We do this here as opposed to a request spec to 1. keep icon specs contained + # in one place, and 2. the view itself makes this request, so this is an appropriate + # location for it. + it 'icons actually exist' do + visit 'assets/favicon.ico' + expect(page.status_code).to eq(200) + + visit 'apple-touch-icon-120x120-precomposed.png' + expect(page.status_code).to eq(200) + end + end end