Merge pull request #223 from okkez/rails5.x

Update Rails to 5.2.0
This commit is contained in:
okkez 2018-04-20 17:31:23 +09:00 committed by GitHub
commit 620e88c1a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 335 additions and 334 deletions

View File

@ -1,9 +1,21 @@
rvm: 2.1.3 rvm: 2.2.10
sudo: required sudo: required
addons:
- chrome: stable
env:
global:
DISPLAY: ":99.0"
before_install:
- google-chrome-stable --version
- wget http://chromedriver.storage.googleapis.com/2.35/chromedriver_linux64.zip
- unzip chromedriver_linux64.zip
- sudo mv chromedriver /usr/local/bin/chromedriver
install: install:
- bundle -v - bundle -v
- gem i bundler - gem i bundler
- sudo sh -c 'curl -L https://toolbelt.treasuredata.com/sh/install-ubuntu-precise-td-agent2.sh | sh' - sudo sh -c 'curl -L https://toolbelt.treasuredata.com/sh/install-ubuntu-trusty-td-agent2.sh | sh'
- bundle install --jobs=4 --retry=4 - bundle install --jobs=4 --retry=4

12
Gemfile
View File

@ -12,17 +12,17 @@ group :development, :test do
end end
group :development do group :development do
gem 'i18n_generators', '1.2.1' gem 'i18n_generators', '2.1.1'
gem 'better_errors' gem 'better_errors'
gem 'web-console', '~> 2.0' gem 'web-console', '~> 3.6'
end end
group :test do group :test do
gem "factory_girl_rails" gem "factory_bot_rails"
gem "capybara", "~> 2.4.0" gem "capybara", "~> 3.0.2"
gem "capybara-screenshot" gem "capybara-screenshot"
gem "simplecov", "~> 0.16.1", require: false gem "simplecov", "~> 0.16.1", require: false
gem "webmock", "~> 1.18.0" gem "webmock", "~> 3.3.0"
gem "timecop" gem "timecop"
gem "poltergeist" gem "selenium-webdriver", "~> 3.11"
end end

View File

