Skip to content

Commit

Permalink
Merge pull request #466 from coopdevs/feature/add-redeira-logo
Browse files Browse the repository at this point in the history
add branded organization logo
  • Loading branch information
enricostano authored Mar 14, 2019
2 parents f421912 + f8e1f5e commit d0f2bbf
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 2 deletions.
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: '[email protected]',
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

0 comments on commit d0f2bbf

Please sign in to comment.