diff --git a/app/assets/images/redeira.png b/app/assets/images/redeira.png new file mode 100644 index 000000000..1806f0428 Binary files /dev/null and b/app/assets/images/redeira.png differ diff --git a/app/helpers/brand_logo_helper.rb b/app/helpers/brand_logo_helper.rb new file mode 100644 index 000000000..ecbe7b51c --- /dev/null +++ b/app/helpers/brand_logo_helper.rb @@ -0,0 +1,16 @@ +module BrandLogoHelper + def render_brand_logo + return unless should_render_logo? + render 'application/brand_logo' + end + + private + + def should_render_logo? + current_organization&.id == branded_organization_id + end + + def branded_organization_id + Rails.application.config.branded_organization_id + end +end diff --git a/app/views/application/_brand_logo.html.erb b/app/views/application/_brand_logo.html.erb new file mode 100644 index 000000000..4959dfd88 --- /dev/null +++ b/app/views/application/_brand_logo.html.erb @@ -0,0 +1,3 @@ +
+ <%= image_tag("redeira.png", class: 'organization-brand-logo img-responsive center-block') %> +
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 333227399..08ae6962d 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -26,6 +26,7 @@ + <%= render_brand_logo %> <%= render 'application/footer' %>
diff --git a/config/initializers/branded_organization.rb b/config/initializers/branded_organization.rb new file mode 100644 index 000000000..17bbac2b0 --- /dev/null +++ b/config/initializers/branded_organization.rb @@ -0,0 +1,7 @@ +DEFAULT_BRANDED_ORG_ID = 246 + +Rails.application.config.branded_organization_id = nil + +unless Rails.env.test? + Rails.application.config.branded_organization_id = (Redis.current.get('branded_organization_id') || DEFAULT_BRANDED_ORG_ID).to_i +end diff --git a/spec/features/brand_logo_spec.rb b/spec/features/brand_logo_spec.rb new file mode 100644 index 000000000..bd89399f3 --- /dev/null +++ b/spec/features/brand_logo_spec.rb @@ -0,0 +1,41 @@ +require 'spec_helper' + +RSpec.feature 'sign in' do + let(:user) do + user = Fabricate( + :user, + email: 'user@timeoverflow.org', + password: 'papapa22', + terms_accepted_at: 1.day.from_now + ) + + user.add_to_organization(organization) + + user + end + + let(:organization) { Fabricate(:organization) } + + context 'with a branded org id' do + before do + allow(Rails.application.config).to receive(:branded_organization_id).and_return(organization.id) + sign_in_with(user.email, user.password) + end + + it 'renders the logo' do + expect(page).to have_css('.organization-brand-logo') + end + end + + context 'without a branded org id' do + before do + allow(Rails.application.config).to receive(:branded_organization_id).and_return(1234) + sign_in_with(user.email, user.password) + end + + it 'does not render the logo' do + expect(page).to have_no_css('.organization-brand-logo') + end + end +end + diff --git a/spec/features/create_offer_spec.rb b/spec/features/create_offer_spec.rb index 75b9a107d..523e7b4c3 100644 --- a/spec/features/create_offer_spec.rb +++ b/spec/features/create_offer_spec.rb @@ -31,8 +31,6 @@ # TODO there are two i18n keys for getting "Crear oferta" copy ( one returns 'Crear oferta' and the other 'Crear Oferta' ) click_on I18n.t('offers.new.submit', model: I18n.t('activerecord.models.offer.one')) - - page.save_screenshot('create-offer-yolo.png') end end end