@ -5,7 +5,7 @@ PATH
addressable addressable
bundler bundler
diff-lcs diff-lcs
draper (~> 2.1) draper (~> 3.0)
fluentd (>= 0.10.56, < 0.14) fluentd (>= 0.10.56, < 0.14)
font-awesome-rails font-awesome-rails
haml-rails (~> 1.0) haml-rails (~> 1.0)
@ -15,109 +15,104 @@ PATH
kramdown (> 1.0.0) kramdown (> 1.0.0)
kramdown-haml kramdown-haml
puma puma
rails (~> 4.2.0) rails (~> 5.2.0)
rubyzip (~> 1.1) rubyzip (~> 1.1)
sass-rails (~> 4.0.3) sass-rails (~> 5.0.7)
settingslogic settingslogic
sucker_punch (~> 1.6.0) sucker_punch (~> 2.0.4)
thor thor
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
actionmailer (4.2.10) actioncable (5.2.0)
actionpack (= 4.2.10) actionpack (= 5.2.0)
actionview (= 4.2.10) nio4r (~> 2.0)
activejob (= 4.2.10) websocket-driver (>= 0.6.1)
actionmailer (5.2.0)
actionpack (= 5.2.0)
actionview (= 5.2.0)
activejob (= 5.2.0)
mail (~> 2.5, >= 2.5.4) mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 1.0, >= 1.0.5) rails-dom-testing (~> 2.0)
actionpack (4.2.10) actionpack (5.2.0)
actionview (= 4.2.10) actionview (= 5.2.0)
activesupport (= 4.2.10) activesupport (= 5.2.0)
rack (~> 1.6) rack (~> 2.0)
rack-test (~> 0.6.2) rack-test (>= 0.6.3)
rails-dom-testing (~> 1.0, >= 1.0.5) rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2) rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (4.2.10) actionview (5.2.0)
activesupport (= 4.2.10) activesupport (= 5.2.0)
builder (~> 3.1) builder (~> 3.1)
erubis (~> 2.7.0) erubi (~> 1.4)
rails-dom-testing (~> 1.0, >= 1.0.5) rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3) rails-html-sanitizer (~> 1.0, >= 1.0.3)
activejob (4.2.10) activejob (5.2.0)
activesupport (= 4.2.10) activesupport (= 5.2.0)
globalid (>= 0.3.0) globalid (>= 0.3.6)
activemodel (4.2.10) activemodel (5.2.0)
activesupport (= 4.2.10) activesupport (= 5.2.0)
activemodel-serializers-xml (1.0.2)
activemodel (> 5.x)
activesupport (> 5.x)
builder (~> 3.1) builder (~> 3.1)
activerecord (4.2.10) activerecord (5.2.0)
activemodel (= 4.2.10) activemodel (= 5.2.0)
activesupport (= 4.2.10) activesupport (= 5.2.0)
arel (~> 6.0) arel (>= 9.0)
activesupport (4.2.10) activestorage (5.2.0)
i18n (~> 0.7) actionpack (= 5.2.0)
activerecord (= 5.2.0)
marcel (~> 0.3.1)
activesupport (5.2.0)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1) minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1) tzinfo (~> 1.1)
addressable (2.5.1) addressable (2.5.2)
public_suffix (~> 2.0, >= 2.0.2) public_suffix (>= 2.0.2, < 4.0)
arel (6.0.4) arel (9.0.0)
better_errors (2.1.1) better_errors (2.1.1)
coderay (>= 1.0.0) coderay (>= 1.0.0)
erubis (>= 2.6.6) erubis (>= 2.6.6)
rack (>= 0.9.0) rack (>= 0.9.0)
binding_of_caller (0.7.2) bindex (0.5.0)
debug_inspector (>= 0.0.1)
builder (3.2.3) builder (3.2.3)
capybara (2.4.4) capybara (3.0.2)
mime-types (>= 1.16) addressable
nokogiri (>= 1.3.3) mini_mime (>= 0.1.3)
rack (>= 1.0.0) nokogiri (~> 1.8)
rack-test (>= 0.5.4) rack (>= 1.6.0)
xpath (~> 2.0) rack-test (>= 0.6.3)
capybara-screenshot (1.0.14) xpath (~> 3.0)
capybara (>= 1.0, < 3) capybara-screenshot (1.0.19)
capybara (>= 1.0, < 4)
launchy launchy
celluloid (0.17.3) childprocess (0.9.0)
celluloid-essentials ffi (~> 1.0, >= 1.0.11)
celluloid-extras
celluloid-fsm
celluloid-pool
celluloid-supervision
timers (>= 4.1.1)
celluloid-essentials (0.20.5)
timers (>= 4.1.1)
celluloid-extras (0.20.5)
timers (>= 4.1.1)
celluloid-fsm (0.20.5)
timers (>= 4.1.1)
celluloid-pool (0.20.5)
timers (>= 4.1.1)
celluloid-supervision (0.20.6)
timers (>= 4.1.1)
cliver (0.3.2)
coderay (1.1.1) coderay (1.1.1)
concurrent-ruby (1.0.5) concurrent-ruby (1.0.5)
cool.io (1.5.3) cool.io (1.5.3)
crack (0.4.3) crack (0.4.3)
safe_yaml (~> 1.0.0) safe_yaml (~> 1.0.0)
crass (1.0.4) crass (1.0.4)
debug_inspector (0.0.2)
diff-lcs (1.3) diff-lcs (1.3)
docile (1.3.0) docile (1.3.0)
domain_name (0.5.20170404) draper (3.0.1)
unf (>= 0.0.5, < 1.0.0) actionpack (~> 5.0)
draper (2.1.0) activemodel (~> 5.0)
actionpack (>= 3.0) activemodel-serializers-xml (~> 1.0)
activemodel (>= 3.0) activesupport (~> 5.0)
activesupport (>= 3.0)
request_store (~> 1.0) request_store (~> 1.0)
erubi (1.7.1)
erubis (2.7.0) erubis (2.7.0)
factory_girl (4.8.0) factory_bot (4.8.2)
activesupport (>= 3.0.0) activesupport (>= 3.0.0)
factory_girl_rails (4.8.0) factory_bot_rails (4.8.2)
factory_girl (~> 4.8.0) factory_bot (~> 4.8.2)
railties (>= 3.0.0) railties (>= 3.0.0)
ffi (1.9.23)
fluentd (0.12.43) fluentd (0.12.43)
cool.io (>= 1.2.2, < 2.0.0) cool.io (>= 1.2.2, < 2.0.0)
http_parser.rb (>= 0.5.1, < 0.7.0) http_parser.rb (>= 0.5.1, < 0.7.0)
@ -141,26 +136,22 @@ GEM
haml (>= 4.0.6, < 6.0) haml (>= 4.0.6, < 6.0)
html2haml (>= 1.0.1) html2haml (>= 1.0.1)
railties (>= 4.0.1) railties (>= 4.0.1)
hike (1.2.3) hashdiff (0.3.7)
hitimes (1.2.6)
html2haml (2.2.0) html2haml (2.2.0)
erubis (~> 2.7.0) erubis (~> 2.7.0)
haml (>= 4.0, < 6) haml (>= 4.0, < 6)
nokogiri (>= 1.6.0) nokogiri (>= 1.6.0)
ruby_parser (~> 3.5) ruby_parser (~> 3.5)
http-cookie (1.0.3)
domain_name (~> 0.5)
http_parser.rb (0.6.0) http_parser.rb (0.6.0)
httpclient (2.8.3) httpclient (2.8.3)
i18n (0.9.5) i18n (1.0.1)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
i18n_generators (1.2.1) i18n_generators (2.1.1)
mechanize
rails (>= 3.0.0) rails (>= 3.0.0)
jbuilder (2.7.0) jbuilder (2.7.0)
activesupport (>= 4.2.0) activesupport (>= 4.2.0)
multi_json (>= 1.2) multi_json (>= 1.2)
jquery-rails (4.3.1) jquery-rails (4.3.3)
rails-dom-testing (>= 1, < 3) rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0) railties (>= 4.2.0)
thor (>= 0.14, < 2.0) thor (>= 0.14, < 2.0)
@ -175,69 +166,57 @@ GEM
nokogiri (>= 1.5.9) nokogiri (>= 1.5.9)
mail (2.7.0) mail (2.7.0)
mini_mime (>= 0.1.1) mini_mime (>= 0.1.1)
mechanize (2.7.5) marcel (0.3.2)
domain_name (~> 0.5, >= 0.5.1) mimemagic (~> 0.3.2)
http-cookie (~> 1.0)
mime-types (>= 1.17.2)
net-http-digest_auth (~> 1.1, >= 1.1.1)
net-http-persistent (~> 2.5, >= 2.5.2)
nokogiri (~> 1.6)
ntlm-http (~> 0.1, >= 0.1.1)
webrobots (>= 0.0.9, < 0.2)
method_source (0.8.2) method_source (0.8.2)
mime-types (3.1) mimemagic (0.3.2)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mini_mime (1.0.0) mini_mime (1.0.0)
mini_portile2 (2.3.0) mini_portile2 (2.3.0)
minitest (5.11.3) minitest (5.11.3)
msgpack (1.2.4) msgpack (1.2.4)
multi_json (1.13.1) multi_json (1.13.1)
net-http-digest_auth (1.4.1) nio4r (2.3.0)
net-http-persistent (2.9.4)
nokogiri (1.8.2) nokogiri (1.8.2)
mini_portile2 (~> 2.3.0) mini_portile2 (~> 2.3.0)
ntlm-http (0.1.1)
poltergeist (1.14.0)
capybara (~> 2.1)
cliver (~> 0.3.1)
websocket-driver (>= 0.2.0)
pry (0.10.4) pry (0.10.4)
coderay (~> 1.1.0) coderay (~> 1.1.0)
method_source (~> 0.8.1) method_source (~> 0.8.1)
slop (~> 3.4) slop (~> 3.4)
pry-rails (0.3.6) pry-rails (0.3.6)
pry (>= 0.10.4) pry (>= 0.10.4)
public_suffix (2.0.5) public_suffix (3.0.2)
puma (3.11.4) puma (3.11.4)
rack (1.6.9) rack (2.0.4)
rack-test (0.6.3) rack-test (1.0.0)
rack (>= 1.0) rack (>= 1.0, < 3)
rails (4.2.10) rails (5.2.0)
actionmailer (= 4.2.10) actioncable (= 5.2.0)
actionpack (= 4.2.10) actionmailer (= 5.2.0)
actionview (= 4.2.10) actionpack (= 5.2.0)
activejob (= 4.2.10) actionview (= 5.2.0)
activemodel (= 4.2.10) activejob (= 5.2.0)
activerecord (= 4.2.10) activemodel (= 5.2.0)
activesupport (= 4.2.10) activerecord (= 5.2.0)
bundler (>= 1.3.0, < 2.0) activestorage (= 5.2.0)
railties (= 4.2.10) activesupport (= 5.2.0)
sprockets-rails bundler (>= 1.3.0)
rails-deprecated_sanitizer (1.0.3) railties (= 5.2.0)
activesupport (>= 4.2.0.alpha) sprockets-rails (>= 2.0.0)
rails-dom-testing (1.0.9) rails-dom-testing (2.0.3)
activesupport (>= 4.2.0, < 5.0) activesupport (>= 4.2.0)
nokogiri (~> 1.6) nokogiri (>= 1.6)
rails-deprecated_sanitizer (>= 1.0.1)
rails-html-sanitizer (1.0.4) rails-html-sanitizer (1.0.4)
loofah (~> 2.2, >= 2.2.2) loofah (~> 2.2, >= 2.2.2)
railties (4.2.10) railties (5.2.0)
actionpack (= 4.2.10) actionpack (= 5.2.0)
activesupport (= 4.2.10) activesupport (= 5.2.0)
method_source
rake (>= 0.8.7) rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0) thor (>= 0.18.1, < 2.0)
rake (12.3.1) rake (12.3.1)
rb-fsevent (0.10.3)
rb-inotify (0.9.10)
ffi (>= 0.5.0, < 2)
request_store (1.4.1) request_store (1.4.1)
rack (>= 1.4) rack (>= 1.4)
rspec-core (3.5.4) rspec-core (3.5.4)
@ -261,12 +240,20 @@ GEM
sexp_processor (~> 4.9) sexp_processor (~> 4.9)
rubyzip (1.2.1) rubyzip (1.2.1)
safe_yaml (1.0.4) safe_yaml (1.0.4)
sass (3.2.19) sass (3.5.6)
sass-rails (4.0.5) sass-listen (~> 4.0.0)
railties (>= 4.0.0, < 5.0) sass-listen (4.0.0)
sass (~> 3.2.2) rb-fsevent (~> 0.9, >= 0.9.4)
sprockets (~> 2.8, < 3.0) rb-inotify (~> 0.9, >= 0.9.7)
sprockets-rails (~> 2.0) sass-rails (5.0.7)
railties (>= 4.0.0, < 6)
sass (~> 3.1)
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3)
selenium-webdriver (3.11.0)
childprocess (~> 0.5)
rubyzip (~> 1.2)
settingslogic (2.0.9) settingslogic (2.0.9)
sexp_processor (4.11.0) sexp_processor (4.11.0)
sigdump (0.2.4) sigdump (0.2.4)
@ -276,46 +263,39 @@ GEM
simplecov-html (~> 0.10.0) simplecov-html (~> 0.10.0)
simplecov-html (0.10.2) simplecov-html (0.10.2)
slop (3.6.0) slop (3.6.0)
sprockets (2.12.4) sprockets (3.7.1)
hike (~> 1.2) concurrent-ruby (~> 1.0)
multi_json (~> 1.0) rack (> 1, < 3)
rack (~> 1.0) sprockets-rails (3.2.1)
tilt (~> 1.1, != 1.3.0) actionpack (>= 4.0)
sprockets-rails (2.3.3) activesupport (>= 4.0)
actionpack (>= 3.0) sprockets (>= 3.0.0)
activesupport (>= 3.0)
sprockets (>= 2.8, < 4.0)
string-scrub (0.0.5) string-scrub (0.0.5)
sucker_punch (1.6.0) sucker_punch (2.0.4)
celluloid (~> 0.17.2) concurrent-ruby (~> 1.0.0)
temple (0.8.0) temple (0.8.0)
thor (0.20.0) thor (0.20.0)
thread_safe (0.3.6) thread_safe (0.3.6)
tilt (1.4.1) tilt (2.0.8)
timecop (0.8.1) timecop (0.8.1)
timers (4.1.2)
hitimes
tzinfo (1.2.5) tzinfo (1.2.5)
thread_safe (~> 0.1) thread_safe (~> 0.1)
tzinfo-data (1.2018.4) tzinfo-data (1.2018.4)
tzinfo (>= 1.0.0) tzinfo (>= 1.0.0)
unf (0.1.4) web-console (3.6.0)
unf_ext actionview (>= 5.0)
unf_ext (0.0.7.4) activemodel (>= 5.0)
web-console (2.3.0) bindex (>= 0.4.0)
activemodel (>= 4.0) railties (>= 5.0)
binding_of_caller (>= 0.7.2) webmock (3.3.0)
railties (>= 4.0)
sprockets-rails (>= 2.0, < 4.0)
webmock (1.18.0)
addressable (>= 2.3.6) addressable (>= 2.3.6)
crack (>= 0.3.2) crack (>= 0.3.2)
webrobots (0.1.2) hashdiff
websocket-driver (0.6.5) websocket-driver (0.7.0)
websocket-extensions (>= 0.1.0) websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.2) websocket-extensions (0.1.3)
xpath (2.0.0) xpath (3.0.0)
nokogiri (~> 1.3) nokogiri (~> 1.8)
yajl-ruby (1.3.1) yajl-ruby (1.3.1)
PLATFORMS PLATFORMS
@ -323,20 +303,20 @@ PLATFORMS
DEPENDENCIES DEPENDENCIES
better_errors better_errors
capybara (~> 2.4.0) capybara (~> 3.0.2)
capybara-screenshot capybara-screenshot
factory_girl_rails factory_bot_rails
fluentd-ui! fluentd-ui!
i18n_generators (= 1.2.1) i18n_generators (= 2.1.1)
poltergeist
pry pry
pry-rails pry-rails
rake rake
rspec-rails (~> 3.0) rspec-rails (~> 3.0)
selenium-webdriver (~> 3.11)
simplecov (~> 0.16.1) simplecov (~> 0.16.1)
timecop timecop
web-console (~> 2.0) web-console (~> 3.6)
webmock (~> 1.18.0) webmock (~> 3.3.0)
BUNDLED WITH BUNDLED WITH
1.16.1 1.16.1

