From d662ebd25231546d09aa782f344b698d66b247c8 Mon Sep 17 00:00:00 2001 From: Aditya Prakash Date: Thu, 21 Apr 2016 21:22:14 +0530 Subject: [PATCH] Remove sponsorship level from view and test --- INSTALL.md | 9 ++++++ app/views/conference/_sponsors.html.haml | 9 ++---- spec/helpers/sponsor_helper_spec.rb | 40 ++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 6 deletions(-) create mode 100644 spec/helpers/sponsor_helper_spec.rb diff --git a/INSTALL.md b/INSTALL.md index 9ee16f86..69d4a15f 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -63,6 +63,15 @@ We recommend to run OSEM in production with [mod_passenger](https://www.phusionp and the [apache web-server](https://www.apache.org/). There are tons of guides on how to deploy rails apps on various base operating systems. Check Google ;-) +#### ImageMagick +We use imagemagic for image manipulation of sponsor logo. You can get it from [direct install](http://software.opensuse.org/package/ImageMagick) page of the package or else check out [Download page](http://www.imagemagick.org/script/binary-releases.php) of ImageMagick. + +If you are upgrading your osem instance and would like to resize the exisiting logos, you would need to `reprocess!` the images: +``` +$ rails c +> Sponsor.find_each { |s| s.logo.reprocess! } +``` + #### Use openID In order to use the OpenID feature you need to register your application with the providers (Google and Facebook) and enter their API keys in config/secrets.yml file, changing the existing sample values. diff --git a/app/views/conference/_sponsors.html.haml b/app/views/conference/_sponsors.html.haml index e50c838a..dd202657 100644 --- a/app/views/conference/_sponsors.html.haml +++ b/app/views/conference/_sponsors.html.haml @@ -4,16 +4,14 @@ .container .row - .col-md-12 + .col-md-12.text-center %h2 Sponsors - @conference.sponsorship_levels.each do |sponsorship_level| -if sponsorship_level.sponsors.any? - %h4 - = sponsorship_level.title - sponsorship_level.sponsors.each_slice(3) do |slice| - .row + .row.row-centered - slice.each do |sponsor| - .col-md-4.col-sm-4.col-top + .col-md-4.col-sm-4.col-centered.col-top %a{ href: '#', data: { toggle: 'modal', target: "#modal_#{sponsor.id}" } } = image_tag get_logo(sponsor), class: "img-responsive img-sponsor img-sponsor-#{sponsorship_level.position}" @@ -41,4 +39,3 @@ Want to sponsor #{@conference.short_title}? = link_to("mailto: #{@conference.contact.sponsor_email}?subject=#{@conference.short_title}%20Sponsorship") do Please contact us! - diff --git a/spec/helpers/sponsor_helper_spec.rb b/spec/helpers/sponsor_helper_spec.rb new file mode 100644 index 00000000..492f9df5 --- /dev/null +++ b/spec/helpers/sponsor_helper_spec.rb @@ -0,0 +1,40 @@ +require 'spec_helper' + +describe SponsorsHelper, type: :helper do + let(:sponsor) { create(:sponsor) } + + describe '#get_logo' do + context 'first sponsorship_level' do + before do + first_sponsorship_level = create(:sponsorship_level, position: 1) + sponsor.update_attributes(sponsorship_level: first_sponsorship_level) + end + + it 'returns correct url' do + expect(get_logo(sponsor)).to match %r{.*(\bfirst/rails.jpg\b)} + end + end + + context 'second sponsorship_level' do + before do + second_sponsorship_level = create(:sponsorship_level, position: 2) + sponsor.update_attributes(sponsorship_level: second_sponsorship_level) + end + + it 'returns correct url' do + expect(get_logo(sponsor)).to match %r{.*(\bsecond/rails.jpg\b)} + end + end + + context 'other sponsorship_level' do + before do + other_sponsorship_level = create(:sponsorship_level, position: 3) + sponsor.update_attributes(sponsorship_level: other_sponsorship_level) + end + + it 'returns correct url' do + expect(get_logo(sponsor)).to match %r{.*(\bothers/rails.jpg\b)} + end + end + end +end