Skip to content

Commit d0f2bbf

Browse files
authored
Merge pull request #466 from coopdevs/feature/add-redeira-logo
add branded organization logo
2 parents f421912 + f8e1f5e commit d0f2bbf

File tree

7 files changed

+69
-2
lines changed

7 files changed

+69
-2
lines changed

app/assets/images/redeira.png

24.1 KB
Loading

app/helpers/brand_logo_helper.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module BrandLogoHelper
2+
def render_brand_logo
3+
return unless should_render_logo?
4+
render 'application/brand_logo'
5+
end
6+
7+
private
8+
9+
def should_render_logo?
10+
return false unless current_user
11+
current_organization&.id == branded_organization_id
12+
end
13+
14+
def branded_organization_id
15+
Rails.application.config.branded_organization_id
16+
end
17+
end
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<div class="container" style="margin-bottom: 30px">
2+
<%= image_tag("redeira.png", class: 'organization-brand-logo img-responsive center-block') %>
3+
</div>

app/views/layouts/application.html.erb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
</div>
2727
</div>
2828

29+
<%= render_brand_logo %>
2930
<%= render 'application/footer' %>
3031

3132
<div class="back-overlay"></div>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
DEFAULT_BRANDED_ORG_ID = 246
2+
3+
Rails.application.config.branded_organization_id = nil
4+
5+
unless Rails.env.test?
6+
Rails.application.config.branded_organization_id = (Redis.current.get('branded_organization_id') || DEFAULT_BRANDED_ORG_ID).to_i
7+
end

spec/features/brand_logo_spec.rb

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
require 'spec_helper'
2+
3+
RSpec.feature 'sign in' do
4+
let(:user) do
5+
user = Fabricate(
6+
:user,
7+
email: 'user@timeoverflow.org',
8+
password: 'papapa22',
9+
terms_accepted_at: 1.day.from_now
10+
)
11+
12+
user.add_to_organization(organization)
13+
14+
user
15+
end
16+
17+
let(:organization) { Fabricate(:organization) }
18+
19+
context 'with a branded org id' do
20+
before do
21+
allow(Rails.application.config).to receive(:branded_organization_id).and_return(organization.id)
22+
sign_in_with(user.email, user.password)
23+
end
24+
25+
it 'renders the logo' do
26+
expect(page).to have_css('.organization-brand-logo')
27+
end
28+
end
29+
30+
context 'without a branded org id' do
31+
before do
32+
allow(Rails.application.config).to receive(:branded_organization_id).and_return(1234)
33+
sign_in_with(user.email, user.password)
34+
end
35+
36+
it 'does not render the logo' do
37+
expect(page).to have_no_css('.organization-brand-logo')
38+
end
39+
end
40+
end
41+

spec/features/create_offer_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@
3131

3232
# TODO there are two i18n keys for getting "Crear oferta" copy ( one returns 'Crear oferta' and the other 'Crear Oferta' )
3333
click_on I18n.t('offers.new.submit', model: I18n.t('activerecord.models.offer.one'))
34-
35-
page.save_screenshot('create-offer-yolo.png')
3634
end
3735
end
3836
end

0 commit comments

Comments
 (0)