View File

@ -28,7 +28,7 @@ module SettingHistoryConcern
else else
flash = { danger: @fluentd.agent.log.tail(1).first } flash = { danger: @fluentd.agent.log.tail(1).first }
end end
redirect_to :back, flash: flash redirect_back fallback_location: root_url, flash: flash
end end
end end

View File

@ -19,7 +19,7 @@ class MiscController < ApplicationController
end end
def upgrading_status def upgrading_status
if FluentdUiRestart::LOCK.present? if FluentdUiRestartJob::LOCK.present?
return render text: "updating" return render text: "updating"
end end
@ -73,6 +73,6 @@ class MiscController < ApplicationController
end end
def update! def update!
FluentdUiRestart.new.async.perform FluentdUiRestart.perform_later
end end
end end

View File

@ -17,27 +17,27 @@ class PluginsController < ApplicationController
def install def install
params[:plugins].each do |gem_name| params[:plugins].each do |gem_name|
GemInstaller.new.async.perform(gem_name) GemInstallerJob.perform_later(gem_name)
end end
redirect_to plugins_path redirect_to plugins_path
end end
def uninstall def uninstall
params[:plugins].each do |gem_name| params[:plugins].each do |gem_name|
GemUninstaller.new.async.perform(gem_name) GemUninstallerJob.perform_later(gem_name)
end end
redirect_to plugins_path redirect_to plugins_path
end end
def upgrade def upgrade
GemInstaller.new.async.perform(params[:plugins][:name], params[:plugins][:version]) GemInstallerJob.perform_later(params[:plugins][:name], params[:plugins][:version])
redirect_to plugins_path redirect_to plugins_path
end end
def bulk_upgrade def bulk_upgrade
params[:plugins].each do |gem_name| params[:plugins].each do |gem_name|
pl = Plugin.new(gem_name: gem_name) pl = Plugin.new(gem_name: gem_name)
GemInstaller.new.async.perform(gem_name, pl.latest_version) GemInstallerJob.perform_later(gem_name, pl.latest_version)
end end
redirect_to plugins_path redirect_to plugins_path
end end

