From 9c9dcf6e69b82bade303e3e18b27d3d03826ae59 Mon Sep 17 00:00:00 2001 From: Maxim Khan-Magomedov Date: Thu, 14 Jul 2016 01:21:39 +0300 Subject: [PATCH] Sovia 5 on rails 5 --- .gitignore | 10 +- Gemfile | 53 ++-- Gemfile.lock | 249 ++++++++---------- Rakefile | 2 +- app/assets/config/manifest.js | 3 + app/assets/javascripts/application.js | 2 +- app/assets/javascripts/biovision.js | 76 ++++++ app/assets/javascripts/cable.js | 13 + .../javascripts/channels}/.keep | 0 app/assets/javascripts/file-preview.js | 18 -- app/assets/stylesheets/application.scss | 4 +- app/assets/stylesheets/layout.scss | 41 ++- app/assets/stylesheets/message-box.scss | 44 +++- app/assets/stylesheets/shared.scss | 96 +++++++ app/assets/stylesheets/toggleable.scss | 74 ++++++ app/channels/application_cable/channel.rb | 4 + app/channels/application_cable/connection.rb | 4 + app/controllers/admin/agents_controller.rb | 2 - app/controllers/admin/browsers_controller.rb | 2 - app/controllers/agents_controller.rb | 2 - app/controllers/api/agents_controller.rb | 2 - app/controllers/api/browsers_controller.rb | 2 - app/controllers/application_controller.rb | 8 - app/controllers/browsers_controller.rb | 2 - app/jobs/application_job.rb | 2 + app/mailers/application_mailer.rb | 4 + app/models/agent.rb | 36 --- app/models/application_record.rb | 3 + app/models/browser.rb | 25 -- app/models/concerns/required_unique_name.rb | 11 - app/views/index/index.html.erb | 1 + app/views/layouts/_footer.html.erb | 2 +- app/views/layouts/_header.html.erb | 2 +- app/views/layouts/_meta_texts.html.erb | 8 +- app/views/layouts/application.html.erb | 1 + app/views/layouts/mailer.html.erb | 13 + app/views/layouts/mailer.text.erb | 1 + bin/puma | 17 -- bin/pumactl | 17 -- bin/rails | 2 +- bin/setup | 29 +- bin/update | 29 ++ config.ru | 3 +- config/application.rb | 13 +- config/boot.rb | 2 +- config/cable.yml | 9 + config/environment.rb | 2 +- config/environments/development.rb | 35 ++- config/environments/production.rb | 43 +-- config/environments/test.rb | 17 +- .../application_controller_renderer.rb | 6 + config/initializers/cookies_serializer.rb | 2 + config/initializers/new_framework_defaults.rb | 24 ++ config/initializers/wrap_parameters.rb | 4 +- config/locales/ru.yml | 3 + config/locales/tracking/ru.yml | 59 ----- config/routes.rb | 33 --- config/spring.rb | 6 + db/migrate/20160627202551_create_browsers.rb | 14 - db/migrate/20160627204318_create_agents.rb | 14 - db/schema.rb | 49 ---- db/seeds.rb | 6 +- lib/tasks/agents.rake | 37 --- lib/tasks/browsers.rake | 37 --- .../apple-touch-icon-precomposed.png | 0 .../.keep => public/apple-touch-icon.png | 0 public/robots.txt | 9 +- .../admin/agents_controller_spec.rb | 5 - .../admin/browsers_controller_spec.rb | 5 - spec/controllers/agents_controller_spec.rb | 5 - .../controllers/api/agents_controller_spec.rb | 5 - .../api/browsers_controller_spec.rb | 5 - spec/controllers/browsers_controller_spec.rb | 5 - spec/factories/agents.rb | 5 - spec/factories/browsers.rb | 5 - spec/models/agent_spec.rb | 37 --- spec/models/browser_spec.rb | 9 - spec/spec_helper.rb | 31 ++- .../excluded_foreign_entity.rb | 7 + .../shared_examples/has_unique_name.rb | 13 - spec/support/shared_examples/required_name.rb | 11 - tmp/.keep | 0 82 files changed, 715 insertions(+), 776 deletions(-) create mode 100644 app/assets/config/manifest.js create mode 100644 app/assets/javascripts/biovision.js create mode 100644 app/assets/javascripts/cable.js rename app/{mailers => assets/javascripts/channels}/.keep (100%) delete mode 100644 app/assets/javascripts/file-preview.js create mode 100644 app/assets/stylesheets/toggleable.scss create mode 100644 app/channels/application_cable/channel.rb create mode 100644 app/channels/application_cable/connection.rb delete mode 100644 app/controllers/admin/agents_controller.rb delete mode 100644 app/controllers/admin/browsers_controller.rb delete mode 100644 app/controllers/agents_controller.rb delete mode 100644 app/controllers/api/agents_controller.rb delete mode 100644 app/controllers/api/browsers_controller.rb delete mode 100644 app/controllers/browsers_controller.rb create mode 100644 app/jobs/application_job.rb create mode 100644 app/mailers/application_mailer.rb delete mode 100644 app/models/agent.rb create mode 100644 app/models/application_record.rb delete mode 100644 app/models/browser.rb delete mode 100644 app/models/concerns/required_unique_name.rb create mode 100644 app/views/layouts/mailer.html.erb create mode 100644 app/views/layouts/mailer.text.erb delete mode 100755 bin/puma delete mode 100755 bin/pumactl create mode 100755 bin/update create mode 100644 config/cable.yml create mode 100644 config/initializers/application_controller_renderer.rb create mode 100644 config/initializers/new_framework_defaults.rb delete mode 100644 config/locales/tracking/ru.yml create mode 100644 config/spring.rb delete mode 100644 db/migrate/20160627202551_create_browsers.rb delete mode 100644 db/migrate/20160627204318_create_agents.rb delete mode 100644 db/schema.rb delete mode 100644 lib/tasks/agents.rake delete mode 100644 lib/tasks/browsers.rake rename app/assets/stylesheets/tracking.scss => public/apple-touch-icon-precomposed.png (100%) rename app/models/.keep => public/apple-touch-icon.png (100%) delete mode 100644 spec/controllers/admin/agents_controller_spec.rb delete mode 100644 spec/controllers/admin/browsers_controller_spec.rb delete mode 100644 spec/controllers/agents_controller_spec.rb delete mode 100644 spec/controllers/api/agents_controller_spec.rb delete mode 100644 spec/controllers/api/browsers_controller_spec.rb delete mode 100644 spec/controllers/browsers_controller_spec.rb delete mode 100644 spec/factories/agents.rb delete mode 100644 spec/factories/browsers.rb delete mode 100644 spec/models/agent_spec.rb delete mode 100644 spec/models/browser_spec.rb create mode 100644 spec/support/shared_examples/excluded_foreign_entity.rb delete mode 100644 spec/support/shared_examples/has_unique_name.rb delete mode 100644 spec/support/shared_examples/required_name.rb create mode 100644 tmp/.keep diff --git a/.gitignore b/.gitignore index 00588eed..2bded20b 100644 --- a/.gitignore +++ b/.gitignore @@ -9,12 +9,18 @@ # Ignore all logfiles and tempfiles. /log/* +/tmp/* !/log/.keep -/tmp +!/tmp/.keep + +# Ignore Byebug command history file. +.byebug_history /config/database.yml /config/secrets.yml +/public/uploads + /spec/examples.txt -/public/uploads/* +.env diff --git a/Gemfile b/Gemfile index a6aab413..8128525d 100644 --- a/Gemfile +++ b/Gemfile @@ -2,65 +2,56 @@ source 'https://rubygems.org' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' -gem 'rails', '~> 4.2.6' +gem 'rails', '~> 5.0.0' # Use postgresql as the database for Active Record -gem 'pg', '~> 0.15' +gem 'pg', '~> 0.18' +# Use Puma as the app server +gem 'puma', '~> 3.0' # Use SCSS for stylesheets gem 'sass-rails', '~> 5.0' # Use Uglifier as compressor for JavaScript assets gem 'uglifier', '>= 1.3.0' # Use CoffeeScript for .coffee assets and views -gem 'coffee-rails', '~> 4.1.0' +gem 'coffee-rails', '~> 4.2' # See https://github.com/rails/execjs#readme for more supported runtimes # gem 'therubyracer', platforms: :ruby # Use jquery as the JavaScript library gem 'jquery-rails' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder -gem 'jbuilder', '~> 2.0' -# bundle exec rake doc:rails generates the API under doc/api. -gem 'sdoc', '~> 0.4.0', group: :doc +gem 'jbuilder', '~> 2.5' +# Use Redis adapter to run Action Cable in production +# gem 'redis', '~> 3.0' -# Use ActiveModel has_secure_password gem 'bcrypt', '~> 3.1.7' -gem 'kaminari' -gem 'rails-i18n', '~> 4.0.0' -gem 'puma' - -# Backport from rails 5 -gem 'has_secure_token' - -# Auto-prefix CSS for old browsers +# Автоматическая расстановка префиксов в CSS gem 'autoprefixer-rails' -# Processing images -gem 'mini_magick' - -# Attaching uploaded files to models -gem 'carrierwave' -gem 'carrierwave-bombshelter' - -# Аутентификация через OAuth -gem 'omniauth-twitter' -gem 'omniauth-facebook' -gem 'omniauth-vkontakte' +gem 'kaminari' +gem 'rails-i18n', '~> 5.0.0' group :development, :test do - # Call 'byebug' anywhere in the code to stop execution and get a debugger console - gem 'byebug' gem 'rspec-rails' gem 'database_cleaner' gem 'factory_girl_rails' end -group :development do - # Access an IRB console on exception pages or by using <%= console %> in views - gem 'web-console', '~> 2.0' +group :development, :test do + # Call 'byebug' anywhere in the code to stop execution and get a debugger console + gem 'byebug', platform: :mri +end +group :development do + # Access an IRB console on exception pages or by using <%= console %> anywhere in the code. + gem 'web-console' + gem 'listen', '~> 3.0.5' # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem 'spring' + gem 'spring-watcher-listen', '~> 2.0.0' gem 'mina' end +# Windows does not include zoneinfo files, so bundle the tzinfo-data gem +gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] diff --git a/Gemfile.lock b/Gemfile.lock index b4fcd189..f245675c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,63 +1,52 @@ GEM remote: https://rubygems.org/ specs: - actionmailer (4.2.6) - actionpack (= 4.2.6) - actionview (= 4.2.6) - activejob (= 4.2.6) + actioncable (5.0.0) + actionpack (= 5.0.0) + nio4r (~> 1.2) + websocket-driver (~> 0.6.1) + actionmailer (5.0.0) + actionpack (= 5.0.0) + actionview (= 5.0.0) + activejob (= 5.0.0) mail (~> 2.5, >= 2.5.4) - rails-dom-testing (~> 1.0, >= 1.0.5) - actionpack (4.2.6) - actionview (= 4.2.6) - activesupport (= 4.2.6) - rack (~> 1.6) - rack-test (~> 0.6.2) - rails-dom-testing (~> 1.0, >= 1.0.5) + rails-dom-testing (~> 2.0) + actionpack (5.0.0) + actionview (= 5.0.0) + activesupport (= 5.0.0) + rack (~> 2.0) + rack-test (~> 0.6.3) + rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (4.2.6) - activesupport (= 4.2.6) + actionview (5.0.0) + activesupport (= 5.0.0) builder (~> 3.1) erubis (~> 2.7.0) - rails-dom-testing (~> 1.0, >= 1.0.5) + rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.2) - activejob (4.2.6) - activesupport (= 4.2.6) - globalid (>= 0.3.0) - activemodel (4.2.6) - activesupport (= 4.2.6) - builder (~> 3.1) - activerecord (4.2.6) - activemodel (= 4.2.6) - activesupport (= 4.2.6) - arel (~> 6.0) - activesupport (4.2.6) + activejob (5.0.0) + activesupport (= 5.0.0) + globalid (>= 0.3.6) + activemodel (5.0.0) + activesupport (= 5.0.0) + activerecord (5.0.0) + activemodel (= 5.0.0) + activesupport (= 5.0.0) + arel (~> 7.0) + activesupport (5.0.0) + concurrent-ruby (~> 1.0, >= 1.0.2) i18n (~> 0.7) - json (~> 1.7, >= 1.7.7) minitest (~> 5.1) - thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) - addressable (2.4.0) - arel (6.0.3) - autoprefixer-rails (6.3.6.2) + arel (7.0.0) + autoprefixer-rails (6.3.7) execjs bcrypt (3.1.11) - binding_of_caller (0.7.2) - debug_inspector (>= 0.0.1) builder (3.2.2) byebug (9.0.5) - carrierwave (0.11.2) - activemodel (>= 3.2.0) - activesupport (>= 3.2.0) - json (>= 1.7) - mime-types (>= 1.16) - mimemagic (>= 0.3.0) - carrierwave-bombshelter (0.2.2) - activesupport (>= 3.2.0) - carrierwave - fastimage - coffee-rails (4.1.1) + coffee-rails (4.2.1) coffee-script (>= 2.2.0) - railties (>= 4.0.0, < 5.1.x) + railties (>= 4.0.0, < 5.2.x) coffee-script (2.4.1) coffee-script-source execjs @@ -73,15 +62,9 @@ GEM factory_girl_rails (4.7.0) factory_girl (~> 4.7.0) railties (>= 3.0.0) - faraday (0.9.2) - multipart-post (>= 1.2, < 3) - fastimage (2.0.0) - addressable (~> 2) + ffi (1.9.14) globalid (0.3.6) activesupport (>= 4.1.0) - has_secure_token (1.0.0) - activerecord (>= 3.0) - hashie (3.4.4) i18n (0.7.0) jbuilder (2.5.0) activesupport (>= 3.0.0, < 5.1) @@ -90,123 +73,99 @@ GEM rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) - json (1.8.3) - jwt (1.5.1) kaminari (0.17.0) actionpack (>= 3.0.0) activesupport (>= 3.0.0) + listen (3.0.8) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) loofah (2.0.3) nokogiri (>= 1.5.9) mail (2.6.4) mime-types (>= 1.16, < 4) + method_source (0.8.2) mime-types (3.1) mime-types-data (~> 3.2015) mime-types-data (3.2016.0521) - mimemagic (0.3.1) mina (0.3.8) open4 (~> 1.3.4) rake - mini_magick (4.5.1) mini_portile2 (2.1.0) minitest (5.9.0) multi_json (1.12.1) - multi_xml (0.5.5) - multipart-post (2.0.0) + nio4r (1.2.1) nokogiri (1.6.8) mini_portile2 (~> 2.1.0) pkg-config (~> 1.1.7) - oauth (0.5.1) - oauth2 (1.1.0) - faraday (>= 0.8, < 0.10) - jwt (~> 1.0, < 1.5.2) - multi_json (~> 1.3) - multi_xml (~> 0.5) - rack (>= 1.2, < 3) - omniauth (1.3.1) - hashie (>= 1.2, < 4) - rack (>= 1.0, < 3) - omniauth-facebook (3.0.0) - omniauth-oauth2 (~> 1.2) - omniauth-oauth (1.1.0) - oauth - omniauth (~> 1.0) - omniauth-oauth2 (1.4.0) - oauth2 (~> 1.0) - omniauth (~> 1.2) - omniauth-twitter (1.2.1) - json (~> 1.3) - omniauth-oauth (~> 1.1) - omniauth-vkontakte (1.3.7) - omniauth-oauth2 (~> 1.1) open4 (1.3.4) pg (0.18.4) pkg-config (1.1.7) puma (3.4.0) - rack (1.6.4) + rack (2.0.1) rack-test (0.6.3) rack (>= 1.0) - rails (4.2.6) - actionmailer (= 4.2.6) - actionpack (= 4.2.6) - actionview (= 4.2.6) - activejob (= 4.2.6) - activemodel (= 4.2.6) - activerecord (= 4.2.6) - activesupport (= 4.2.6) + rails (5.0.0) + actioncable (= 5.0.0) + actionmailer (= 5.0.0) + actionpack (= 5.0.0) + actionview (= 5.0.0) + activejob (= 5.0.0) + activemodel (= 5.0.0) + activerecord (= 5.0.0) + activesupport (= 5.0.0) bundler (>= 1.3.0, < 2.0) - railties (= 4.2.6) - sprockets-rails - rails-deprecated_sanitizer (1.0.3) - activesupport (>= 4.2.0.alpha) - rails-dom-testing (1.0.7) - activesupport (>= 4.2.0.beta, < 5.0) + railties (= 5.0.0) + sprockets-rails (>= 2.0.0) + rails-dom-testing (2.0.1) + activesupport (>= 4.2.0, < 6.0) nokogiri (~> 1.6.0) - rails-deprecated_sanitizer (>= 1.0.1) rails-html-sanitizer (1.0.3) loofah (~> 2.0) - rails-i18n (4.0.8) + rails-i18n (5.0.0) i18n (~> 0.7) - railties (~> 4.0) - railties (4.2.6) - actionpack (= 4.2.6) - activesupport (= 4.2.6) + railties (~> 5.0) + railties (5.0.0) + actionpack (= 5.0.0) + activesupport (= 5.0.0) + method_source rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) rake (11.2.2) - rdoc (4.2.2) - json (~> 1.4) - rspec-core (3.4.4) - rspec-support (~> 3.4.0) - rspec-expectations (3.4.0) + rb-fsevent (0.9.7) + rb-inotify (0.9.7) + ffi (>= 0.5.0) + rspec-core (3.5.1) + rspec-support (~> 3.5.0) + rspec-expectations (3.5.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.4.0) - rspec-mocks (3.4.1) + rspec-support (~> 3.5.0) + rspec-mocks (3.5.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.4.0) - rspec-rails (3.4.2) - actionpack (>= 3.0, < 4.3) - activesupport (>= 3.0, < 4.3) - railties (>= 3.0, < 4.3) - rspec-core (~> 3.4.0) - rspec-expectations (~> 3.4.0) - rspec-mocks (~> 3.4.0) - rspec-support (~> 3.4.0) - rspec-support (3.4.1) + rspec-support (~> 3.5.0) + rspec-rails (3.5.1) + actionpack (>= 3.0) + activesupport (>= 3.0) + railties (>= 3.0) + rspec-core (~> 3.5.0) + rspec-expectations (~> 3.5.0) + rspec-mocks (~> 3.5.0) + rspec-support (~> 3.5.0) + rspec-support (3.5.0) sass (3.4.22) - sass-rails (5.0.4) - railties (>= 4.0.0, < 5.0) + sass-rails (5.0.5) + railties (>= 4.0.0, < 6) sass (~> 3.1) sprockets (>= 2.8, < 4.0) sprockets-rails (>= 2.0, < 4.0) tilt (>= 1.1, < 3) - sdoc (0.4.1) - json (~> 1.7, >= 1.7.7) - rdoc (~> 4.0) - spring (1.7.1) - sprockets (3.6.2) + spring (1.7.2) + spring-watcher-listen (2.0.0) + listen (>= 2.7, < 4.0) + spring (~> 1.2) + sprockets (3.6.3) concurrent-ruby (~> 1.0) rack (> 1, < 3) - sprockets-rails (3.0.4) + sprockets-rails (3.1.1) actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) @@ -217,11 +176,14 @@ GEM thread_safe (~> 0.1) uglifier (3.0.0) execjs (>= 0.3.0, < 3) - web-console (2.3.0) - activemodel (>= 4.0) - binding_of_caller (>= 0.7.2) - railties (>= 4.0) - sprockets-rails (>= 2.0, < 4.0) + web-console (3.3.1) + actionview (>= 5.0) + activemodel (>= 5.0) + debug_inspector + railties (>= 5.0) + websocket-driver (0.6.4) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.2) PLATFORMS ruby @@ -230,30 +192,25 @@ DEPENDENCIES autoprefixer-rails bcrypt (~> 3.1.7) byebug - carrierwave - carrierwave-bombshelter - coffee-rails (~> 4.1.0) + coffee-rails (~> 4.2) database_cleaner factory_girl_rails - has_secure_token - jbuilder (~> 2.0) + jbuilder (~> 2.5) jquery-rails kaminari + listen (~> 3.0.5) mina - mini_magick - omniauth-facebook - omniauth-twitter - omniauth-vkontakte - pg (~> 0.15) - puma - rails (~> 4.2.6) - rails-i18n (~> 4.0.0) + pg (~> 0.18) + puma (~> 3.0) + rails (~> 5.0.0) + rails-i18n (~> 5.0.0) rspec-rails sass-rails (~> 5.0) - sdoc (~> 0.4.0) spring + spring-watcher-listen (~> 2.0.0) + tzinfo-data uglifier (>= 1.3.0) - web-console (~> 2.0) + web-console BUNDLED WITH 1.12.5 diff --git a/Rakefile b/Rakefile index ba6b733d..e85f9139 100644 --- a/Rakefile +++ b/Rakefile @@ -1,6 +1,6 @@ # Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. -require File.expand_path('../config/application', __FILE__) +require_relative 'config/application' Rails.application.load_tasks diff --git a/app/assets/config/manifest.js b/app/assets/config/manifest.js new file mode 100644 index 00000000..b16e53d6 --- /dev/null +++ b/app/assets/config/manifest.js @@ -0,0 +1,3 @@ +//= link_tree ../images +//= link_directory ../javascripts .js +//= link_directory ../stylesheets .css diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 646c5aba..105a4f18 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -5,7 +5,7 @@ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path. // // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the -// compiled file. +// compiled file. JavaScript code in this file should be added after the last require_* statement. // // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details // about supported directives. diff --git a/app/assets/javascripts/biovision.js b/app/assets/javascripts/biovision.js new file mode 100644 index 00000000..cec8e0d3 --- /dev/null +++ b/app/assets/javascripts/biovision.js @@ -0,0 +1,76 @@ +"use strict"; + +$(function () { + $(document).on('change', 'input[type=file]', function () { + if ($(this).data('image')) { + var target = $('#' + $(this).data('image')).find('img'); + var input = this; + + if (input.files && input.files[0]) { + var reader = new FileReader(); + + reader.onload = function (e) { + target.attr('src', e.target.result); + }; + + reader.readAsDataURL(input.files[0]); + } + } + }); + + $(document).on('click', 'div.toggleable > span', function () { + if (!$(this).hasClass('switch')) { + var $flag = $(this); + var url = $(this).parent().data('url'); + var parameter = $(this).data('flag'); + + $.post({ + url: url, + data: { parameter: parameter }, + beforeSend: function() { + $flag.removeClass(); + $flag.addClass('switch'); + }, + success: function(response) { + $flag.removeClass(); + if (response.hasOwnProperty('data') && response['data'].hasOwnProperty(parameter)) { + switch (response['data'][parameter]) { + case true: + $flag.addClass('active'); + break; + case false: + $flag.addClass('inactive'); + break; + default: + $flag.addClass('unknown'); + } + } else { + $flag.addClass('unknown'); + } + } + }).fail(function(response) { + $flag.removeClass(); + $flag.addClass('unknown'); + handle_ajax_failure(response); + }); + } + }); + + $('div[data-destroy-url] button.destroy').on('click', function() { + var $button = $(this); + var $container = $(this).closest('div[data-destroy-url]'); + + $button.attr('disabled', true); + + $.ajax($container.data('destroy-url'), { + method: 'delete', + success: function(response) { + $container.remove(); + } + }).fail(handle_ajax_failure); + }); +}); + +function handle_ajax_failure(response) { + console.log(response); +} diff --git a/app/assets/javascripts/cable.js b/app/assets/javascripts/cable.js new file mode 100644 index 00000000..71ee1e66 --- /dev/null +++ b/app/assets/javascripts/cable.js @@ -0,0 +1,13 @@ +// Action Cable provides the framework to deal with WebSockets in Rails. +// You can generate new channels where WebSocket features live using the rails generate channel command. +// +//= require action_cable +//= require_self +//= require_tree ./channels + +(function() { + this.App || (this.App = {}); + + App.cable = ActionCable.createConsumer(); + +}).call(this); diff --git a/app/mailers/.keep b/app/assets/javascripts/channels/.keep similarity index 100% rename from app/mailers/.keep rename to app/assets/javascripts/channels/.keep diff --git a/app/assets/javascripts/file-preview.js b/app/assets/javascripts/file-preview.js deleted file mode 100644 index 0fe6f33c..00000000 --- a/app/assets/javascripts/file-preview.js +++ /dev/null @@ -1,18 +0,0 @@ -$(function() { - $(document).on('change', 'input[type=file]', function() { - if ($(this).data('image')) { - var target = $('#' + $(this).data('image')).find('img'); - var input = this; - - if (input.files && input.files[0]) { - var reader = new FileReader(); - - reader.onload = function (e) { - target.attr('src', e.target.result); - }; - - reader.readAsDataURL(input.files[0]); - } - } - }); -}); diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 517af380..8cca3c55 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -1,5 +1,5 @@ @import "shared"; -@import "layout"; @import "message-box"; @import "pagination"; -@import "tracking"; +@import "toggleable"; +@import "layout"; diff --git a/app/assets/stylesheets/layout.scss b/app/assets/stylesheets/layout.scss index 4a54383a..5b3e678b 100644 --- a/app/assets/stylesheets/layout.scss +++ b/app/assets/stylesheets/layout.scss @@ -4,7 +4,42 @@ html { font-size: 16px; } -.field_with_errors { - display: inline-block; - background: #fff7f7; +#main { + > div.options { + > ul { + margin: 1rem 0; + padding: 0; + font-size: $decreased_size; + line-height: 2rem; + + > li { + list-style: none; + display: inline-block; + margin: 0 0.5rem; + + &:before { + content: '['; + } + + &:after { + content: ']'; + } + } + } + } +} + +.hidden { + display: none !important; +} + +span.not-found { + color: #ffaaaa; + cursor: default; + + &:before { + content: '\26A0'; + color: #ff0000; + margin-right: 0.25rem; + } } diff --git a/app/assets/stylesheets/message-box.scss b/app/assets/stylesheets/message-box.scss index be77b73f..3d522544 100644 --- a/app/assets/stylesheets/message-box.scss +++ b/app/assets/stylesheets/message-box.scss @@ -1,15 +1,19 @@ -div.message-box { - background-repeat: no-repeat; - background-position: 1rem 1rem; - background-size: 1rem 1rem; +@mixin message-box { margin: 0 0 0.5rem 0; padding: 1rem 1rem 1rem 3rem; - border-style: dashed; - border-width: 0.0625rem; + background: { + repeat: no-repeat; + position: 1rem 1rem; + size: 1rem 1rem; + } + border: { + style: dashed; + width: 0.0625rem; + } } div.notice { - @extend div.message-box; + @include message-box; background-color: #eeffee; background-image: image_url('icons/message-box/notice.png'); color: #004000; @@ -17,7 +21,7 @@ div.notice { } div.warning { - @extend div.message-box; + @include message-box; background-color: #ffffee; background-image: image_url('icons/message-box/warning.png'); color: #404000; @@ -25,9 +29,31 @@ div.warning { } div.alert { - @extend div.message-box; + @include message-box; background-color: #ffeeee; background-image: image_url('icons/message-box/alert.png'); color: #400000; border-color: #eedddd; } + +section.errors { + border: solid #eedddd 0.0625rem; + padding: 1rem; + margin: 1rem; + + > h2 { + color: #400000; + background: #ffeeee image_url('icons/message-box/alert.png') no-repeat center left 1rem / 1rem 1rem; + font-size: 1.25rem; + padding: 1rem 1rem 1rem 3rem; + } + + ul { + color: #770000; + } +} + +.field_with_errors { + display: inline-block; + background: #fff7f7; +} diff --git a/app/assets/stylesheets/shared.scss b/app/assets/stylesheets/shared.scss index e69de29b..19a3607f 100644 --- a/app/assets/stylesheets/shared.scss +++ b/app/assets/stylesheets/shared.scss @@ -0,0 +1,96 @@ +// Размеры шрифтов +$huge_size: 1.5rem; // 24px +$larger_size: 1.375rem; // 22px +$large_size: 1.25rem; // 20px +$increased_size: 1.125rem; // 18px +$normal_size: 1rem; // 16px +$decreased_size: 0.875rem; // 14px +$small_size: 0.75rem; // 12px +$smaller_size: 0.625rem; // 10px +$tiny_size: 0.5rem; // 8px + +// Зебра для списков +$row_background_even: #f0f0f0; +$row_background_odd: #fafafa; + +$secondary_text_color: #777777; + +@mixin entity-table { + margin: 1rem; + border-spacing: 0; + + tbody { + tr:nth-of-type(even) { + background: $row_background_even; + } + + tr:nth-of-type(odd) { + background: $row_background_odd; + } + + th { + text-align: right; + padding: 0.25rem 0.5rem; + } + + td { + padding: 0.25rem 0.5rem; + + &[colspan]:first-letter { + text-transform: capitalize; + } + } + } +} + +@mixin entity-form-table { + th { + font-weight: normal; + text-align: right; + vertical-align: top; + line-height: 1.75rem; + + &[colspan] { + text-align: center; + font-weight: bold; + border-top: solid #777777 0.0625rem; + padding-top: 1rem; + } + } + + tfoot { + tr { + td { + padding: 0.5rem 0; + text-align: center; + } + } + } + + p.notice { + margin: 0; + color: $secondary_text_color; + font-size: $decreased_size; + + &:before { + content: '\261E'; + margin-right: 0.25rem; + } + } +} + +@mixin striped-list { + margin: 1rem 0; + padding: 0; + + > li { + list-style: none; + margin: 0; + padding: 0.5rem; + background: $row_background_odd; + + &:nth-of-type(even) { + background: $row_background_even; + } + } +} diff --git a/app/assets/stylesheets/toggleable.scss b/app/assets/stylesheets/toggleable.scss new file mode 100644 index 00000000..377bd54b --- /dev/null +++ b/app/assets/stylesheets/toggleable.scss @@ -0,0 +1,74 @@ +$toggleable_active: #c0ffc0; +$toggleable_inactive: #ffc0c0; +$toggleable_switch: #ffffc0; +$toggleable_unknown: #c0c0c0; +$toggleable_background: #ffffff; + +.toggleable { + margin: 0.5rem; + font-size: $small_size; + + > span { + display: inline-block; + line-height: 1.5rem; + padding: 0 0.5rem 0 0; + margin: 0.25rem; + cursor: pointer; + border: solid 0.0625rem; + border-radius: 0.5rem; + background-color: $toggleable_background; + + &:before { + line-height: 1.5rem; + display: inline-block; + width: 1.375rem; + text-align: center; + margin: 0 0.25rem 0 0; + border-radius: 0.375rem 0 0 0.375rem; + } + } + + .active { + border-color: $toggleable_active; + + &:before { + content: '\2611'; + background-color: $toggleable_active; + } + } + + .inactive { + border-color: $toggleable_inactive; + + &:before { + content: '\2610'; + background-color: $toggleable_inactive; + } + } + + .switch { + border-color: $toggleable_switch; + cursor: not-allowed; + + &:before { + content: '\231B'; + background-color: $toggleable_switch; + } + } + + .unknown { + border-color: $toggleable_unknown; + + &:before { + content: '\26A0'; + background-color: $toggleable_unknown; + } + } +} + +button.destroy { + font-size: $small_size; + line-height: 1rem; + background: #fff7f7; + border: solid #800000 0.0625rem; +} diff --git a/app/channels/application_cable/channel.rb b/app/channels/application_cable/channel.rb new file mode 100644 index 00000000..d6726972 --- /dev/null +++ b/app/channels/application_cable/channel.rb @@ -0,0 +1,4 @@ +module ApplicationCable + class Channel < ActionCable::Channel::Base + end +end diff --git a/app/channels/application_cable/connection.rb b/app/channels/application_cable/connection.rb new file mode 100644 index 00000000..0ff5442f --- /dev/null +++ b/app/channels/application_cable/connection.rb @@ -0,0 +1,4 @@ +module ApplicationCable + class Connection < ActionCable::Connection::Base + end +end diff --git a/app/controllers/admin/agents_controller.rb b/app/controllers/admin/agents_controller.rb deleted file mode 100644 index 9e8b7e91..00000000 --- a/app/controllers/admin/agents_controller.rb +++ /dev/null @@ -1,2 +0,0 @@ -class Admin::AgentsController < ApplicationController -end diff --git a/app/controllers/admin/browsers_controller.rb b/app/controllers/admin/browsers_controller.rb deleted file mode 100644 index 5f613e1c..00000000 --- a/app/controllers/admin/browsers_controller.rb +++ /dev/null @@ -1,2 +0,0 @@ -class Admin::BrowsersController < ApplicationController -end diff --git a/app/controllers/agents_controller.rb b/app/controllers/agents_controller.rb deleted file mode 100644 index e5e6c928..00000000 --- a/app/controllers/agents_controller.rb +++ /dev/null @@ -1,2 +0,0 @@ -class AgentsController < ApplicationController -end diff --git a/app/controllers/api/agents_controller.rb b/app/controllers/api/agents_controller.rb deleted file mode 100644 index 1a3f5f6f..00000000 --- a/app/controllers/api/agents_controller.rb +++ /dev/null @@ -1,2 +0,0 @@ -class Api::AgentsController < ApplicationController -end diff --git a/app/controllers/api/browsers_controller.rb b/app/controllers/api/browsers_controller.rb deleted file mode 100644 index 0a4d15a9..00000000 --- a/app/controllers/api/browsers_controller.rb +++ /dev/null @@ -1,2 +0,0 @@ -class Api::BrowsersController < ApplicationController -end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 8be965c0..a11a3725 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,12 +1,4 @@ class ApplicationController < ActionController::Base - class UnauthorizedException < Exception - end - - class ForbiddenException < Exception - end - - # Prevent CSRF attacks by raising an exception. - # For APIs, you may want to use :null_session instead. protect_from_forgery with: :exception helper_method :current_page, :param_from_request diff --git a/app/controllers/browsers_controller.rb b/app/controllers/browsers_controller.rb deleted file mode 100644 index 4e65cc2f..00000000 --- a/app/controllers/browsers_controller.rb +++ /dev/null @@ -1,2 +0,0 @@ -class BrowsersController < ApplicationController -end diff --git a/app/jobs/application_job.rb b/app/jobs/application_job.rb new file mode 100644 index 00000000..a009ace5 --- /dev/null +++ b/app/jobs/application_job.rb @@ -0,0 +1,2 @@ +class ApplicationJob < ActiveJob::Base +end diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb new file mode 100644 index 00000000..286b2239 --- /dev/null +++ b/app/mailers/application_mailer.rb @@ -0,0 +1,4 @@ +class ApplicationMailer < ActionMailer::Base + default from: 'from@example.com' + layout 'mailer' +end diff --git a/app/models/agent.rb b/app/models/agent.rb deleted file mode 100644 index 7bcde71e..00000000 --- a/app/models/agent.rb +++ /dev/null @@ -1,36 +0,0 @@ -class Agent < ActiveRecord::Base - include RequiredUniqueName - - PER_PAGE = 20 - TOGGLEABLE = %i(mobile bot active) - - belongs_to :browser, counter_cache: true - - # @param [Integer] page - def self.page_for_administration(page) - ordered_by_name.page(page).per(PER_PAGE) - end - - def self.entity_parameters - %i(browser_id name mobile bot active) - end - - # Get instance of Agent for given string - # - # Trims agent name upto 255 characters - # - # @param [String] name - # @return [Agent] - def self.named(name) - criterion = { name: name[0..254] } - self.find_by(criterion) || self.create(criterion) - end - - # @param [String] attribute - def toggle_parameter(attribute) - if TOGGLEABLE.include? attribute - toggle! attribute - { attribute => self[attribute] } - end - end -end diff --git a/app/models/application_record.rb b/app/models/application_record.rb new file mode 100644 index 00000000..10a4cba8 --- /dev/null +++ b/app/models/application_record.rb @@ -0,0 +1,3 @@ +class ApplicationRecord < ActiveRecord::Base + self.abstract_class = true +end diff --git a/app/models/browser.rb b/app/models/browser.rb deleted file mode 100644 index 647e1acc..00000000 --- a/app/models/browser.rb +++ /dev/null @@ -1,25 +0,0 @@ -class Browser < ActiveRecord::Base - include RequiredUniqueName - - PER_PAGE = 20 - TOGGLEABLE = %i(mobile bot active) - - has_many :agents, dependent: :nullify - - # @param [Integer] page - def self.page_for_administration(page) - ordered_by_name.page(page).per(PER_PAGE) - end - - def self.entity_parameters - %i(name mobile bot active) - end - - # @param [String] attribute - def toggle_parameter(attribute) - if TOGGLEABLE.include? attribute - toggle! attribute - { attribute => self[attribute] } - end - end -end diff --git a/app/models/concerns/required_unique_name.rb b/app/models/concerns/required_unique_name.rb deleted file mode 100644 index ce22aabe..00000000 --- a/app/models/concerns/required_unique_name.rb +++ /dev/null @@ -1,11 +0,0 @@ -module RequiredUniqueName - extend ActiveSupport::Concern - - included do - validates_presence_of :name - validates_uniqueness_of :name - - scope :ordered_by_name, -> { order 'name asc' } - scope :with_name_like, -> (name) { where 'name ilike ?', "%#{name}%" } - end -end diff --git a/app/views/index/index.html.erb b/app/views/index/index.html.erb index e69de29b..e8fd8410 100644 --- a/app/views/index/index.html.erb +++ b/app/views/index/index.html.erb @@ -0,0 +1 @@ +<% content_for :meta_title, t('.title') %> diff --git a/app/views/layouts/_footer.html.erb b/app/views/layouts/_footer.html.erb index 85db16cc..fc739826 100644 --- a/app/views/layouts/_footer.html.erb +++ b/app/views/layouts/_footer.html.erb @@ -1,3 +1,3 @@ diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb index a3970f7a..dcf23e53 100644 --- a/app/views/layouts/_header.html.erb +++ b/app/views/layouts/_header.html.erb @@ -1,4 +1,4 @@
-
<%= link_to 'example.com', root_path %>
+
<%= link_to 'sovia.ru', root_path %>
<%= render 'layouts/main_navigation' %>
diff --git a/app/views/layouts/_meta_texts.html.erb b/app/views/layouts/_meta_texts.html.erb index 0cb44b92..8d5fa28d 100644 --- a/app/views/layouts/_meta_texts.html.erb +++ b/app/views/layouts/_meta_texts.html.erb @@ -10,8 +10,8 @@ <% end %> - + - - -<%# yield :meta_twitter if content_for? :meta_twitter %> + + +<%= yield :meta_twitter if content_for? :meta_twitter %> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 6852f6d5..66e1878b 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -7,6 +7,7 @@ <%= javascript_include_tag 'application' %> <%= csrf_meta_tags %> + <%= render 'layouts/meta_texts' %> <%= render 'layouts/header' %> diff --git a/app/views/layouts/mailer.html.erb b/app/views/layouts/mailer.html.erb new file mode 100644 index 00000000..17b86c1a --- /dev/null +++ b/app/views/layouts/mailer.html.erb @@ -0,0 +1,13 @@ + + + + + + + + + <%= yield %> + + diff --git a/app/views/layouts/mailer.text.erb b/app/views/layouts/mailer.text.erb new file mode 100644 index 00000000..37f0bddb --- /dev/null +++ b/app/views/layouts/mailer.text.erb @@ -0,0 +1 @@ +<%= yield %> diff --git a/bin/puma b/bin/puma deleted file mode 100755 index 13d14022..00000000 --- a/bin/puma +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env ruby -# frozen_string_literal: true -# -# This file was generated by Bundler. -# -# The application 'puma' is installed as part of a gem, and -# this file is here to facilitate running it. -# - -require "pathname" -ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", - Pathname.new(__FILE__).realpath) - -require "rubygems" -require "bundler/setup" - -load Gem.bin_path("puma", "puma") diff --git a/bin/pumactl b/bin/pumactl deleted file mode 100755 index 41681ff7..00000000 --- a/bin/pumactl +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env ruby -# frozen_string_literal: true -# -# This file was generated by Bundler. -# -# The application 'pumactl' is installed as part of a gem, and -# this file is here to facilitate running it. -# - -require "pathname" -ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", - Pathname.new(__FILE__).realpath) - -require "rubygems" -require "bundler/setup" - -load Gem.bin_path("puma", "pumactl") diff --git a/bin/rails b/bin/rails index 0138d79b..5badb2fd 100755 --- a/bin/rails +++ b/bin/rails @@ -4,6 +4,6 @@ begin rescue LoadError => e raise unless e.message.include?('spring') end -APP_PATH = File.expand_path('../../config/application', __FILE__) +APP_PATH = File.expand_path('../config/application', __dir__) require_relative '../config/boot' require 'rails/commands' diff --git a/bin/setup b/bin/setup index acdb2c13..e620b4da 100755 --- a/bin/setup +++ b/bin/setup @@ -1,29 +1,34 @@ #!/usr/bin/env ruby require 'pathname' +require 'fileutils' +include FileUtils # path to your application root. -APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) +APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) -Dir.chdir APP_ROOT do +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do # This script is a starting point to setup your application. - # Add necessary setup steps to this file: + # Add necessary setup steps to this file. - puts "== Installing dependencies ==" - system "gem install bundler --conservative" - system "bundle check || bundle install" + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') # puts "\n== Copying sample files ==" - # unless File.exist?("config/database.yml") - # system "cp config/database.yml.sample config/database.yml" + # unless File.exist?('config/database.yml') + # cp 'config/database.yml.sample', 'config/database.yml' # end puts "\n== Preparing database ==" - system "bin/rake db:setup" + system! 'bin/rails db:setup' puts "\n== Removing old logs and tempfiles ==" - system "rm -f log/*" - system "rm -rf tmp/cache" + system! 'bin/rails log:clear tmp:clear' puts "\n== Restarting application server ==" - system "touch tmp/restart.txt" + system! 'bin/rails restart' end diff --git a/bin/update b/bin/update new file mode 100755 index 00000000..a8e4462f --- /dev/null +++ b/bin/update @@ -0,0 +1,29 @@ +#!/usr/bin/env ruby +require 'pathname' +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a way to update your development environment automatically. + # Add necessary update steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + puts "\n== Updating database ==" + system! 'bin/rails db:migrate' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/config.ru b/config.ru index bd83b254..f7ba0b52 100644 --- a/config.ru +++ b/config.ru @@ -1,4 +1,5 @@ # This file is used by Rack-based servers to start the application. -require ::File.expand_path('../config/environment', __FILE__) +require_relative 'config/environment' + run Rails.application diff --git a/config/application.rb b/config/application.rb index 99687538..65b9f465 100644 --- a/config/application.rb +++ b/config/application.rb @@ -1,4 +1,4 @@ -require File.expand_path('../boot', __FILE__) +require_relative 'boot' require "rails" # Pick the frameworks you want: @@ -8,6 +8,7 @@ require "action_controller/railtie" require "action_mailer/railtie" require "action_view/railtie" +require "action_cable/engine" require "sprockets/railtie" # require "rails/test_unit/railtie" @@ -26,15 +27,5 @@ class Application < Rails::Application %w(app/services lib).each do |path| config.autoload_paths << config.root.join(path).to_s end - - config.action_dispatch.rescue_responses.merge!( - { - :'ApplicationController::UnauthorizedException' => :unauthorized, - :'ApplicationController::ForbiddenException' => :forbidden, - } - ) - - # Do not swallow errors in after_commit/after_rollback callbacks. - config.active_record.raise_in_transactional_callbacks = true end end diff --git a/config/boot.rb b/config/boot.rb index 6b750f00..30f5120d 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,3 +1,3 @@ -ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) require 'bundler/setup' # Set up gems listed in the Gemfile. diff --git a/config/cable.yml b/config/cable.yml new file mode 100644 index 00000000..0bbde6f7 --- /dev/null +++ b/config/cable.yml @@ -0,0 +1,9 @@ +development: + adapter: async + +test: + adapter: async + +production: + adapter: redis + url: redis://localhost:6379/1 diff --git a/config/environment.rb b/config/environment.rb index ee8d90dc..426333bb 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -1,5 +1,5 @@ # Load the Rails application. -require File.expand_path('../application', __FILE__) +require_relative 'application' # Initialize the Rails application. Rails.application.initialize! diff --git a/config/environments/development.rb b/config/environments/development.rb index af3f168b..f1b63b2b 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -9,9 +9,22 @@ # Do not eager load code on boot. config.eager_load = false - # Show full error reports and disable caching. - config.consider_all_requests_local = true - config.action_controller.perform_caching = false + # Show full error reports. + config.consider_all_requests_local = true + + # Enable/disable caching. By default caching is disabled. + if Rails.root.join('tmp/caching-dev.txt').exist? + config.action_controller.perform_caching = true + + config.cache_store = :memory_store + config.public_file_server.headers = { + 'Cache-Control' => 'public, max-age=172800' + } + else + config.action_controller.perform_caching = false + + config.cache_store = :null_store + end # Don't care if the mailer can't send. config.action_mailer.raise_delivery_errors = false @@ -22,6 +35,8 @@ } config.action_mailer.default_url_options = { :host => 'sovia.local:3000' } + config.action_mailer.perform_caching = false + # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log @@ -33,15 +48,13 @@ # number of complex assets. config.assets.debug = true - # Asset digests allow you to set far-future HTTP expiration dates on all assets, - # yet still be able to expire them through the digest params. - config.assets.digest = true - - # Adds additional error checking when serving assets at runtime. - # Checks for improperly declared sprockets dependencies. - # Raises helpful error messages. - config.assets.raise_runtime_errors = true + # Suppress logger output for asset requests. + config.assets.quiet = true # Raises error for missing translations # config.action_view.raise_on_missing_translations = true + + # Use an evented file watcher to asynchronously detect changes in source code, + # routes, locales, etc. This feature depends on the listen gem. + config.file_watcher = ActiveSupport::EventedFileUpdateChecker end diff --git a/config/environments/production.rb b/config/environments/production.rb index ed380b63..72ed0194 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -14,15 +14,9 @@ config.consider_all_requests_local = false config.action_controller.perform_caching = true - # Enable Rack::Cache to put a simple HTTP cache in front of your application - # Add `rack-cache` to your Gemfile before enabling this. - # For large-scale production use, consider using a caching reverse proxy like - # NGINX, varnish or squid. - # config.action_dispatch.rack_cache = true - # Disable serving static files from the `/public` folder by default since # Apache or NGINX already handles this. - config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present? + config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? # Compress JavaScripts and CSS. config.assets.js_compressor = :uglifier @@ -31,34 +25,37 @@ # Do not fallback to assets pipeline if a precompiled asset is missed. config.assets.compile = false - # Asset digests allow you to set far-future HTTP expiration dates on all assets, - # yet still be able to expire them through the digest params. - config.assets.digest = true - # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.action_controller.asset_host = 'http://assets.sovia.ru' + # Specifies the header that your server uses for sending files. # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX + # Mount Action Cable outside main process or domain + # config.action_cable.mount_path = nil + # config.action_cable.url = 'wss://sovia.ru/cable' + # config.action_cable.allowed_request_origins = [ 'https://sovia.ru', /http:\/\/example.*/ ] + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. # config.force_ssl = true # Use the lowest log level to ensure availability of diagnostic information # when problems arise. - config.log_level = :info + config.log_level = :debug # Prepend all log lines with the following tags. - # config.log_tags = [ :subdomain, :uuid ] - - # Use a different logger for distributed setups. - # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) + config.log_tags = [ :request_id ] # Use a different cache store in production. # config.cache_store = :mem_cache_store - # Enable serving of images, stylesheets, and JavaScripts from an asset server. - # config.action_controller.asset_host = 'http://assets.example.com' + # Use a real queuing backend for Active Job (and separate queues per environment) + # config.active_job.queue_adapter = :resque + # config.active_job.queue_name_prefix = "sovia5_#{Rails.env}" + config.action_mailer.perform_caching = false # Ignore bad email addresses and do not raise email delivery errors. # Set this to true and configure the email server for immediate delivery to raise delivery errors. @@ -89,6 +86,16 @@ # Use default logging formatter so that PID and timestamp are not suppressed. config.log_formatter = ::Logger::Formatter.new + # Use a different logger for distributed setups. + # require 'syslog/logger' + # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') + + if ENV["RAILS_LOG_TO_STDOUT"].present? + logger = ActiveSupport::Logger.new(STDOUT) + logger.formatter = config.log_formatter + config.logger = ActiveSupport::TaggedLogging.new(logger) + end + # Do not dump schema after migrations. config.active_record.dump_schema_after_migration = false end diff --git a/config/environments/test.rb b/config/environments/test.rb index 1c19f08b..a7b308d4 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -12,9 +12,11 @@ # preloads Rails for running tests, you may have to set it to true. config.eager_load = false - # Configure static file server for tests with Cache-Control for performance. - config.serve_static_files = true - config.static_cache_control = 'public, max-age=3600' + # Configure public file server for tests with Cache-Control for performance. + config.public_file_server.enabled = true + config.public_file_server.headers = { + 'Cache-Control' => 'public, max-age=3600' + } # Show full error reports and disable caching. config.consider_all_requests_local = true @@ -25,14 +27,17 @@ # Disable request forgery protection in test environment. config.action_controller.allow_forgery_protection = false + config.action_mailer.perform_caching = false # Tell Action Mailer not to deliver emails to the real world. # The :test delivery method accumulates sent emails in the # ActionMailer::Base.deliveries array. config.action_mailer.delivery_method = :test - - # Randomize the order test cases are executed. - config.active_support.test_order = :random + config.action_mailer.default_options = { + from: 'sovia.ru ', + reply_to: 'support@sovia.ru' + } + config.action_mailer.default_url_options = { :host => 'sovia.local:3000' } # Print deprecation notices to the stderr. config.active_support.deprecation = :stderr diff --git a/config/initializers/application_controller_renderer.rb b/config/initializers/application_controller_renderer.rb new file mode 100644 index 00000000..51639b67 --- /dev/null +++ b/config/initializers/application_controller_renderer.rb @@ -0,0 +1,6 @@ +# Be sure to restart your server when you modify this file. + +# ApplicationController.renderer.defaults.merge!( +# http_host: 'example.org', +# https: false +# ) diff --git a/config/initializers/cookies_serializer.rb b/config/initializers/cookies_serializer.rb index 7f70458d..5a6a32d3 100644 --- a/config/initializers/cookies_serializer.rb +++ b/config/initializers/cookies_serializer.rb @@ -1,3 +1,5 @@ # Be sure to restart your server when you modify this file. +# Specify a serializer for the signed and encrypted cookie jars. +# Valid options are :json, :marshal, and :hybrid. Rails.application.config.action_dispatch.cookies_serializer = :json diff --git a/config/initializers/new_framework_defaults.rb b/config/initializers/new_framework_defaults.rb new file mode 100644 index 00000000..0706cafd --- /dev/null +++ b/config/initializers/new_framework_defaults.rb @@ -0,0 +1,24 @@ +# Be sure to restart your server when you modify this file. +# +# This file contains migration options to ease your Rails 5.0 upgrade. +# +# Read the Rails 5.0 release notes for more info on each option. + +# Enable per-form CSRF tokens. Previous versions had false. +Rails.application.config.action_controller.per_form_csrf_tokens = true + +# Enable origin-checking CSRF mitigation. Previous versions had false. +Rails.application.config.action_controller.forgery_protection_origin_check = true + +# Make Ruby 2.4 preserve the timezone of the receiver when calling `to_time`. +# Previous versions had false. +ActiveSupport.to_time_preserves_timezone = true + +# Require `belongs_to` associations by default. Previous versions had false. +Rails.application.config.active_record.belongs_to_required_by_default = true + +# Do not halt callback chains when a callback returns false. Previous versions had true. +ActiveSupport.halt_callback_chains_on_return_false = false + +# Configure SSL options to enable HSTS with subdomains. Previous versions had false. +Rails.application.config.ssl_options = { hsts: { subdomains: true } } diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb index 33725e95..bbfc3961 100644 --- a/config/initializers/wrap_parameters.rb +++ b/config/initializers/wrap_parameters.rb @@ -5,10 +5,10 @@ # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. ActiveSupport.on_load(:action_controller) do - wrap_parameters format: [:json] if respond_to?(:wrap_parameters) + wrap_parameters format: [:json] end # To enable root element in JSON for ActiveRecord objects. # ActiveSupport.on_load(:active_record) do -# self.include_root_in_json = true +# self.include_root_in_json = true # end diff --git a/config/locales/ru.yml b/config/locales/ru.yml index 84ac37be..e76a0f64 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -39,3 +39,6 @@ ru: index: index: title: "Администрирование" + index: + index: + title: "Сайт о снах" diff --git a/config/locales/tracking/ru.yml b/config/locales/tracking/ru.yml deleted file mode 100644 index efc12011..00000000 --- a/config/locales/tracking/ru.yml +++ /dev/null @@ -1,59 +0,0 @@ -ru: - agent: - zero: "нет агентов пользователя" - one: "%{count} агент пользователя" - few: "%{count} агента пользователя" - many: "%{count} агентов пользователя" - other: "%{count} агентов пользователя" - activerecord: - attributes: - browser: - mobile: "Мобильный" - bot: "Бот" - active: "Активный" - locked: "Запрет изменений" - deleted: "Удалён" - name: "Название" - agent: - browser_id: "Браузер" - mobile: "Мобильный" - bot: "Бот" - active: "Активный" - locked: "Запрет изменений" - deleted: "Удалён" - name: "Название" - admin: - browsers: - index: - index: "Браузеры, страница %{page}" - heading: "Браузеры" - agents: - index: - index: "Агенты пользователя, страница %{page}" - heading: "Агенты пользователя" - browsers: - new: - title: "Создание браузера" - create: - success: "Браузер успешно создан" - show: - index: "Браузер «%{name}»" - edit: - title: "Редактирование браузера" - update: - success: "Браузер успешно изменён" - destroy: - success: "Браузер успешно удалён" - agents: - new: - title: "Создание агента пользователя" - create: - success: "Агент пользователя успешно создан" - show: - index: "Агент пользователя «%{name}»" - edit: - title: "Редактирование агента пользователя" - update: - success: "Агент пользователя успешно изменён" - destroy: - success: "Агент пользователя успешно удалён" diff --git a/config/routes.rb b/config/routes.rb index 35bd4602..b6b09851 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,36 +1,3 @@ Rails.application.routes.draw do - # Toggleable members - concern :toggleable do - post 'toggle', on: :member - end - - # Lockable members - concern :lockable do - member do - put 'lock', as: :lock - delete 'lock', as: :unlock - end - end - root 'index#index' - - # Administrative routes - namespace :admin do - # Tracking - resources :browsers, :agents, only: :index - end - - # API routes - namespace :api, defaults: { format: :json } do - # Tracking - resources :browsers, :agents, concerns: [:toggleable, :lockable] - end - - # Tracking - resources :browsers, except: [:index] do - member do - get 'agents' - end - end - resources :agents, except: [:index] end diff --git a/config/spring.rb b/config/spring.rb new file mode 100644 index 00000000..c9119b40 --- /dev/null +++ b/config/spring.rb @@ -0,0 +1,6 @@ +%w( + .ruby-version + .rbenv-vars + tmp/restart.txt + tmp/caching-dev.txt +).each { |path| Spring.watch(path) } diff --git a/db/migrate/20160627202551_create_browsers.rb b/db/migrate/20160627202551_create_browsers.rb deleted file mode 100644 index 40c0cbea..00000000 --- a/db/migrate/20160627202551_create_browsers.rb +++ /dev/null @@ -1,14 +0,0 @@ -class CreateBrowsers < ActiveRecord::Migration - def change - create_table :browsers do |t| - t.timestamps null: false - t.integer :agents_count, null: false, default: 0 - t.boolean :bot, null: false, default: false - t.boolean :mobile, null: false, default: false - t.boolean :active, null: false, default: true - t.boolean :locked, null: false, default: false - t.boolean :deleted, null: false, default: false - t.string :name, null: false, index: true - end - end -end diff --git a/db/migrate/20160627204318_create_agents.rb b/db/migrate/20160627204318_create_agents.rb deleted file mode 100644 index 9f5c15e3..00000000 --- a/db/migrate/20160627204318_create_agents.rb +++ /dev/null @@ -1,14 +0,0 @@ -class CreateAgents < ActiveRecord::Migration - def change - create_table :agents do |t| - t.timestamps null: false - t.references :browser, index: true, foreign_key: true - t.boolean :bot, null: false, default: false - t.boolean :mobile, null: false, default: false - t.boolean :active, null: false, default: true - t.boolean :locked, null: false, default: false - t.boolean :deleted, null: false, default: false - t.string :name, null: false, index: true - end - end -end diff --git a/db/schema.rb b/db/schema.rb deleted file mode 100644 index 6d2492f3..00000000 --- a/db/schema.rb +++ /dev/null @@ -1,49 +0,0 @@ -# encoding: UTF-8 -# This file is auto-generated from the current state of the database. Instead -# of editing this file, please use the migrations feature of Active Record to -# incrementally modify your database, and then regenerate this schema definition. -# -# Note that this schema.rb definition is the authoritative source for your -# database schema. If you need to create the application database on another -# system, you should be using db:schema:load, not running all the migrations -# from scratch. The latter is a flawed and unsustainable approach (the more migrations -# you'll amass, the slower it'll run and the greater likelihood for issues). -# -# It's strongly recommended that you check this file into your version control system. - -ActiveRecord::Schema.define(version: 20160627204318) do - - # These are extensions that must be enabled in order to support this database - enable_extension "plpgsql" - - create_table "agents", force: :cascade do |t| - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.integer "browser_id" - t.boolean "bot", default: false, null: false - t.boolean "mobile", default: false, null: false - t.boolean "active", default: true, null: false - t.boolean "locked", default: false, null: false - t.boolean "deleted", default: false, null: false - t.string "name", null: false - end - - add_index "agents", ["browser_id"], name: "index_agents_on_browser_id", using: :btree - add_index "agents", ["name"], name: "index_agents_on_name", using: :btree - - create_table "browsers", force: :cascade do |t| - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.integer "agents_count", default: 0, null: false - t.boolean "bot", default: false, null: false - t.boolean "mobile", default: false, null: false - t.boolean "active", default: true, null: false - t.boolean "locked", default: false, null: false - t.boolean "deleted", default: false, null: false - t.string "name", null: false - end - - add_index "browsers", ["name"], name: "index_browsers_on_name", using: :btree - - add_foreign_key "agents", "browsers" -end diff --git a/db/seeds.rb b/db/seeds.rb index 4edb1e85..1beea2ac 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1,7 +1,7 @@ # This file should contain all the record creation needed to seed the database with its default values. -# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). +# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup). # # Examples: # -# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) -# Mayor.create(name: 'Emanuel', city: cities.first) +# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) +# Character.create(name: 'Luke', movie: movies.first) diff --git a/lib/tasks/agents.rake b/lib/tasks/agents.rake deleted file mode 100644 index 7a5a0ba5..00000000 --- a/lib/tasks/agents.rake +++ /dev/null @@ -1,37 +0,0 @@ -namespace :agents do - desc 'Import agents from YAML with deleting old data' - task import: :environment do - file_path = "#{Rails.root}/tmp/import/agents.yml" - if File.exists? file_path - puts 'Deleting old agents...' - Agent.destroy_all - puts 'Done. Importing...' - File.open file_path, 'r' do |file| - YAML.load(file).each do |id, data| - agent = Agent.new id: id - agent.assign_attributes data - agent.save! - print "\r#{id}" - end - puts - end - Agent.connection.execute "select setval('agents_id_seq', (select max(id) from agents));" - puts "Done. We have #{Agent.count} agents now" - else - puts "Cannot find file #{file_path}" - end - end - - desc 'Export agents to YAML' - task export: :environment do - file_path = "#{Rails.root}/tmp/export/agents.yml" - File.open file_path, 'w' do |file| - Agent.order('id asc').each do |agent| - file.puts "#{agent.id}:" - agent.attributes.except(:id).each do |attribute, value| - file.puts " #{attribute}: #{value.inspect}" - end - end - end - end -end diff --git a/lib/tasks/browsers.rake b/lib/tasks/browsers.rake deleted file mode 100644 index a03ae888..00000000 --- a/lib/tasks/browsers.rake +++ /dev/null @@ -1,37 +0,0 @@ -namespace :browsers do - desc 'Import browsers from YAML with deleting old data' - task import: :environment do - file_path = "#{Rails.root}/tmp/import/browsers.yml" - if File.exists? file_path - puts 'Deleting old browsers...' - Browser.destroy_all - puts 'Done. Importing...' - File.open file_path, 'r' do |file| - YAML.load(file).each do |id, data| - browser = Browser.new id: id - browser.assign_attributes data - browser.save! - print "\r#{id}" - end - puts - end - Browser.connection.execute "select setval('browsers_id_seq', (select max(id) from browsers));" - puts "Done. We have #{Browser.count} browsers now" - else - puts "Cannot find file #{file_path}" - end - end - - desc 'Export browsers to YAML' - task export: :environment do - file_path = "#{Rails.root}/tmp/export/browsers.yml" - File.open file_path, 'w' do |file| - Browser.order('id asc').each do |browser| - file.puts "#{browser.id}:" - browser.attributes.except(:id).each do |attribute, value| - file.puts " #{attribute}: #{value.inspect}" - end - end - end - end -end diff --git a/app/assets/stylesheets/tracking.scss b/public/apple-touch-icon-precomposed.png similarity index 100% rename from app/assets/stylesheets/tracking.scss rename to public/apple-touch-icon-precomposed.png diff --git a/app/models/.keep b/public/apple-touch-icon.png similarity index 100% rename from app/models/.keep rename to public/apple-touch-icon.png diff --git a/public/robots.txt b/public/robots.txt index 03150c68..3c9c7c01 100644 --- a/public/robots.txt +++ b/public/robots.txt @@ -1,4 +1,5 @@ -User-agent: * -Disallow: /admin -Disallow: /api -Disallow: /my +# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file +# +# To ban all spiders from the entire site uncomment the next two lines: +# User-agent: * +# Disallow: / diff --git a/spec/controllers/admin/agents_controller_spec.rb b/spec/controllers/admin/agents_controller_spec.rb deleted file mode 100644 index bf4d1fad..00000000 --- a/spec/controllers/admin/agents_controller_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'rails_helper' - -RSpec.describe Admin::AgentsController, type: :controller do - -end diff --git a/spec/controllers/admin/browsers_controller_spec.rb b/spec/controllers/admin/browsers_controller_spec.rb deleted file mode 100644 index 0bca040d..00000000 --- a/spec/controllers/admin/browsers_controller_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'rails_helper' - -RSpec.describe Admin::BrowsersController, type: :controller do - -end diff --git a/spec/controllers/agents_controller_spec.rb b/spec/controllers/agents_controller_spec.rb deleted file mode 100644 index c527d0b7..00000000 --- a/spec/controllers/agents_controller_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'rails_helper' - -RSpec.describe AgentsController, type: :controller do - -end diff --git a/spec/controllers/api/agents_controller_spec.rb b/spec/controllers/api/agents_controller_spec.rb deleted file mode 100644 index 333cb901..00000000 --- a/spec/controllers/api/agents_controller_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'rails_helper' - -RSpec.describe Api::AgentsController, type: :controller do - -end diff --git a/spec/controllers/api/browsers_controller_spec.rb b/spec/controllers/api/browsers_controller_spec.rb deleted file mode 100644 index e13dedfe..00000000 --- a/spec/controllers/api/browsers_controller_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'rails_helper' - -RSpec.describe Api::BrowsersController, type: :controller do - -end diff --git a/spec/controllers/browsers_controller_spec.rb b/spec/controllers/browsers_controller_spec.rb deleted file mode 100644 index 89c81dd3..00000000 --- a/spec/controllers/browsers_controller_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'rails_helper' - -RSpec.describe BrowsersController, type: :controller do - -end diff --git a/spec/factories/agents.rb b/spec/factories/agents.rb deleted file mode 100644 index d5283ed6..00000000 --- a/spec/factories/agents.rb +++ /dev/null @@ -1,5 +0,0 @@ -FactoryGirl.define do - factory :agent do - sequence(:name) { |n| "Agent #{n}" } - end -end diff --git a/spec/factories/browsers.rb b/spec/factories/browsers.rb deleted file mode 100644 index a8aad014..00000000 --- a/spec/factories/browsers.rb +++ /dev/null @@ -1,5 +0,0 @@ -FactoryGirl.define do - factory :browser do - sequence(:name) { |n| "Browser #{n}" } - end -end diff --git a/spec/models/agent_spec.rb b/spec/models/agent_spec.rb deleted file mode 100644 index d3a919a2..00000000 --- a/spec/models/agent_spec.rb +++ /dev/null @@ -1,37 +0,0 @@ -require 'rails_helper' - -RSpec.describe Agent, type: :model do - subject { build :agent } - - it_behaves_like 'has_valid_factory' - it_behaves_like 'has_unique_name' - it_behaves_like 'required_name' - - describe '::named' do - let(:action) { -> { Agent.named(subject.name) } } - - context 'when Agent exists' do - before :each do - subject.save! - end - - it 'returns instance of Agent' do - expect(action.call).to eq(subject) - end - - it 'does not change database' do - expect(action).not_to change(Agent, :count) - end - end - - context 'when Agent does not exist' do - it 'returns instance of Agent' do - expect(action.call).to be_an_instance_of(Agent) - end - - it 'adds new Agent to database' do - expect(action).to change(Agent, :count).by(1) - end - end - end -end diff --git a/spec/models/browser_spec.rb b/spec/models/browser_spec.rb deleted file mode 100644 index 19f22f2c..00000000 --- a/spec/models/browser_spec.rb +++ /dev/null @@ -1,9 +0,0 @@ -require 'rails_helper' - -RSpec.describe Browser, type: :model do - subject { build :browser } - - it_behaves_like 'has_valid_factory' - it_behaves_like 'has_unique_name' - it_behaves_like 'required_name' -end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 2569fbe5..1dc273fc 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -13,18 +13,30 @@ mocks.verify_partial_doubles = true end - # These two settings work together to allow you to limit a spec run - # to individual examples or groups you care about by tagging them with - # `:focus` metadata. When nothing is tagged with `:focus`, all examples - # get run. - config.filter_run :focus - config.run_all_when_everything_filtered = true + # This option will default to `:apply_to_host_groups` in RSpec 4 (and will + # have no way to turn it off -- the option exists only for backwards + # compatibility in RSpec 3). It causes shared context metadata to be + # inherited by the metadata hash of host groups and examples, rather than + # triggering implicit auto-inclusion in groups with matching metadata. + config.shared_context_metadata_behavior = :apply_to_host_groups + + # This allows you to limit a spec run to individual examples or groups + # you care about by tagging them with `:focus` metadata. When nothing + # is tagged with `:focus`, all examples get run. RSpec also provides + # aliases for `it`, `describe`, and `context` that include `:focus` + # metadata: `fit`, `fdescribe` and `fcontext`, respectively. + config.filter_run_when_matching :focus # Allows RSpec to persist some state between runs in order to support # the `--only-failures` and `--next-failure` CLI options. We recommend # you configure your source control system to ignore this file. config.example_status_persistence_file_path = "spec/examples.txt" + # Limits the available syntax to the non-monkey patched syntax that is + # recommended. For more details, see: + # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/ + # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ + # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode config.disable_monkey_patching! # Many RSpec users commonly either run the entire suite or an individual @@ -40,7 +52,7 @@ # Print the 10 slowest examples and example groups at the # end of the spec run, to help surface which specs are running # particularly slow. - # config.profile_examples = 10 + config.profile_examples = 10 # Run specs in random order to surface order dependencies. If you find an # order dependency and want to debug it, you can fix the order by providing @@ -53,4 +65,9 @@ # test failures related to randomization by passing the same `--seed` value # as the one that triggered the failure. Kernel.srand config.seed + +# The settings below are suggested to provide a good initial experience +# with RSpec, but feel free to customize to your heart's content. +=begin +=end end diff --git a/spec/support/shared_examples/excluded_foreign_entity.rb b/spec/support/shared_examples/excluded_foreign_entity.rb new file mode 100644 index 00000000..bcf86455 --- /dev/null +++ b/spec/support/shared_examples/excluded_foreign_entity.rb @@ -0,0 +1,7 @@ +require 'rails_helper' + +RSpec.shared_examples_for 'excluded_foreign_entity' do + it 'does not add foreign entity to @collection' do + expect(assigns[:collection]).not_to include(foreign_entity) + end +end diff --git a/spec/support/shared_examples/has_unique_name.rb b/spec/support/shared_examples/has_unique_name.rb deleted file mode 100644 index 02d20cf0..00000000 --- a/spec/support/shared_examples/has_unique_name.rb +++ /dev/null @@ -1,13 +0,0 @@ -require 'rails_helper' - -RSpec.shared_examples_for 'has_unique_name' do - let(:model) { described_class.to_s.underscore.to_sym } - - describe 'validation' do - it 'fails with non-unique name' do - create model, name: subject.name - expect(subject).not_to be_valid - expect(subject.errors.messages).to have_key(:name) - end - end -end diff --git a/spec/support/shared_examples/required_name.rb b/spec/support/shared_examples/required_name.rb deleted file mode 100644 index cdb9449b..00000000 --- a/spec/support/shared_examples/required_name.rb +++ /dev/null @@ -1,11 +0,0 @@ -require 'rails_helper' - -RSpec.shared_examples_for 'required_name' do - describe 'validation' do - it 'fails without name' do - subject.name = nil - expect(subject).not_to be_valid - expect(subject.errors.messages).to have_key(:name) - end - end -end diff --git a/tmp/.keep b/tmp/.keep new file mode 100644 index 00000000..e69de29b