Skip to content

Commit

Permalink
Fix tag icons (calagator#586)
Browse files Browse the repository at this point in the history
* deps: add uglifier for testing asset precompile
* Use appropriate check for tag icon assets depending on environment precompile setting
Fixes calagator#524
* Deprecate support for Rails pre-4.2 and add newer Ruby versions to CI
* Drop support for Ruby 2.2.x
  • Loading branch information
aeschright authored May 3, 2019
1 parent cb821d7 commit d5ff304
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 59 deletions.
17 changes: 6 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@ add_ons:
language: ruby

rvm:
- 2.2.6
- 2.3.3
- 2.4.0
- 2.3.7
- 2.4.6
- 2.5.5
- rbx-2

gemfile:
- gemfiles/rails_4_0.gemfile
- gemfiles/rails_4_1.gemfile
- gemfiles/rails_4_2.gemfile

env:
Expand All @@ -22,17 +20,14 @@ env:
matrix:
fast_finish: true
allow_failures:
- rvm: 2.4.0
- rvm: 2.5.5
- rvm: rbx-2
exclude:
- rvm: rbx-2
gemfile: gemfiles/rails_4_0.gemfile
- rvm: rbx-2
gemfile: gemfiles/rails_4_1.gemfile

before_install:
- sudo apt-get install chromium-chromedriver
- google-chrome-stable --headless --disable-gpu
- gem uninstall -i $(rvm gemdir)@global -ax bundler
- gem install bundler -v 1.17.3

before_script:
- "export PATH=$PATH:/usr/lib/chromium-browser/"
Expand Down
20 changes: 2 additions & 18 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -1,23 +1,7 @@
appraise 'rails-4-0' do
gem 'rails', '4.0.13'
gem 'turbolinks'

gem 'mysql2', '~> 0.3.18'
gem 'pg', '~> 0.18.1'
end

appraise 'rails-4-1' do
gem 'rails', '4.1.11'
gem 'turbolinks'

gem 'mysql2', '~> 0.3.18'
gem 'pg', '~> 0.18.1'
end

appraise 'rails-4-2' do
gem 'rails', '4.2.2'
gem 'rails', '4.2.11.1'
gem 'turbolinks'

gem 'mysql2', '~> 0.3.18'
gem 'mysql2', '~> 0.5.2'
gem 'pg', '~> 0.18.1'
end
9 changes: 7 additions & 2 deletions app/helpers/calagator/tags_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ def render

def text
icon = TagIcon.new(tag.name, context)
[icon.exists? && icon.image_tag, context.escape_once(tag.name)].compact.join(' ').html_safe
i = icon.exists? ? icon.image_tag : nil
[i, context.escape_once(tag.name)].compact.join(' ').html_safe
end

def url
Expand Down Expand Up @@ -46,7 +47,11 @@ def image_tag
end

def exists?
Rails.application.assets && Rails.application.assets[image_path]
if Rails.configuration.assets.compile
Rails.application.precompiled_assets.include?(image_path)
else
Rails.application.assets_manifest.assets[image_path].present?
end
end

private
Expand Down
5 changes: 3 additions & 2 deletions calagator.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ Gem::Specification.new do |s|
s.description = 'Calagator is an open source community calendaring platform'
s.license = 'MIT'

s.required_ruby_version = ['>= 2.2.0', '< 2.4.0']
s.required_ruby_version = ['>= 2.3.0', '< 2.6.0']

s.files = Dir['{app,config,lib,vendor}/**/*'] + Dir['db/**/*.rb'] + ['MIT-LICENSE.txt', 'Rakefile', 'README.md', 'rails_template.rb']
s.test_files = Dir['spec/**/*']
s.executables << 'calagator'

# When changing this Rails requirement, also update RAILS_REQUIREMENT in rails_template.rb
s.add_dependency 'rails', '~> 4.0'
s.add_dependency 'rails', '~> 4.2'

# s.add_dependency "mofo", path: "vendor/gems/mofo-0.2.8" # vendored fork with hpricot dependency replaced with nokogiri

Expand Down Expand Up @@ -67,5 +67,6 @@ Gem::Specification.new do |s|
s.add_development_dependency 'sqlite3', '~> 1.3.6'
s.add_development_dependency 'sunspot_solr', '~> 2.1'
s.add_development_dependency 'timecop', '~> 0.7.1'
s.add_development_dependency 'uglifier', '>= 1.3.0'
s.add_development_dependency 'webmock', '~> 3.5'
end
11 changes: 0 additions & 11 deletions gemfiles/rails_4_0.gemfile

This file was deleted.

11 changes: 0 additions & 11 deletions gemfiles/rails_4_1.gemfile

This file was deleted.

8 changes: 5 additions & 3 deletions gemfiles/rails_4_2.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

source 'https://rubygems.org'

gem 'rails', '4.2.11.1'
gem 'turbolinks'
gem 'recaptcha', require: 'recaptcha/rails'
gem 'byebug', platform: 'mri'
gem 'mysql2', '~> 0.3.18'
gem 'launchy'
gem 'mysql2', '~> 0.5.2'
gem 'pg', '~> 0.18.1'
gem 'rails', '4.2.2'
gem 'turbolinks'

gemspec path: '../'
2 changes: 1 addition & 1 deletion rails_template.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'rubygems'
require 'pathname'

RAILS_REQUIREMENT = '~> 4.0'.freeze
RAILS_REQUIREMENT = '~> 4.2'.freeze

def assert_minimum_rails_version
requirement = Gem::Requirement.new(RAILS_REQUIREMENT)
Expand Down
4 changes: 4 additions & 0 deletions spec/helpers/calagator/tags_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ module Calagator
it 'should render nothing if event has no tags' do
expect(helper.display_tag_icons(@untagged_event)).to eq ''
end

it 'should render an image if the event tag has one associated' do
expect(helper.display_tag_icons(@event)).to include 'img'
end
end
end
end

0 comments on commit d5ff304

Please sign in to comment.