View File

@ -0,0 +1,10 @@
class AllPluginCheckUpdateJob < ApplicationJob
queue_as :default
def perform(*args)
Plugin.installed.each do |pl|
GemUpdateCheckJob.perform_later(pl.gem_name)
end
AllPluginCheckUpdateJob.set(wait: 1.hour).perform_later # will be checked every hour
end
end

View File

@ -0,0 +1,2 @@
class ApplicationJob < ActiveJob::Base
end

View File

@ -1,5 +1,5 @@
class FluentdUiRestart class FluentdUiRestartJob < ApplicationJob
include SuckerPunch::Job queue_as :default
LOCK = [] LOCK = []
@ -20,7 +20,7 @@ class FluentdUiRestart
lock! lock!
# NOTE: install will be failed before released fluentd-ui gem # NOTE: install will be failed before released fluentd-ui gem
SuckerPunch.logger.info "[restart] install new fluentd-ui" logger.info "[restart] install new fluentd-ui"
Plugin.new(gem_name: "fluentd-ui").install! Plugin.new(gem_name: "fluentd-ui").install!
if Rails.env.production? if Rails.env.production?
@ -29,7 +29,7 @@ class FluentdUiRestart
cmd = %W(bundle exec rails s) cmd = %W(bundle exec rails s)
end end
SuckerPunch.logger.info "[restart] will restart" logger.info "[restart] will restart"
Bundler.with_clean_env do Bundler.with_clean_env do
restarter = "#{Rails.root}/bin/fluentd-ui-restart" restarter = "#{Rails.root}/bin/fluentd-ui-restart"
Process.spawn(*[restarter, $$.to_s, *cmd, *ARGV]) && Process.kill(:TERM, $$) Process.spawn(*[restarter, $$.to_s, *cmd, *ARGV]) && Process.kill(:TERM, $$)

