Skip to content

add branded organization logo #466

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

Merged
merged 2 commits into from
Mar 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Binary file added app/assets/images/redeira.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions app/helpers/brand_logo_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module BrandLogoHelper
def render_brand_logo
return unless should_render_logo?
render 'application/brand_logo'
end

private

def should_render_logo?
return false unless current_user
current_organization&.id == branded_organization_id
end

def branded_organization_id
Rails.application.config.branded_organization_id
end
end
3 changes: 3 additions & 0 deletions app/views/application/_brand_logo.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div class="container" style="margin-bottom: 30px">
<%= image_tag("redeira.png", class: 'organization-brand-logo img-responsive center-block') %>
</div>
1 change: 1 addition & 0 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
</div>
</div>

<%= render_brand_logo %>
<%= render 'application/footer' %>

<div class="back-overlay"></div>
Expand Down
7 changes: 7 additions & 0 deletions config/initializers/branded_organization.rb
Original file line number Diff line number Diff line change
@@ -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
41 changes: 41 additions & 0 deletions spec/features/brand_logo_spec.rb
Original file line number Diff line number Diff line change
@@ -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

2 changes: 0 additions & 2 deletions spec/features/create_offer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down