Skip to content

Commit

Permalink
SRCH-372 - Update Rails to compile assets (#232)
Browse files Browse the repository at this point in the history
* SRCH-372 - Update Rails to compile assets

* SRCH-355 - update compass-rails to 3.1.0
  • Loading branch information
peggles2 authored Feb 14, 2019
1 parent 2b6b6dc commit a6db54c
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 50 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ generate_top_queries_from_file_input_file.txt
Procfile
.byebug_history
config/secrets.yml
public/assets/**
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ gem 'cld3', '~> 3.2.3'
gem 'coffee-rails', '~> 4.2.2'
gem 'uglifier', '~> 4.1.2'
gem 'less-rails-bootstrap', '~> 3.3.5'
gem 'compass-rails', '~> 2.0.5'
gem 'compass-rails', '~> 3.1.0'
gem 'compass-blueprint', '~> 1.0.0'
gem 'jquery-ui-rails', '~> 6.0.1'
gem 'jquery-rails', git: 'https://github.com/GSA/jquery-rails', ref: 'c0c56208f57746a4bc63431d5e771cea4486efca'
Expand Down
27 changes: 12 additions & 15 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ GEM
capybara-screenshot (1.0.22)
capybara (>= 1.0, < 4)
launchy
chunky_png (1.3.10)
chunky_png (1.3.11)
cld3 (3.2.3)
ffi (>= 1.1.0, < 1.10.0)
climate_control (0.2.0)
Expand Down Expand Up @@ -207,10 +207,10 @@ GEM
sass (>= 3.3.0, < 3.5)
compass-import-once (1.0.5)
sass (>= 3.2, < 3.5)
compass-rails (2.0.5)
compass-rails (3.1.0)
compass (~> 1.0.0)
sass-rails (< 5.1)
sprockets (< 2.13)
sprockets (< 4.0)
concurrent-ruby (1.1.4)
cookiejar (0.3.3)
counter_culture (2.0.0)
Expand Down Expand Up @@ -347,7 +347,6 @@ GEM
hashdiff (0.3.7)
hashie (3.3.2)
highline (1.7.10)
hike (1.2.3)
html_truncator (0.4.2)
nokogiri (~> 1.5)
htmlentities (4.3.4)
Expand Down Expand Up @@ -645,15 +644,13 @@ GEM
tilt (>= 1.3, < 3)
spring (2.0.2)
activesupport (>= 4.2)
sprockets (2.12.5)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sprockets-rails (2.3.3)
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (>= 2.8, < 4.0)
sprockets (3.7.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.2.1)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
temple (0.8.0)
terminal-table (1.8.0)
unicode-display_width (~> 1.1, >= 1.1.1)
Expand All @@ -671,7 +668,7 @@ GEM
thor (0.20.3)
thread (0.2.2)
thread_safe (0.3.6)
tilt (1.4.1)
tilt (2.0.9)
timecop (0.9.1)
truncator (0.1.7)
activesupport
Expand Down Expand Up @@ -764,7 +761,7 @@ DEPENDENCIES
coffee-rails (~> 4.2.2)
colorize (~> 0.8.1)
compass-blueprint (~> 1.0.0)
compass-rails (~> 2.0.5)
compass-rails (~> 3.1.0)
counter_culture (~> 2.0.0)
cucumber-rails (~> 1.6.0)
curb (~> 0.9.4)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

// Sprite icons path
// -------------------------
@iconSpritePath: "bootstrap/glyphicons-halflings.png";
@iconWhiteSpritePath: "bootstrap/glyphicons-halflings-white.png";
@iconSpritePath: asset-url('bootstrap/glyphicons-halflings.png');
@iconWhiteSpritePath: asset-url('bootstrap/glyphicons-halflings-white.png');

.icon {
display: inline-block;
Expand Down
1 change: 1 addition & 0 deletions config/initializers/assets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@
# Rails.application.config.assets.precompile += %w( search.js )
Rails.application.config.assets.precompile += %w(font-awesome-grunticon-rails.js)
Rails.application.config.assets.precompile += %w(*.png *.gif)
Rails.application.config.assets.precompile += %w( application.css )
Rails.application.config.assets.precompile += Dir.entries("#{Rails.root}/app/assets/javascripts/").select { |e| e =~ /^(?!application\.js).+\.js$/ }
Rails.application.config.assets.precompile += Dir.entries("#{Rails.root}/app/assets/stylesheets/").select { |e| e =~ /^(?!application\.css).+\.css$/ }
7 changes: 1 addition & 6 deletions deploy/before_symlink.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,5 @@
# updated whenever our asset fingerprints change.
run <<COMPILE
cd #{release_path} && \
RAILS_ENV=#{rails_env} bundle exec rake assets:precompile && \
cd #{release_path}/public/assets && \
for js in sayt_loader_libs sayt_loader stats; do cp ${js}-#{TTHC}.js ${js}.js && cp ${js}-#{TTHC}.js.gz ${js}.js.gz; done && \
for css in sayt; do cp ${css}-#{TTHC}.css ${css}.css && cp ${css}-#{TTHC}.css.gz ${css}.css.gz; done && \
for png in bootstrap/glyphicons-halflings bootstrap/glyphicons-halflings-white; do cp ${png}-#{TTHC}.png ${png}.png; done && \
find . -type f -perm 600 | xargs --no-run-if-empty chmod 644
RAILS_ENV=#{rails_env} bundle exec rake assets:precompile
COMPILE
4 changes: 2 additions & 2 deletions features/step_definitions/affiliate_image_search_steps.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Then /^I should see the Results by (Azure|Bing) logo$/ do |engine|
page.should have_selector("img.results-by-logo.#{engine.downcase}[src^='/assets/searches/binglogo_en.gif']")
page.should have_selector("img.results-by-logo.#{engine.downcase}[src^='/assets/searches/binglogo_en']")
end

Then /^I should see the Results by USASearch logo$/ do
page.should have_selector("img[src^='/assets/searches/results_by_usasearch_en.png']")
page.should have_selector("img[src^='/assets/searches/results_by_usasearch_en']")
end
38 changes: 32 additions & 6 deletions spec/helpers/search_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,11 @@
%w(AWEB AIMAG BWEB IMAG).each do |module_tag|
it 'should see an image with alt text' do
html = helper.search_results_by_logo(module_tag)
expect(html).to have_selector("img[alt='Results by Bing'][src^='/assets/searches/binglogo_en.gif']")
expect(html).
to have_selector(
"img[alt='Results by Bing']" \
"[src^='/assets/searches/binglogo_en']"
)
end
end
end
Expand All @@ -289,15 +293,24 @@
%w(GWEB GIMAG).each do |module_tag|
it 'should see an image with alt text' do
html = helper.search_results_by_logo(module_tag)
expect(html).to have_selector("img[alt='Results by Google'][src^='/assets/searches/googlelogo_en.gif']")
expect(html).
to have_selector(
"img[alt='Results by Google']" \
"[src^='/assets/searches/googlelogo_en']"
)
end
end
end

context 'when results by USASearch' do
it 'should see an image with alt text' do
html = helper.search_results_by_logo('whatevs')
expect(html).to have_selector("a[href='https://search.gov'] img[alt='Results by USASearch'][src^='/assets/searches/results_by_usasearch_en.png']")
expect(html).
to have_selector(
"a[href='https://search.gov'] " \
"img[alt='Results by USASearch']" \
"[src^='/assets/searches/results_by_usasearch_en']"
)
end
end
end
Expand All @@ -310,7 +323,11 @@
%w(BWEB IMAG).each do |module_tag|
it 'should see an image with alt text' do
html = helper.search_results_by_logo(module_tag)
expect(html).to have_selector("img[alt='Resultados por Bing'][src^='/assets/searches/binglogo_es.gif']")
expect(html).
to have_selector(
"img[alt='Resultados por Bing']" \
"[src^='/assets/searches/binglogo_es']"
)
end
end
end
Expand All @@ -319,15 +336,24 @@
%w(GWEB GIMAG).each do |module_tag|
it 'should see an image with alt text' do
html = helper.search_results_by_logo(module_tag)
expect(html).to have_selector("img[alt='Resultados por Google'][src^='/assets/searches/googlelogo_es.gif']")
expect(html).
to have_selector(
"img[alt='Resultados por Google']" \
"[src^='/assets/searches/googlelogo_es']"
)
end
end
end

context 'when results by USASearch' do
it 'should see an image with alt text' do
html = helper.search_results_by_logo('whatevs')
expect(html).to have_selector("a[href='https://search.gov'] img[alt='Resultados por USASearch'][src^='/assets/searches/results_by_usasearch_es.png']")
expect(html).
to have_selector(
"a[href='https://search.gov'] " \
"img[alt='Resultados por USASearch']" \
"[src^='/assets/searches/results_by_usasearch_es']"
)
end
end
end
Expand Down
50 changes: 32 additions & 18 deletions spec/views/shared/_searchresults.html.haml_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,58 +47,72 @@
end
end

context "when results are by USASearch" do
it "should show the Bing logo" do
context 'when results are by USASearch' do
it 'should show the Bing logo' do
render
expect(rendered).to have_selector("img[src^='/assets/searches/binglogo_en.gif']")
expect(rendered).not_to have_selector("a img[src^='/assets/searches/binglogo_en.gif']")
expect(rendered).
to have_selector("img[src^='/assets/searches/binglogo_en']")
expect(rendered).
not_to have_selector("a img[src^='/assets/searches/binglogo_en']")
end
end

context "when results are by USASearch" do
context 'when results are by USASearch' do
before do
allow(@search).to receive(:module_tag).and_return 'AIDOC'
allow(view).to receive(:search).and_return @search
end

it "should show the English USASearch results by logo" do
it 'should show the English USASearch results by logo' do
render
expect(rendered).to have_selector("a[href='https://search.gov'] img[src^='/assets/searches/results_by_usasearch_en.png']")
expect(rendered).
to have_selector(
'a[href="https://search.gov"] ' \
'img[src^="/assets/searches/results_by_usasearch_en"]'
)
end

context "when the locale is Spanish" do
context 'when the locale is Spanish' do
before do
allow(I18n).to receive(:locale).and_return :es
end

it "should show the Spanish USASearch results by logo" do
it 'should show the Spanish USASearch results by logo' do
render
expect(rendered).to have_selector("a[href='https://search.gov'] img[src^='/assets/searches/results_by_usasearch_es.png']")
expect(rendered).
to have_selector(
'a[href="https://search.gov"] ' \
'img[src^="/assets/searches/results_by_usasearch_es"]'
)
end
end
end

context "when results are by Google" do
context 'when results are by Google' do
before do
allow(@search).to receive(:module_tag).and_return 'GWEB'
allow(view).to receive(:search).and_return @search
end

it "should show the English Google results by logo" do
it 'should show the English Google results by logo' do
render
expect(rendered).to have_selector("img[src^='/assets/searches/googlelogo_en.gif']")
expect(rendered).not_to have_selector("a img[src^='/assets/searches/googlelogo_en.gif']")
expect(rendered).
to have_selector('img[src^="/assets/searches/googlelogo_en"]')
expect(rendered).
not_to have_selector('a img[src^="/assets/searches/googlelogo_en"]')
end

context "when the locale is Spanish" do
context 'when the locale is Spanish' do
before do
allow(I18n).to receive(:locale).and_return :es
end

it "should show the Spanish Google results by logo" do
it 'should show the Spanish Google results by logo' do
render
expect(rendered).to have_selector("img[src^='/assets/searches/googlelogo_es.gif']")
expect(rendered).not_to have_selector("a img[src^='/assets/searches/googlelogo_es.gif']")
expect(rendered).
to have_selector('img[src^="/assets/searches/googlelogo_es"]')
expect(rendered).
not_to have_selector('a img[src^="/assets/searches/googlelogo_es"]')
end
end
end
Expand Down

0 comments on commit a6db54c

Please sign in to comment.