View File

@ -0,0 +1,11 @@
class FluentdUiUpdateCheckJob < ApplicationJob
queue_as :default
def perform
pl = Plugin.new(gem_name: "fluentd-ui")
if pl.gem_versions
FluentdUI.latest_version = pl.latest_version
end
FluentdUiUpdateCheckJob.set(wait: 1.hour).perform_later # will be checked every hour
end
end

View File

@ -1,6 +1,5 @@
class GemInstaller class GemInstallerJob < ApplicationJob
include SuckerPunch::Job queue_as :default
workers 16
def perform(gem_name, version = nil) def perform(gem_name, version = nil)
SuckerPunch.logger.info "install #{gem_name} #{version}" SuckerPunch.logger.info "install #{gem_name} #{version}"
@ -9,9 +8,9 @@ class GemInstaller
# NOTE: uninstall all versions of `gem_name` then install it for upgrade/downgrade # NOTE: uninstall all versions of `gem_name` then install it for upgrade/downgrade
pl.uninstall! if pl.installed? pl.uninstall! if pl.installed?
pl.install! pl.install!
SuckerPunch.logger.info "installed #{gem_name} #{version}" logger.info "installed #{gem_name} #{version}"
rescue Plugin::GemError rescue Plugin::GemError
SuckerPunch.logger.warn "installing #{gem_name} #{version} is failed" logger.warn "installing #{gem_name} #{version} is failed"
end end
end end
end end

View File

@ -0,0 +1,14 @@
class GemUninstallerJob < ApplicationJob
queue_as :default
def perform(gem_name)
logger.info "uninstall #{gem_name}"
pl = Plugin.new(gem_name: gem_name)
begin
pl.uninstall!
logger.info "uninstalled #{gem_name}"
rescue Plugin::GemError
logger.warn "uninstalling #{gem_name} is failed"
end
end
end

View File

@ -0,0 +1,9 @@
class GemUpdateCheckJob < ApplicationJob
queue_as :default
def perform(gem_name)
logger.info "check #{gem_name} latest version"
pl = Plugin.new(gem_name: gem_name)
pl.gem_versions!
end
end

View File

@ -1,14 +0,0 @@
class AllPluginCheckUpdate
include SuckerPunch::Job
def perform
Plugin.installed.each do |pl|
GemUpdateCheck.new.async.perform(pl.gem_name)
end
later(3600) # will be checked every hour
end
def later(sec)
after(sec) { perform }
end
end

View File

@ -1,15 +0,0 @@
class FluentdUiUpdateCheck
include SuckerPunch::Job
def perform
pl = Plugin.new(gem_name: "fluentd-ui")
if pl.gem_versions
FluentdUI.latest_version = pl.latest_version
end
later(3600) # will be checked every hour
end
def later(sec)
after(sec) { perform }
end
end

View File

@ -1,15 +0,0 @@
class GemUninstaller
include SuckerPunch::Job
workers 16
def perform(gem_name)
SuckerPunch.logger.info "uninstall #{gem_name}"
pl = Plugin.new(gem_name: gem_name)
begin
pl.uninstall!
SuckerPunch.logger.info "uninstalled #{gem_name}"
rescue Plugin::GemError
SuckerPunch.logger.warn "uninstalling #{gem_name} is failed"
end
end
end

View File

@ -1,10 +0,0 @@
class GemUpdateCheck
include SuckerPunch::Job
workers 16
def perform(gem_name)
SuckerPunch.logger.info "check #{gem_name} latest version"
pl = Plugin.new(gem_name: gem_name)
pl.gem_versions!
end
end

View File

