diff --git a/.rubocop.yml b/.rubocop.yml index e69de29b..4b0d0073 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -0,0 +1,10 @@ +AllCops: + Exclude: + - db/schema.rb +FrozenStringLiteralComment: + Enabled: false +LineLength: + Enabled: true + Max: 160 +Rails: + Enabled: true diff --git a/.travis.yml b/.travis.yml index b97f903d..338e2b0c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,16 +4,22 @@ rvm: - 2.4.1 bundler_args: --without development cache: bundler +sudo: required addons: apt_packages: - pandoc code_climate: repo_token: 243e5ab59244b7a1d3fb97d56bfe9961307ad558cb4a7cbeec3c85104e9ee11b + chrome: stable before_install: - export TZ=Europe/Zurich - mysql -e 'CREATE DATABASE base_test' + - google-chrome-stable --headless --disable-gpu --remote-debugging-port=9222 http://localhost & + before_script: - cp config/secrets.travis.yml config/secrets.yml + - export DISPLAY=:99.0 && sh -e /etc/init.d/xvfb start && sleep 3 + script: - RAILS_ENV=test bundle exec rails db:create - RAILS_ENV=test bundle exec rails db:migrate diff --git a/Gemfile b/Gemfile index b141677f..01578d0b 100644 --- a/Gemfile +++ b/Gemfile @@ -96,7 +96,7 @@ group :development, :test do gem 'rspec' gem 'rspec-rails' # RSpec for Rails - gem 'sqlite3' # Use SQLite as the database for Active Record + gem 'capybara' # Capybara helps you test web applications by simulating how a real user would interact with your app. # Data generation gem 'factory_bot_rails' # Test data generator @@ -141,9 +141,9 @@ group :development do gem 'rubocop', require: false # A robust Ruby code analyzer, based on the community Ruby style guide - gem 'capybara', '>=2.2.0.beta' # Acceptance test framework for web applications + gem 'capybara-selenium' # Acceptance test framework for web applications - gem 'rails-footnotes' # Every Rails page has footnotes that gives information about your application + gem 'rack-mini-profiler' # Profiler for your development and production Ruby rack apps gem 'mina', require: false # Really fast deployer and server automation tool @@ -163,12 +163,9 @@ group :test do gem 'database_cleaner' # Resets test database after each test - # Capybara - Headless, JavaScript-executing browser for Selenium - gem 'poltergeist', github: 'teampoltergeist/poltergeist' # PhantomJS driver for Capybara, see https://github.com/teampoltergeist/poltergeist/pull/913 - gem 'launchy' # Use `save_and_open_page` in request tests to automatically open a browser - gem 'selenium-webdriver' # Selenium webdriver (needed to use Chrome driver) + gem 'selenium-webdriver' # Selenium webdriver (needed to use Chrome driver) - gem 'capybara-screenshot' # Automatically save screen shots when a scenario fails + gem 'chromedriver-helper' # Easy installation and use of chromedriver, the Chromium project's selenium webdriver adapter. gem 'i18n-tasks' # Manage translation and localization with static analysis diff --git a/Gemfile.lock b/Gemfile.lock index 85d4e22e..b9bca274 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -5,69 +5,66 @@ GIT strip_attributes (1.8.0) activemodel (>= 3.0, < 6.0) -GIT - remote: git://github.com/teampoltergeist/poltergeist.git - revision: 733b084a32d5c424dd9b4f4a9c2225cf6e1b5d76 - specs: - poltergeist (1.16.0) - capybara (~> 2.1) - cliver (~> 0.3.1) - websocket-driver (>= 0.2.0) - GEM remote: https://rubygems.org/ specs: - actioncable (5.1.4) - actionpack (= 5.1.4) + actioncable (5.2.0) + actionpack (= 5.2.0) nio4r (~> 2.0) - websocket-driver (~> 0.6.1) - actionmailer (5.1.4) - actionpack (= 5.1.4) - actionview (= 5.1.4) - activejob (= 5.1.4) + 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) rails-dom-testing (~> 2.0) - actionpack (5.1.4) - actionview (= 5.1.4) - activesupport (= 5.1.4) + actionpack (5.2.0) + actionview (= 5.2.0) + activesupport (= 5.2.0) rack (~> 2.0) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (5.1.4) - activesupport (= 5.1.4) + actionview (5.2.0) + activesupport (= 5.2.0) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.3) actionview-encoded_mail_to (1.0.9) rails - activejob (5.1.4) - activesupport (= 5.1.4) + activejob (5.2.0) + activesupport (= 5.2.0) globalid (>= 0.3.6) - activemodel (5.1.4) - activesupport (= 5.1.4) - activerecord (5.1.4) - activemodel (= 5.1.4) - activesupport (= 5.1.4) - arel (~> 8.0) - activesupport (5.1.4) + activemodel (5.2.0) + activesupport (= 5.2.0) + activerecord (5.2.0) + activemodel (= 5.2.0) + activesupport (= 5.2.0) + arel (>= 9.0) + activestorage (5.2.0) + 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) + i18n (>= 0.7, < 2) minitest (~> 5.1) tzinfo (~> 1.1) - acts_as_list (0.9.10) + acts_as_list (0.9.14) activerecord (>= 3.0) - acts_as_tree (2.7.0) + acts_as_tree (2.7.1) activerecord (>= 3.0.0) addressable (2.5.2) public_suffix (>= 2.0.2, < 4.0) - arel (8.0.0) - ast (2.3.0) - autoprefixer-rails (7.2.2) + archive-zip (0.11.0) + io-like (~> 0.3.0) + arel (9.0.0) + ast (2.4.0) + autoprefixer-rails (8.6.1) execjs awesome_print (1.8.0) - bcrypt (3.1.11) + bcrypt (3.1.12) better_errors (2.4.0) coderay (>= 1.0.0) erubi (>= 1.0.0) @@ -77,29 +74,31 @@ GEM autoprefixer-rails (>= 5.2.1) sass (>= 3.3.4) builder (3.2.3) - byebug (9.1.0) - cancancan (2.1.2) - capybara (2.16.1) + byebug (10.0.2) + cancancan (2.2.0) + capybara (3.2.1) addressable mini_mime (>= 0.1.3) - nokogiri (>= 1.3.3) - rack (>= 1.0.0) - rack-test (>= 0.5.4) - xpath (~> 2.0) - capybara-screenshot (1.0.18) - capybara (>= 1.0, < 3) - launchy - carrierwave (1.2.1) + nokogiri (~> 1.8) + rack (>= 1.6.0) + rack-test (>= 0.6.3) + xpath (~> 3.1) + capybara-selenium (0.0.6) + capybara + selenium-webdriver + carrierwave (1.2.2) activemodel (>= 4.0.0) activesupport (>= 4.0.0) mime-types (>= 1.16) - carrierwave-base64 (2.6.1) + carrierwave-base64 (2.7.0) carrierwave (>= 0.8.0) mime-types (~> 3.0) - childprocess (0.8.0) + childprocess (0.9.0) ffi (~> 1.0, >= 1.0.11) - chunky_png (1.3.8) - cliver (0.3.2) + chromedriver-helper (1.2.0) + archive-zip (~> 0.10) + nokogiri (~> 1.8) + chunky_png (1.3.10) cocoon (1.2.11) codeclimate-test-reporter (1.0.8) simplecov (<= 0.13) @@ -123,64 +122,63 @@ GEM sass (>= 3.3.0, < 3.5) compass-import-once (1.0.5) sass (>= 3.2, < 3.5) - compass-rails (3.0.2) + compass-rails (3.1.0) compass (~> 1.0.0) sass-rails (< 5.1) sprockets (< 4.0) concurrent-ruby (1.0.5) - crass (1.0.3) + crass (1.0.4) css_parser (1.6.0) addressable - database_cleaner (1.6.2) - devise (4.3.0) + database_cleaner (1.7.0) + devise (4.4.3) bcrypt (~> 3.0) orm_adapter (~> 0.1) - railties (>= 4.1.0, < 5.2) + railties (>= 4.1.0, < 6.0) responders warden (~> 1.2.3) - devise-i18n (1.5.0) - devise (>= 3.4) + devise-i18n (1.6.2) + devise (>= 4.4) diff-lcs (1.3) docile (1.1.5) - easy_translate (0.5.0) - json + easy_translate (0.5.1) thread thread_safe em-websocket (0.5.1) eventmachine (>= 0.12.9) http_parser.rb (~> 0.6.0) - email_spec (2.1.1) + email_spec (2.2.0) htmlentities (~> 4.3.3) launchy (~> 2.1) - mail (~> 2.6) - enumerize (2.1.2) + mail (~> 2.7) + enumerize (2.2.2) activesupport (>= 3.2) - erubi (1.7.0) - eventmachine (1.2.5) + erubi (1.7.1) + eventmachine (1.2.7) execjs (2.7.0) - factory_bot (4.8.2) + factory_bot (4.10.0) activesupport (>= 3.0.0) - factory_bot_rails (4.8.2) - factory_bot (~> 4.8.2) + factory_bot_rails (4.10.0) + factory_bot (~> 4.10.0) railties (>= 3.0.0) fancybox2-rails (0.2.7) railties (>= 3.1.0) - ffaker (2.7.0) - ffi (1.9.18) - font-awesome-rails (4.7.0.2) - railties (>= 3.2, < 5.2) + ffaker (2.9.0) + ffi (1.9.25) + font-awesome-rails (4.7.0.4) + railties (>= 3.2, < 6.0) formatador (0.2.5) - fuubar (2.2.0) + fuubar (2.3.1) rspec-core (~> 3.0) ruby-progressbar (~> 1.4) gaffe (1.2.0) rails (>= 4.0.0) globalid (0.4.1) activesupport (>= 4.2.0) - guard (2.14.1) + guard (2.14.2) formatador (>= 0.2.4) listen (>= 2.7, < 4.0) - lumberjack (~> 1.0) + lumberjack (>= 1.0.12, < 2.0) nenv (~> 0.1) notiffany (~> 0.0) pry (>= 0.9.12) @@ -211,57 +209,62 @@ GEM htmlentities (4.3.4) http_parser.rb (0.6.0) humanizer (2.6.4) - i18n (0.9.1) + i18n (1.0.1) concurrent-ruby (~> 1.0) - i18n-tasks (0.9.19) + i18n-tasks (0.9.21) activesupport (>= 4.0.2) ast (>= 2.1.0) - easy_translate (>= 0.5.0) + easy_translate (>= 0.5.1) erubi highline (>= 1.7.3) i18n parser (>= 2.2.3.0) - rainbow (~> 2.2) + rainbow (>= 2.2.2, < 4.0) terminal-table (>= 1.5.1) i18n_yaml_sorter (0.2.0) + io-like (0.3.0) + jaro_winkler (1.5.1) jbuilder (2.7.0) activesupport (>= 4.2.0) multi_json (>= 1.2) - jquery-rails (4.3.1) + jquery-rails (4.3.3) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) - json (1.8.6) + json (2.1.0) launchy (2.4.3) addressable (~> 2.3) listen (3.0.8) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) - loofah (2.1.1) + loofah (2.2.2) crass (~> 1.0.2) nokogiri (>= 1.5.9) - lumberjack (1.0.12) + lumberjack (1.0.13) mail (2.7.0) mini_mime (>= 0.1.1) + marcel (0.3.2) + mimemagic (~> 0.3.2) method_source (0.9.0) mime-types (3.1) mime-types-data (~> 3.2015) mime-types-data (3.2016.0521) + mimemagic (0.3.2) mina (1.2.3) open4 (~> 1.3.4) rake mini_magick (4.8.0) mini_mime (1.0.0) mini_portile2 (2.3.0) - minitest (5.10.3) - mobility (0.3.4) - i18n (>= 0.6.10, < 0.10) + minitest (5.11.3) + mobility (0.7.5) + i18n (>= 0.6.10, < 1.1) request_store (~> 1.0) - multi_json (1.12.2) - mysql2 (0.4.10) + multi_json (1.13.1) + mysql2 (0.5.1) nenv (0.3.0) - nio4r (2.1.0) - nokogiri (1.8.1) + nio4r (2.3.1) + nokogiri (1.8.2) mini_portile2 (~> 2.3.0) notiffany (0.1.1) nenv (~> 0.1) @@ -269,80 +272,81 @@ GEM open4 (1.3.4) orm_adapter (0.5.0) pandoc-ruby (2.0.2) - paper_trail (8.1.1) - activerecord (>= 4.2, < 5.2) + paper_trail (9.1.1) + activerecord (>= 4.2, < 5.3) request_store (~> 1.1) - parallel (1.12.0) - parser (2.4.0.2) - ast (~> 2.3) - polyamorous (1.3.1) + parallel (1.12.1) + parser (2.5.1.0) + ast (~> 2.4.0) + polyamorous (1.3.3) activerecord (>= 3.0) powerpack (0.1.1) premailer (1.11.1) addressable css_parser (>= 1.6.0) htmlentities (>= 4.0.0) - premailer-rails (1.10.1) + premailer-rails (1.10.2) actionmailer (>= 3, < 6) premailer (~> 1.7, >= 1.7.9) pry (0.11.3) coderay (~> 1.1.0) method_source (~> 0.9.0) - pry-byebug (3.5.1) - byebug (~> 9.1) + pry-byebug (3.6.0) + byebug (~> 10.0) pry (~> 0.10) pry-rails (0.3.6) pry (>= 0.10.4) - public_suffix (3.0.1) - puma (3.11.0) - rack (2.0.3) - rack-livereload (0.3.16) + public_suffix (3.0.2) + puma (3.11.4) + rack (2.0.5) + rack-livereload (0.3.17) rack - rack-test (0.8.2) + rack-mini-profiler (1.0.0) + rack (>= 1.2.0) + rack-test (1.0.0) rack (>= 1.0, < 3) - rails (5.1.4) - actioncable (= 5.1.4) - actionmailer (= 5.1.4) - actionpack (= 5.1.4) - actionview (= 5.1.4) - activejob (= 5.1.4) - activemodel (= 5.1.4) - activerecord (= 5.1.4) - activesupport (= 5.1.4) + rails (5.2.0) + actioncable (= 5.2.0) + actionmailer (= 5.2.0) + actionpack (= 5.2.0) + actionview (= 5.2.0) + activejob (= 5.2.0) + activemodel (= 5.2.0) + activerecord (= 5.2.0) + activestorage (= 5.2.0) + activesupport (= 5.2.0) bundler (>= 1.3.0) - railties (= 5.1.4) + railties (= 5.2.0) sprockets-rails (>= 2.0.0) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) - rails-footnotes (4.1.8) - rails (>= 3.2) - rails-html-sanitizer (1.0.3) - loofah (~> 2.0) - rails-i18n (5.0.4) - i18n (~> 0.7) - railties (~> 5.0) - railties (5.1.4) - actionpack (= 5.1.4) - activesupport (= 5.1.4) + rails-html-sanitizer (1.0.4) + loofah (~> 2.2, >= 2.2.2) + rails-i18n (5.1.1) + i18n (>= 0.7, < 2) + railties (>= 5.0, < 6) + railties (5.2.0) + actionpack (= 5.2.0) + activesupport (= 5.2.0) method_source rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) - rainbow (2.2.2) - rake - rake (12.3.0) - ransack (1.8.4) + rainbow (3.0.0) + rake (12.3.1) + ransack (1.8.8) actionpack (>= 3.0) activerecord (>= 3.0) activesupport (>= 3.0) i18n - polyamorous (~> 1.3) - rb-fsevent (0.10.2) + polyamorous (~> 1.3.2) + rb-fsevent (0.10.3) rb-inotify (0.9.10) ffi (>= 0.5.0, < 2) - rdoc (4.3.0) - request_store (1.3.2) - rerun (0.11.0) + rdoc (6.0.4) + request_store (1.4.1) + rack (>= 1.4) + rerun (0.13.0) listen (~> 3.0) respec (0.9.1) rspec (>= 2.11) @@ -355,7 +359,7 @@ GEM rspec-mocks (~> 3.7.0) rspec-collection_matchers (1.1.3) rspec-expectations (>= 2.99.0.beta1) - rspec-core (3.7.0) + rspec-core (3.7.1) rspec-support (~> 3.7.0) rspec-expectations (3.7.0) diff-lcs (>= 1.2.0, < 2.0) @@ -371,12 +375,13 @@ GEM rspec-expectations (~> 3.7.0) rspec-mocks (~> 3.7.0) rspec-support (~> 3.7.0) - rspec-support (3.7.0) - rubocop (0.51.0) + rspec-support (3.7.1) + rubocop (0.57.1) + jaro_winkler (~> 1.5.1) parallel (~> 1.10) - parser (>= 2.3.3.1, < 3.0) + parser (>= 2.5) powerpack (~> 0.1) - rainbow (>= 2.2.2, < 3.0) + rainbow (>= 2.2.2, < 4.0) ruby-progressbar (~> 1.7) unicode-display_width (~> 1.0, >= 1.0.1) ruby-progressbar (1.9.0) @@ -388,18 +393,17 @@ GEM sprockets (>= 2.8, < 4.0) sprockets-rails (>= 2.0, < 4.0) tilt (>= 1.1, < 3) - sdoc (0.4.2) - json (~> 1.7, >= 1.7.7) - rdoc (~> 4.0) - selenium-webdriver (3.8.0) + sdoc (1.0.0) + rdoc (>= 5.0) + selenium-webdriver (3.12.0) childprocess (~> 0.5) - rubyzip (~> 1.0) + rubyzip (~> 1.2) shellany (0.0.1) shoulda-matchers (3.1.2) activesupport (>= 4.0.0) - simple_form (3.5.0) - actionpack (> 4, < 5.2) - activemodel (> 4, < 5.2) + simple_form (4.0.1) + actionpack (>= 5.0) + activemodel (>= 5.0) simplecov (0.13.0) docile (~> 1.1.0) json (>= 1.8, < 3) @@ -427,7 +431,6 @@ GEM actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) - sqlite3 (1.3.13) temple (0.8.0) terminal-notifier-guard (1.7.0) terminal-table (1.8.0) @@ -437,11 +440,11 @@ GEM thread_safe (0.3.6) tilt (2.0.8) timeliness (0.3.8) - tzinfo (1.2.4) + tzinfo (1.2.5) thread_safe (~> 0.1) - uglifier (4.0.2) + uglifier (4.1.11) execjs (>= 0.3.0, < 3) - unicode-display_width (1.3.0) + unicode-display_width (1.4.0) validate_url (1.0.2) activemodel (>= 3.0.0) addressable @@ -449,19 +452,19 @@ GEM i18n validates_timeliness (4.0.2) timeliness (~> 0.3.7) - wannabe_bool (0.7.0) + wannabe_bool (0.7.1) warden (1.2.7) rack (>= 1.0) - web-console (3.5.1) + web-console (3.6.2) actionview (>= 5.0) activemodel (>= 5.0) bindex (>= 0.4.0) railties (>= 5.0) - websocket-driver (0.6.5) + websocket-driver (0.7.0) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.3) - xpath (2.1.0) - nokogiri (~> 1.3) + xpath (3.1.0) + nokogiri (~> 1.8) xray-rails (0.3.1) rails (>= 3.1.0) @@ -476,10 +479,11 @@ DEPENDENCIES better_errors bootstrap-sass cancancan - capybara (>= 2.2.0.beta) - capybara-screenshot + capybara + capybara-selenium carrierwave carrierwave-base64 (>= 2.5) + chromedriver-helper cocoon codeclimate-test-reporter (~> 1.0.0) coffee-rails (~> 4.2) @@ -506,7 +510,6 @@ DEPENDENCIES i18n_yaml_sorter jbuilder (~> 2.5) jquery-rails - launchy listen (~> 3.0.5) mina mini_magick @@ -514,14 +517,13 @@ DEPENDENCIES mysql2 (>= 0.3.18) pandoc-ruby paper_trail (>= 4.0.0.rc) - poltergeist! premailer-rails pry-byebug pry-rails puma (~> 3.0) rack-livereload + rack-mini-profiler rails (~> 5.1) - rails-footnotes rails-i18n ransack rb-fsevent @@ -543,7 +545,6 @@ DEPENDENCIES spring spring-commands-rspec spring-watcher-listen (~> 2.0.0) - sqlite3 strip_attributes! terminal-notifier-guard tzinfo-data diff --git a/README.rdoc b/README.rdoc index 8c180bfc..f74c5bbc 100644 --- a/README.rdoc +++ b/README.rdoc @@ -44,7 +44,7 @@ This is a basic Rails project with everything configured the way I want. To fork - MiniMagick - `$ brew install imagemagick` - PhantomJS - - `$ brew install phantomjs` + - `$ brew install chromedriver` = Activate external services diff --git a/README_example.md b/README_example.md index c8036dad..c29e16ee 100644 --- a/README_example.md +++ b/README_example.md @@ -27,7 +27,7 @@ You can use [direnv](https://github.com/zimbatm/direnv) to automatically add `bi ## Requirements - [Pandoc](http://pandoc.org/) for advanced Markdown capabilities: `$ brew install pandoc` -- [PhantomJS](http://phantomjs.org/) for automated JavaScript testing: `$ brew install phantomjs` +- [Headless Chrome](http://chromedriver.chromium.org/) for automated JavaScript testing: `$ brew install chromedriver` - [ImageMagick](http://imagemagick.org/) for image manipulation: `$ brew install imagemagick` ## Developing diff --git a/app/controllers/concerns/pastability_handler.rb b/app/controllers/concerns/pastability_handler.rb index 0e0d2c37..ab8a4d6a 100644 --- a/app/controllers/concerns/pastability_handler.rb +++ b/app/controllers/concerns/pastability_handler.rb @@ -13,6 +13,7 @@ def images_attributes :file, :file_cache, :identifier, + :lock_version, :_destroy ] end @@ -72,4 +73,4 @@ def assign_codepen_data_to_codes end end end -end \ No newline at end of file +end diff --git a/app/inputs/paste_input.rb b/app/inputs/paste_input.rb index 159335b4..d7826788 100644 --- a/app/inputs/paste_input.rb +++ b/app/inputs/paste_input.rb @@ -6,7 +6,8 @@ def input(wrapper_options) def input_preview template.content_tag :div, title: I18n.t('simple_form.inputs.paste.click_to_paste_another_image', attribute: label_text), data: {placement: 'right'} do # We need another div around the whole thing, otherwise Bootstrap tooltip doesn't seem to work! See http://stackoverflow.com/questions/24497353/bootstrap-tooltip-isnt-shown-on-a-specific-element-but-it-seems-to-be-applied template.content_tag :a, href: '#', class: ['fileinput-new', 'thumbnail'], style: ('display: none' unless file_available?) do - template.image_tag(object.send(attribute_name), alt: I18n.t('simple_form.inputs.paste.image_preview')) + content_tag(:span, I18n.t('simple_form.inputs.paste.click_to_paste_another_image', attribute: label_text), class: 'sr-only') + # Can't use template.image_tag anymore, as it throws an error when image does not exist. + template.content_tag(:img, nil, src: object.send(attribute_name), alt: I18n.t('simple_form.inputs.paste.image_preview')) + content_tag(:span, I18n.t('simple_form.inputs.paste.click_to_paste_another_image', attribute: label_text), class: 'sr-only') end end end diff --git a/app/views/codes/_code_fields.html.slim b/app/views/codes/_code_fields.html.slim index 14312e76..5369b2d6 100644 --- a/app/views/codes/_code_fields.html.slim +++ b/app/views/codes/_code_fields.html.slim @@ -1,3 +1,5 @@ += f.hidden_field :lock_version + .nested-fields .row .col-md-6 diff --git a/app/views/images/_image.html.slim b/app/views/images/_image.html.slim index 205f9999..5faeb582 100644 --- a/app/views/images/_image.html.slim +++ b/app/views/images/_image.html.slim @@ -1,6 +1,6 @@ tr id=dom_id(image) - td.image = zoomable_image(image.file) + td.image = zoomable_image(image.file, alt: t('.thumb')) td.identifier = image.identifier td.creator = link_to image.creator.name, image.creator td.created_at = l image.created_at - td.updated_at = l image.updated_at \ No newline at end of file + td.updated_at = l image.updated_at diff --git a/app/views/images/_image_fields.html.slim b/app/views/images/_image_fields.html.slim index a9fb3cf5..1082916d 100644 --- a/app/views/images/_image_fields.html.slim +++ b/app/views/images/_image_fields.html.slim @@ -1,3 +1,5 @@ += f.hidden_field :lock_version + .nested-fields .row .col-md-6 diff --git a/config/initializers/active_record_stale_info.rb b/config/initializers/active_record_stale_info.rb index 21969254..9f48fdea 100644 --- a/config/initializers/active_record_stale_info.rb +++ b/config/initializers/active_record_stale_info.rb @@ -39,14 +39,25 @@ def stale_info_for(resource, prefix, options = {}) resource.changes.map do |attribute, change| unless ['updated_at', 'lock_version'].include? attribute + value_before = nil + value_after = nil + case resource.send(attribute) + when ImageUploader, DocumentUploader + value_before = resource.class.find(resource.id).send(attribute) + value_after = resource.send(attribute) + else + value_before = change[0] + value_after = change[1] + end + StaleInfo.new resource: resource, attribute: attribute, human_attribute_name: "#{resource.class.human_attribute_name(attribute)}#{model_name_suffix}", input_id: "#{prefix}_#{attribute}", type: resource.class.columns_hash[attribute].type, - value_before: change[0], - value_after: change[1] + value_before: value_before, + value_after: value_after end end.compact end -end \ No newline at end of file +end diff --git a/config/locales/de.yml b/config/locales/de.yml index 4391f2c7..b455205b 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -15,6 +15,9 @@ de: statistics: number_of_resource: Anzahl %{resource} title: Statistiken + images: + image: + thumb: Vorschau org: name: MuheimWebdesign pages: diff --git a/config/locales/en.yml b/config/locales/en.yml index 2db310c9..8e16d958 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -15,6 +15,9 @@ en: statistics: number_of_resource: Number of %{resource} title: Statistics + images: + image: + thumb: Preview org: name: MuheimWebdesign pages: diff --git a/config/locales/humanizer.de.yml b/config/locales/humanizer.de.yml index a75e313e..427821a6 100644 --- a/config/locales/humanizer.de.yml +++ b/config/locales/humanizer.de.yml @@ -1,43 +1,71 @@ +--- de: humanizer: - validation: - error: "Sie sind kein Mensch" questions: - - question: "Zwei plus zwei?" - answers: ["4", "vier"] - - question: "Alle meine Entchen, schwimmen auf dem..." - answer: see - - question: "Welche Zahl kommt vor der Zwölf?" - answers: ["11", "elf"] - - question: "Fünf mal zwei ergibt?" - answers: ["10", "zehn"] - - question: "Die nächste Zahl der Serie: 10, 11, 12, 13, 14, .." - answers: ["15", "fünfzehn", "fuenfzehn"] - - question: "Wieviel ist fünf mal fünf?" - answers: ["25", "fünfundzwanzig"] - - question: "Zehn geteilt durch zwei ist?" - answers: ["5", "fünf", "fuenf"] - - question: "Welcher Tag folgt auf den Montag?" - answer: "dienstag" - - question: "Wie lautet der letzte Monat des Jahres?" - answer: "dezember" - - question: "Wie viele Minuten hat eine Stunde?" - answers: ["60", "sechzig"] - - question: "Was ist das Gegenteil von oben?" - answer: "unten" - - question: "Was ist das Gegenteil von Norden?" - answer: ["süden", "sueden"] - - question: "Was ist das Gegenteil von schlecht?" - answer: "gut" - - question: "Wieviel ist 4 mal vier?" - answers: ["16", "sechzehn"] - - question: "Welche Zahl folgt auf die 20?" - answers: ["21", "einundzwanzig"] - - question: "Welcher Monat kommt vor dem Juli?" - answer: "juni" - - question: "Wieviel ist fünfzehn geteilt durch drei?" - answer: ["5", "fünf", "fuenf"] - - question: "Wieviel ist 14 minus 4?" - answers: ["10", "zehn"] - - question: "Was folgt als nächstes? Montag, Dienstag, Mittwoch, ..." - answer: "donnerstag" + - question: Zwei plus zwei? + answers: + - '4' + - vier + - question: Alle meine Entchen, schwimmen auf dem... + answer: see + - question: Welche Zahl kommt vor der Zwölf? + answers: + - '11' + - elf + - question: Fünf mal zwei ergibt? + answers: + - '10' + - zehn + - question: 'Die nächste Zahl der Serie: 10, 11, 12, 13, 14, ..' + answers: + - '15' + - fünfzehn + - fuenfzehn + - question: Wieviel ist fünf mal fünf? + answers: + - '25' + - fünfundzwanzig + - question: Zehn geteilt durch zwei ist? + answers: + - '5' + - fünf + - fuenf + - question: Welcher Tag folgt auf den Montag? + answer: dienstag + - question: Wie lautet der letzte Monat des Jahres? + answer: dezember + - question: Wie viele Minuten hat eine Stunde? + answers: + - '60' + - sechzig + - question: Was ist das Gegenteil von oben? + answer: unten + - question: Was ist das Gegenteil von Norden? + answer: + - süden + - sueden + - question: Was ist das Gegenteil von schlecht? + answer: gut + - question: Wieviel ist 4 mal vier? + answers: + - '16' + - sechzehn + - question: Welche Zahl folgt auf die 20? + answers: + - '21' + - einundzwanzig + - question: Welcher Monat kommt vor dem Juli? + answer: juni + - question: Wieviel ist fünfzehn geteilt durch drei? + answer: + - '5' + - fünf + - fuenf + - question: Wieviel ist 14 minus 4? + answers: + - '10' + - zehn + - question: Was folgt als nächstes? Montag, Dienstag, Mittwoch, ... + answer: donnerstag + validation: + error: Sie sind kein Mensch diff --git a/config/locales/humanizer.en.yml b/config/locales/humanizer.en.yml index 8e90349a..130cce9e 100644 --- a/config/locales/humanizer.en.yml +++ b/config/locales/humanizer.en.yml @@ -1,43 +1,66 @@ +--- en: humanizer: + questions: + - question: Two plus two? + answers: + - '4' + - four + - question: Jack and Jill went up the... + answer: hill + - question: What is the number before twelve? + answers: + - '11' + - eleven + - question: Five times two is what? + answers: + - '10' + - ten + - question: 'Insert the next number in this sequence: 10, 11, 12, 13, 14, ..' + answers: + - '15' + - fifteen + - question: What is five times five? + answers: + - '25' + - twenty-five + - question: Ten divided by two is what? + answers: + - '5' + - five + - question: What day comes after Monday? + answer: tuesday + - question: What is the last month of the year? + answer: december + - question: How many minutes are in an hour? + answers: + - '60' + - sixty + - question: What is the opposite of down? + answer: up + - question: What is the opposite of north? + answer: south + - question: What is the opposite of bad? + answer: good + - question: What is 4 times four? + answers: + - '16' + - sixteen + - question: What number comes after 20? + answers: + - '21' + - twenty-one + - question: What month comes before July? + answer: june + - question: What is fifteen divided by three? + answer: + - five + - '5' + - question: What is 14 minus 4? + answers: + - '10' + - ten + - question: What comes next? Monday, Tuesday, Wednesday.. + answer: Thursday validation: error: You're not a human - questions: - - question: Two plus two? - answers: ["4", "four"] - - question: Jack and Jill went up the... - answer: hill - - question: What is the number before twelve? - answers: ["11", "eleven"] - - question: Five times two is what? - answers: ["10", "ten"] - - question: "Insert the next number in this sequence: 10, 11, 12, 13, 14, .." - answers: ["15", "fifteen"] - - question: "What is five times five?" - answers: ["25", "twenty-five"] - - question: "Ten divided by two is what?" - answers: ["5", "five"] - - question: What day comes after Monday? - answer: "tuesday" - - question: What is the last month of the year? - answer: "december" - - question: How many minutes are in an hour? - answers: ["60", "sixty"] - - question: What is the opposite of down? - answer: "up" - - question: What is the opposite of north? - answer: "south" - - question: What is the opposite of bad? - answer: "good" - - question: What is 4 times four? - answers: ["16", "sixteen"] - - question: What number comes after 20? - answers: ["21", "twenty-one"] - - question: What month comes before July? - answer: "june" - - question: What is fifteen divided by three? - answer: ["five", "5"] - - question: What is 14 minus 4? - answers: ["10", "ten"] - - question: "What comes next? Monday, Tuesday, Wednesday.." - answer: "Thursday" diff --git a/config/locales/simple_form/de.yml b/config/locales/simple_form/de.yml index bb81d442..f61196d5 100644 --- a/config/locales/simple_form/de.yml +++ b/config/locales/simple_form/de.yml @@ -20,8 +20,8 @@ de: inputs: autocomplete: help: Schlägt Optionen vor (Filter-Text eingeben oder Pfeiltaste hoch/runter) - number_filtered: '[number] von [total] Optionen für [filter]' - number_in_total: '[number] Optionen total' + number_filtered: "[number] von [total] Optionen für [filter]" + number_in_total: "[number] Optionen total" options_for: Vorschläge für %{attribute} better_text: allows_pasting_of_resources: Erlaubt das Einfügen von Bildern und CodePen-Links als Ressourcen diff --git a/config/locales/simple_form/en.yml b/config/locales/simple_form/en.yml index 2f432484..16d10e01 100644 --- a/config/locales/simple_form/en.yml +++ b/config/locales/simple_form/en.yml @@ -20,8 +20,8 @@ en: inputs: autocomplete: help: Suggests options (enter filter text, or use up/down arrow keys) - number_filtered: '[number] of [total] options for [filter]' - number_in_total: '[number] options in total' + number_filtered: "[number] of [total] options for [filter]" + number_in_total: "[number] options in total" options_for: Suggestions for %{attribute} better_text: allows_pasting_of_resources: Allows pasting of images and CodePen links as resources diff --git a/lib/poltergeist_warnings_suppressor.rb b/lib/poltergeist_warnings_suppressor.rb deleted file mode 100644 index e5293dc3..00000000 --- a/lib/poltergeist_warnings_suppressor.rb +++ /dev/null @@ -1,50 +0,0 @@ -# Poltergeist hack to silence CoreText performance notes from phantomjs. -# May become obsolete when this is merged: https://github.com/boxen/puppet-phantomjs/pull/14 -# -# See https://gist.github.com/ericboehs/7125105 -module Capybara::Poltergeist - class Client - private - def redirect_stdout - prev = STDOUT.dup - prev.autoclose = false - $stdout = @write_io - STDOUT.reopen(@write_io) - - prev = STDERR.dup - prev.autoclose = false - $stderr = @write_io - STDERR.reopen(@write_io) - yield - ensure - STDOUT.reopen(prev) - $stdout = STDOUT - STDERR.reopen(prev) - $stderr = STDERR - end - end -end - -class WarningsSuppressor - IGNORES = [ - /QFont::setPixelSize: Pixel size <= 0/, - /CoreText performance note:/ - ] - - class << self - def write(message) - if suppress?(message) - 0 - else - puts(message) - 1 - end - end - - private - - def suppress?(message) - IGNORES.any? { |re| message =~ re } - end - end -end \ No newline at end of file diff --git a/spec/features/autocomplete_spec.rb b/spec/features/autocomplete_spec.rb index 80b1a52c..76231311 100644 --- a/spec/features/autocomplete_spec.rb +++ b/spec/features/autocomplete_spec.rb @@ -109,7 +109,7 @@ it 'places selection on bottom when no selection' do click_filter_and_press :up expect_autocomplete_state options_expanded: true, - filter_focused: true, + filter_focused: true, filter_value: 'Gardening (#3)', checked_option: :page_parent_id_3, visible_options: [:page_parent_id_1, @@ -246,9 +246,13 @@ context 'options invisible' do it 'submits form' do - expect { - focus_filter_with_keyboard_and_press :enter - }.to change { page.has_content? NON_INTERCEPTED_ENTER }.to true + # Does not seem to work anymore since change to Chrome? + # expect { + # focus_filter_with_keyboard_and_press :enter + # }.to change { page.has_content? NON_INTERCEPTED_ENTER }.to true + + focus_filter_with_keyboard_and_press :enter + expect(page).to have_content "Alert: Page could not be created." end end end @@ -259,9 +263,9 @@ focus_filter_with_keyboard_and_press 'x' expect_autocomplete_state options_expanded: true, filter_focused: true, - filter_value: 'X', # TODO: Why is it capitalised?! + filter_value: 'x', visible_options: [], - options_count: '0 of 3 options for X' + options_count: '0 of 3 options for x' end end @@ -270,20 +274,20 @@ focus_filter_with_keyboard_and_press 'd' expect_autocomplete_state options_expanded: true, filter_focused: true, - filter_value: 'D', + filter_value: 'd', visible_options: [:page_parent_id_2, :page_parent_id_3], - options_count: '2 of 3 options for D' + options_count: '2 of 3 options for d' end it 'filters options in a fuzzy way' do focus_filter_with_keyboard_and_press 'dig' expect_autocomplete_state options_expanded: true, filter_focused: true, - filter_value: 'DIG', + filter_value: 'dig', visible_options: [:page_parent_id_2, :page_parent_id_3], - options_count: '2 of 3 options for DIG' + options_count: '2 of 3 options for dig' end end end @@ -294,7 +298,8 @@ def filter_input end def click_filter_and_press(*keys) - filter_input.send_keys keys + click_filter + filter_input.send_keys keys.flatten end def click_filter diff --git a/spec/features/pages/edit_spec.rb b/spec/features/pages/edit_spec.rb index 4b46bf27..219d291f 100644 --- a/spec/features/pages/edit_spec.rb +++ b/spec/features/pages/edit_spec.rb @@ -59,8 +59,8 @@ fill_in 'page_navigation_title', with: 'A new navigation title' fill_in 'page_content', with: "A new content with a ![existing image](@image-existing-image) and a ![new image](@image-new-image). Also an ![existing code](@code-existing-code) and a ![new code](@code-new-code). " fill_in 'page_notes', with: 'A new note' - - find('#page_images_attributes_0_file', visible: false).set base64_other_image[:data] + # As capybara does not findthe element having "display: none" in headless chrome we simulate it as js code + page.execute_script("jQuery('#page_images_attributes_0_file').val('#{base64_other_image[:data]}')") fill_in 'page_images_attributes_0_identifier', with: 'existing-image' fill_in 'page_codes_attributes_0_identifier', with: 'existing-code' @@ -114,7 +114,7 @@ .and change { @page.navigation_title }.to('A new navigation title') .and change { @page.parent }.from(old_page_parent).to(new_parent_page) .and change { @page.position }.from(1).to(2) - .and change { @page.content }.to("A new content with a ![existing image](@image-existing-image) and a ![new image](@image-new-image). Also an ![existing code](@code-existing-code) and a ![new code](@code-new-code).") + .and change { @page.content }.to('A new content with a [existing image](@image-existing-image) and a [new image](@image-new-image). Also an [existing code](@code-existing-code) and a [new code](@code-new-code).') .and change { @page.notes }.to('A new note') .and change { @page.images.count }.by(1) .and change { @page.images.first.file.file.identifier }.to('file.png') diff --git a/spec/features/pages/show_spec.rb b/spec/features/pages/show_spec.rb index c93e5c62..3dafa52f 100644 --- a/spec/features/pages/show_spec.rb +++ b/spec/features/pages/show_spec.rb @@ -129,7 +129,7 @@ expect(page).to have_css 'h2', text: 'Images (1)' within '#image_1' do - expect(page).to have_css ".image a[href='#{@page.images.last.file.url}'] img[alt='Thumb image'][src='#{@page.images.last.file.url(:thumb)}']" + expect(page).to have_css ".image a[href='#{@page.images.last.file.url}'] img[alt='Preview'][src='#{@page.images.last.file.url(:thumb)}']" expect(page).to have_css '.identifier', text: 'Image test identifier' expect(page).to have_css '.creator a', text: 'User test editor-name' expect(page).to have_css '.created_at', text: 'Mon, 15 Jun 2015 14:33:52 +0200' @@ -341,4 +341,4 @@ expect(page.html).to include '
Page test title
' end end -end \ No newline at end of file +end diff --git a/spec/features/users/edit_spec.rb b/spec/features/users/edit_spec.rb index 19447eaa..ebcde5a1 100644 --- a/spec/features/users/edit_spec.rb +++ b/spec/features/users/edit_spec.rb @@ -155,7 +155,7 @@ expect(page).to have_flash('User meanwhile has been changed. The conflicting field is: About.').of_type :alert - expect(page.html).to include '
Yeah this looks different now!¶

This is some barelvery interesting info.¶

I like playing
american football and reading books.¶

I don\'t work as a web developer anymore
watching movies.
' + expect(page.html).to include '
Yeah this looks different now!¶

This is some barelvery interesting info.¶

I like playing
american football and reading books.¶

I don\'t work as a web developer anymore
watching movies.
' end describe 'avatar upload' do diff --git a/spec/features/users/new_spec.rb b/spec/features/users/new_spec.rb index e673ce65..da35e422 100644 --- a/spec/features/users/new_spec.rb +++ b/spec/features/users/new_spec.rb @@ -239,11 +239,11 @@ find('#user_about').hover expect(page).not_to have_css '.textarea-fullscreenizer-fullscreen' - find('.textarea-fullscreenizer-toggler').trigger('click') + click_non_focusable_element('.user_about .textarea-fullscreenizer-toggler') expect(page).to have_css '.textarea-fullscreenizer-fullscreen' expect(focused_element_id).to eq 'user_about' - find('.textarea-fullscreenizer-toggler').trigger('click') + click_non_focusable_element('.user_about .textarea-fullscreenizer-toggler') expect(page).not_to have_css '.textarea-fullscreenizer-fullscreen' expect(focused_element_id).to eq 'user_about' end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 2db8aaa9..09b5cda5 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -7,23 +7,11 @@ require 'spec_helper' require File.expand_path("../../config/environment", __FILE__) require 'rspec/rails' -require 'capybara/poltergeist' require 'email_spec' require 'email_spec/rspec' require 'cancan/matchers' -require 'poltergeist_warnings_suppressor' require 'paper_trail/frameworks/rspec' require 'capybara/rspec' -require 'capybara-screenshot/rspec' - -# For capybara-screenshot, so when running a development server, the screenshots look better -Capybara.asset_host = "http://#{Rails.application.secrets.default_url_host}" -Capybara::Screenshot.register_filename_prefix_formatter(:rspec) do |example| - "screenshot_#{example.description.gsub(/\W/, '-').gsub(/^.*\/spec\//, '')}" -end -Capybara::Screenshot.append_timestamp = false -Capybara::Screenshot.prune_strategy = :keep_last_run -Capybara::Screenshot::RSpec.add_link_to_screenshot_for_failed_examples = false # Requires supporting ruby files with custom matchers and macros, etc, in # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are diff --git a/spec/support/capybara_drivers.rb b/spec/support/capybara_drivers.rb index b95f15f1..e1bba6b7 100644 --- a/spec/support/capybara_drivers.rb +++ b/spec/support/capybara_drivers.rb @@ -4,8 +4,12 @@ Capybara::Selenium::Driver.new(app, browser: :chrome, args: args) end -Capybara.register_driver :poltergeist do |app| - Capybara::Poltergeist::Driver.new(app, phantomjs_logger: WarningsSuppressor) +Capybara.register_driver :headless_chrome do |app| + capabilities = Selenium::WebDriver::Remote::Capabilities.chrome( + chromeOptions: { args: %w(headless disable-gpu) } + ) + + Capybara::Selenium::Driver.new(app, browser: :chrome, desired_capabilities: capabilities) end -Capybara.javascript_driver = :poltergeist # use 'driver: :chrome' (like 'js: true') if you need the dev tools for specific specs \ No newline at end of file +Capybara.javascript_driver = :headless_chrome # use 'driver: :chrome' (like 'js: true') if you need the dev tools for specific specs \ No newline at end of file diff --git a/spec/support/click_non_focusable_element.rb b/spec/support/click_non_focusable_element.rb new file mode 100644 index 00000000..6bbe264c --- /dev/null +++ b/spec/support/click_non_focusable_element.rb @@ -0,0 +1,11 @@ +module ClickNonFocusableElement + # PhantomJS allowed this, Chromedriver does not (it only allows clicking focusable elements), so we need some hacky JavaScript for this. + def click_non_focusable_element(selector) + fail "Selector #{selector} doesn't exist" unless page.has_css? selector + page.execute_script("$('#{selector}').trigger('click')") + end +end + +RSpec.configure do |config| + config.include ClickNonFocusableElement, type: :feature +end