@ -35,7 +35,10 @@ module FluentdUi
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
config.i18n.default_locale = 'en' config.i18n.default_locale = 'en'
config.autoload_paths += %W(#{config.root}/app/workers #{config.root}/lib) config.i18n.available_locales = %i(en ja)
config.autoload_paths += %W(#{config.root}/lib)
config.active_job.queue_adapter = :sucker_punch
# NOTE: currently, fluentd-ui does not using ActiveRecord, and using Time.now instead of Time.zone.now for each different TZ for users. # NOTE: currently, fluentd-ui does not using ActiveRecord, and using Time.now instead of Time.zone.now for each different TZ for users.
# If AR will be used, please comment in and check timezone. # If AR will be used, please comment in and check timezone.

View File

@ -13,8 +13,8 @@ Rails.application.configure do
config.eager_load = false config.eager_load = false
# Configure static file server for tests with Cache-Control for performance. # Configure static file server for tests with Cache-Control for performance.
config.serve_static_files = true config.public_file_server.enabled = true
config.static_cache_control = 'public, max-age=3600' config.public_file_server_headers = { 'Cache-Control' => 'public, max-age=3600' }
# Show full error reports and disable caching. # Show full error reports and disable caching.
config.consider_all_requests_local = true config.consider_all_requests_local = true

View File

@ -1,6 +1,7 @@
require "plugin" # Avoid: RuntimeError Circular dependency detected while autoloading constant Plugin
unless Rails.env.test? unless Rails.env.test?
unless FluentdUI.td_agent_ui? unless FluentdUI.td_agent_ui?
# td-agent-ui shouldn't auto update # td-agent-ui shouldn't auto update
FluentdUiUpdateCheck.new.async.perform FluentdUiUpdateCheckJob.perform_later
end end
end end

View File

@ -1 +1,2 @@
AllPluginCheckUpdate.new.async.perform require "plugin" # Avoid: RuntimeError Circular dependency detected while autoloading constant Plugin
AllPluginCheckUpdateJob.perform_later

View File

@ -1,3 +1,4 @@
---
ja: ja:
date: date:
abbr_day_names: abbr_day_names:
@ -31,9 +32,9 @@ ja:
- 金曜日 - 金曜日
- 土曜日 - 土曜日
formats: formats:
default: ! '%Y/%m/%d' default: "%Y/%m/%d"
long: ! '%Y年%m月%d日(%a)' long: "%Y年%m月%d日(%a)"
short: ! '%m/%d' short: "%m/%d"
month_names: month_names:
- -
- 1月 - 1月
@ -65,29 +66,32 @@ ja:
other: 約%{count}年 other: 約%{count}年
almost_x_years: almost_x_years:
one: 1年弱 one: 1年弱
other: ! '%{count}年弱' other: "%{count}年弱"
half_a_minute: 30秒前後 half_a_minute: 30秒前後
less_than_x_minutes: less_than_x_minutes:
one: 1分以内 one: 1分以内
other: ! '%{count}分未満' other: "%{count}分未満"
less_than_x_seconds: less_than_x_seconds:
one: 1秒以内 one: 1秒以内
other: ! '%{count}秒未満' other: "%{count}秒未満"
over_x_years: over_x_years:
one: 1年以上 one: 1年以上
other: ! '%{count}年以上' other: "%{count}年以上"
x_days: x_days:
one: 1日 one: 1日
other: ! '%{count}日' other: "%{count}日"
x_minutes: x_minutes:
one: 1分 one: 1分
other: ! '%{count}分' other: "%{count}分"
x_months: x_months:
one: 1ヶ月 one: 1ヶ月
other: ! '%{count}ヶ月' other: "%{count}ヶ月"
x_years:
one: 1年
other: "%{count}年"
x_seconds: x_seconds:
one: 1秒 one: 1秒
other: ! '%{count}秒' other: "%{count}秒"
prompts: prompts:
day: day:
hour: hour:
@ -96,40 +100,40 @@ ja:
second: second:
year: year:
errors: errors:
format: ! '%{attribute}%{message}' format: "%{attribute}%{message}"
messages: messages:
accepted: を受諾してください accepted: を受諾してください
blank: を入力してください blank: を入力してください
present: は入力しないでください present: は入力しないでください
confirmation: と%{attribute}の入力が一致しません confirmation: と%{attribute}の入力が一致しません
empty: を入力してください empty: を入力してください
equal_to: は%{count}にしてください equal_to: は%{count}にしてください
even: は偶数にしてください even: は偶数にしてください
exclusion: は予約されています exclusion: は予約されています
greater_than: は%{count}より大きい値にしてください greater_than: は%{count}より大きい値にしてください
greater_than_or_equal_to: は%{count}以上の値にしてください greater_than_or_equal_to: は%{count}以上の値にしてください
inclusion: は一覧にありません inclusion: は一覧にありません
invalid: は不正な値です invalid: は不正な値です
less_than: は%{count}より小さい値にしてください less_than: は%{count}より小さい値にしてください
less_than_or_equal_to: は%{count}以下の値にしてください less_than_or_equal_to: は%{count}以下の値にしてください
not_a_number: は数値で入力してください。 model_invalid: "バリデーションに失敗しました: %{errors}"
not_an_integer: は整数で入力してください。 not_a_number: は数値で入力してください
odd: は奇数にしてください。 not_an_integer: は整数で入力してください
record_invalid: バリデーションに失敗しました。 %{errors} odd: は奇数にしてください
restrict_dependent_destroy: ! '%{record}が存在しているので削除できません。' required: を入力してください
taken: はすでに存在します taken: はすでに存在します
too_long: は%{count}文字以内で入力してください too_long: は%{count}文字以内で入力してください
too_short: は%{count}文字以上で入力してください too_short: は%{count}文字以上で入力してください
wrong_length: は%{count}文字で入力してください wrong_length: は%{count}文字で入力してください
other_than: "は%{count}以外の値にしてください。" other_than: は%{count}以外の値にしてください
template: template:
body: 次の項目を確認してください body: 次の項目を確認してください
header: header:
one: ! '%{model}にエラーが発生しました。' one: "%{model}にエラーが発生しました"
other: ! '%{model}に%{count}個のエラーが発生しました。' other: "%{model}に%{count}個のエラーが発生しました"
helpers: helpers:
select: select:
prompt: 選択してください prompt: 選択してください
submit: submit:
create: 登録する create: 登録する
submit: 保存する submit: 保存する
@ -137,22 +141,22 @@ ja:
number: number:
currency: currency:
format: format:
delimiter: ! ',' delimiter: ","
format: ! '%n%u' format: "%n%u"
precision: 0 precision: 0
separator: . separator: "."
significant: false significant: false
strip_insignificant_zeros: false strip_insignificant_zeros: false
unit: unit:
format: format:
delimiter: ! ',' delimiter: ","
precision: 3 precision: 3
separator: . separator: "."
significant: false significant: false
strip_insignificant_zeros: false strip_insignificant_zeros: false
human: human:
decimal_units: decimal_units:
format: ! '%n %u' format: "%n %u"
units: units:
billion: 十億 billion: 十億
million: 百万 million: 百万
@ -166,13 +170,13 @@ ja:
significant: true significant: true
strip_insignificant_zeros: true strip_insignificant_zeros: true
storage_units: storage_units:
format: ! '%n%u' format: "%n%u"
units: units:
byte: バイト byte: バイト
gb: ギガバイト gb: GB
kb: キロバイト kb: KB
mb: メガバイト mb: MB
tb: テラバイト tb: TB
percentage: percentage:
format: format:
delimiter: '' delimiter: ''
@ -182,13 +186,13 @@ ja:
delimiter: '' delimiter: ''
support: support:
array: array:
last_word_connector: last_word_connector:
two_words_connector: two_words_connector:
words_connector: words_connector:
time: time:
am: 午前 am: 午前
formats: formats:
default: ! '%Y/%m/%d %H:%M:%S' default: "%Y/%m/%d %H:%M:%S"
long: ! '%Y年%m月%d日(%a) %H時%M分%S秒 %z' long: "%Y年%m月%d日(%a) %H時%M分%S秒 %z"
short: ! '%y/%m/%d %H:%M' short: "%y/%m/%d %H:%M"
pm: 午後 pm: 午後

View File

@ -25,15 +25,15 @@ Gem::Specification.new do |spec|
spec.require_paths = ["lib"] spec.require_paths = ["lib"]
spec.add_dependency "fluentd", [">= 0.10.56", "< 0.14"] spec.add_dependency "fluentd", [">= 0.10.56", "< 0.14"]
spec.add_dependency 'rails', '~> 4.2.0' spec.add_dependency 'rails', '~> 5.2.0'
spec.add_dependency 'sucker_punch', "~> 1.6.0" spec.add_dependency 'sucker_punch', "~> 2.0.4"
spec.add_dependency 'addressable' spec.add_dependency 'addressable'
spec.add_dependency "font-awesome-rails" spec.add_dependency "font-awesome-rails"
spec.add_dependency 'sass-rails', '~> 4.0.3' spec.add_dependency 'sass-rails', '~> 5.0.7'
spec.add_dependency "haml-rails", "~> 1.0" spec.add_dependency "haml-rails", "~> 1.0"
spec.add_dependency 'jquery-rails', "~> 4.3.1" spec.add_dependency 'jquery-rails', "~> 4.3.1"
spec.add_dependency 'jbuilder', '~> 2.0' spec.add_dependency 'jbuilder', '~> 2.0'
spec.add_dependency "draper", '~> 2.1' spec.add_dependency "draper", '~> 3.0'
spec.add_dependency "bundler" spec.add_dependency "bundler"
spec.add_dependency "httpclient", "~> 2.5" # same as td-agent spec.add_dependency "httpclient", "~> 2.5" # same as td-agent
spec.add_dependency "settingslogic" spec.add_dependency "settingslogic"

View File

@ -6,24 +6,20 @@ describe DummyController do
controller DummyController do controller DummyController do
skip_before_action :login_required skip_before_action :login_required
def index def index
render :text => "Hello World" render plain: "Hello World"
end end
end end
describe '#set_locale' do describe '#set_locale' do
let!(:default_locale) { :en } let!(:default_locale) { :en }
let!(:available_locales) { [:en, :ja] }
before do before do
I18n.stub(:default_locale).and_return(default_locale)
I18n.stub(:available_locales).and_return(available_locales)
I18n.locale = I18n.default_locale #initialize I18n.locale = I18n.default_locale #initialize
end end
context 'with params[:lang]' do context 'with params[:lang]' do
before do before do
get 'index', lang: param_lang get 'index', params: { lang: param_lang }
end end
context 'and in available_locales' do context 'and in available_locales' do

View File

@ -1,4 +1,4 @@
FactoryGirl.define do FactoryBot.define do
factory :fluentd do factory :fluentd do
dir = Rails.root.join("tmp/fluentd-test").to_s dir = Rails.root.join("tmp/fluentd-test").to_s
FileUtils.mkdir_p(dir) FileUtils.mkdir_p(dir)

View File

@ -1,6 +1,6 @@
# Read about factories at https://github.com/thoughtbot/factory_girl # Read about factories at https://github.com/thoughtbot/factory_bot
FactoryGirl.define do FactoryBot.define do
factory :plugin do factory :plugin do
gem_name "fluent-plugin-dummy" gem_name "fluent-plugin-dummy"
version "1.2.3" version "1.2.3"

View File

@ -1,4 +1,4 @@
FactoryGirl.define do FactoryBot.define do
factory :user do factory :user do
name "admin" name "admin"
password "changeme" password "changeme"

View File

@ -35,16 +35,17 @@ describe "histories", stub: :daemon do
it 'show histories#show' do it 'show histories#show' do
page.should have_css('h1', text: I18n.t('fluentd.settings.histories.show.page_title')) page.should have_css('h1', text: I18n.t('fluentd.settings.histories.show.page_title'))
page.should have_text(last_backup_file.content)
page.should has_text?(last_backup_file.content)
end end
describe 'diff' do describe 'diff' do
context 'has diff' do context 'has diff' do
it 'shows diff between current and target' do it 'shows diff between current and target' do
page.should have_text("- type http") page.should has_text?("- type http")
page.should have_text("+ type forward") page.should has_text?("+ type forward")
page.should have_text("- port 8899") page.should has_text?("- port 8899")
page.should have_text("+ port 24224") page.should has_text?("+ port 24224")
end end
end end
@ -64,7 +65,7 @@ describe "histories", stub: :daemon do
page.should have_css('h1', text: I18n.t('fluentd.settings.show.page_title')) page.should have_css('h1', text: I18n.t('fluentd.settings.show.page_title'))
page.should have_text(I18n.t('messages.config_successfully_copied', brand: 'fluentd') ) page.should have_text(I18n.t('messages.config_successfully_copied', brand: 'fluentd') )
page.should have_text(last_backup_file.content) page.should has_text?(last_backup_file.content)
end end
describe "configtest" do describe "configtest" do

View File

@ -39,9 +39,10 @@ describe "running_backup", stub: :daemon do
describe 'diff' do describe 'diff' do
context 'has diff' do context 'has diff' do
it 'shows diff between current and running' do it 'shows diff between current and running' do
expect(page).to have_text("- type http") diff = page.first(".diff pre").native.inner_text
expect(page).to have_text("- port 8899") expect(diff).to include("- type http")
expect(page).to have_text("+ Running backup file content") expect(diff).to include("- port 8899")
expect(diff).to include("+ Running backup file content")
end end
end end

View File

@ -50,6 +50,7 @@ describe 'setting', stub: :daemon do
describe "config" do describe "config" do
before do before do
Fluentd::Agent::TdAgent.any_instance.stub(:dryrun).with(an_instance_of(String)).and_return(true)
daemon.agent.config_write conf daemon.agent.config_write conf
click_link I18n.t('terms.edit') click_link I18n.t('terms.edit')
end end

View File

@ -21,19 +21,19 @@ describe Fluentd do
context "not writable" do context "not writable" do
before { FileUtils.chmod(0400, path) } before { FileUtils.chmod(0400, path) }
it { should_not be_blank } it { should_not be_blank }
it { subject.get(column).should include(I18n.t('activerecord.errors.messages.lack_write_permission')) } it { subject[column].should include(I18n.t('activerecord.errors.messages.lack_write_permission')) }
end end
context "not readable" do context "not readable" do
before { FileUtils.chmod(0200, path) } before { FileUtils.chmod(0200, path) }
it { should_not be_blank } it { should_not be_blank }
it { subject.get(column).should include(I18n.t('activerecord.errors.messages.lack_read_permission')) } it { subject[column].should include(I18n.t('activerecord.errors.messages.lack_read_permission')) }
end end
context "is directory" do context "is directory" do
before { fluentd.send("#{column}=", Rails.root + "tmp") } before { fluentd.send("#{column}=", Rails.root + "tmp") }
it { should_not be_blank } it { should_not be_blank }
it { subject.get(column).should include(I18n.t('activerecord.errors.messages.is_a_directory')) } it { subject[column].should include(I18n.t('activerecord.errors.messages.is_a_directory')) }
end end
end end
@ -50,7 +50,7 @@ describe Fluentd do
context "not writable" do context "not writable" do
before { FileUtils.chmod(0500, dir) } before { FileUtils.chmod(0500, dir) }
it { should_not be_blank } it { should_not be_blank }
it { subject.get(column).should include(I18n.t('activerecord.errors.messages.lack_write_permission')) } it { subject[column].should include(I18n.t('activerecord.errors.messages.lack_write_permission')) }
end end
end end
end end

View File

@ -9,8 +9,18 @@ require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails' require 'rspec/rails'
require 'webmock/rspec' require 'webmock/rspec'
WebMock.disable_net_connect!(allow_localhost: true) WebMock.disable_net_connect!(allow_localhost: true)
require 'capybara/poltergeist' require 'capybara/rspec'
Capybara.javascript_driver = :poltergeist Capybara.register_driver :selenium do |app|
Capybara::Selenium::Driver.new(app,
browser: :chrome,
desired_capabilities: Selenium::WebDriver::Remote::Capabilities.chrome(
chrome_options: {
args: %w(headless disable-gpu window-size=1920,1080),
},
)
)
end
Capybara.javascript_driver = :selenium
require 'capybara-screenshot/rspec' require 'capybara-screenshot/rspec'
# Requires supporting ruby files with custom matchers and macros, etc, # Requires supporting ruby files with custom matchers and macros, etc,
@ -27,8 +37,8 @@ RSpec.configure do |config|
# config.mock_with :flexmock # config.mock_with :flexmock
# config.mock_with :rr # config.mock_with :rr
# Syntax sugar to use the FactoryGirl methods directly instead FactoryGirl.create ete. # Syntax sugar to use the FactoryBot methods directly instead FactoryBot.create ete.
config.include FactoryGirl::Syntax::Methods config.include FactoryBot::Syntax::Methods
config.include LoginMacro config.include LoginMacro
config.include JavascriptMacro config.include JavascriptMacro
config.include StubDaemon config.include StubDaemon