diff --git a/Gemfile b/Gemfile index 710b52f..5dc2167 100644 --- a/Gemfile +++ b/Gemfile @@ -59,7 +59,7 @@ group :development, :test do gem 'pry-byebug' gem 'pry-rails' - gem "factory_bot_rails" + gem "factory_bot_rails", '~> 5.0' end group :development do diff --git a/Gemfile.lock b/Gemfile.lock index 9e7f69e..a8da6cc 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,55 +1,55 @@ GEM remote: https://rubygems.org/ specs: - actioncable (5.2.1) - actionpack (= 5.2.1) + actioncable (5.2.2) + actionpack (= 5.2.2) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailer (5.2.1) - actionpack (= 5.2.1) - actionview (= 5.2.1) - activejob (= 5.2.1) + actionmailer (5.2.2) + actionpack (= 5.2.2) + actionview (= 5.2.2) + activejob (= 5.2.2) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (5.2.1) - actionview (= 5.2.1) - activesupport (= 5.2.1) + actionpack (5.2.2) + actionview (= 5.2.2) + activesupport (= 5.2.2) rack (~> 2.0) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (5.2.1) - activesupport (= 5.2.1) + actionview (5.2.2) + activesupport (= 5.2.2) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.3) - activejob (5.2.1) - activesupport (= 5.2.1) + activejob (5.2.2) + activesupport (= 5.2.2) globalid (>= 0.3.6) - activemodel (5.2.1) - activesupport (= 5.2.1) - activerecord (5.2.1) - activemodel (= 5.2.1) - activesupport (= 5.2.1) + activemodel (5.2.2) + activesupport (= 5.2.2) + activerecord (5.2.2) + activemodel (= 5.2.2) + activesupport (= 5.2.2) arel (>= 9.0) - activestorage (5.2.1) - actionpack (= 5.2.1) - activerecord (= 5.2.1) + activestorage (5.2.2) + actionpack (= 5.2.2) + activerecord (= 5.2.2) marcel (~> 0.3.1) - activesupport (5.2.1) + activesupport (5.2.2) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) tzinfo (~> 1.1) - addressable (2.5.2) + addressable (2.6.0) public_suffix (>= 2.0.2, < 4.0) - airbrussh (1.3.0) + airbrussh (1.3.1) sshkit (>= 1.6.1, != 1.7.0) - annotate (2.7.3) + annotate (2.7.4) activerecord (>= 3.2, < 6.0) rake (>= 10.4, < 13.0) - archive-zip (0.11.0) + archive-zip (0.12.0) io-like (~> 0.3.0) arel (9.0.0) ast (2.4.0) @@ -58,67 +58,67 @@ GEM bindex (0.5.0) binding_of_caller (0.8.0) debug_inspector (>= 0.0.1) - bootsnap (1.3.0) + bootsnap (1.4.1) msgpack (~> 1.0) builder (3.2.3) - byebug (10.0.2) - capistrano (3.10.2) + byebug (11.0.0) + capistrano (3.11.0) airbrussh (>= 1.0.0) i18n rake (>= 10.0.0) sshkit (>= 1.9.0) - capistrano-bundler (1.3.0) + capistrano-bundler (1.5.0) capistrano (~> 3.1) - sshkit (~> 1.2) capistrano-rails (1.4.0) capistrano (~> 3.1) capistrano-bundler (~> 1.1) - capistrano-rbenv (2.1.3) + capistrano-rbenv (2.1.4) capistrano (~> 3.1) sshkit (~> 1.3) capistrano3-puma (3.1.1) capistrano (~> 3.7) capistrano-bundler puma (~> 3.4) - capybara (3.1.0) + capybara (3.14.0) addressable mini_mime (>= 0.1.3) nokogiri (~> 1.8) rack (>= 1.6.0) rack-test (>= 0.6.3) - xpath (~> 3.0) + regexp_parser (~> 1.2) + xpath (~> 3.2) childprocess (0.9.0) ffi (~> 1.0, >= 1.0.11) - chromedriver-helper (1.2.0) + chromedriver-helper (2.1.0) archive-zip (~> 0.10) nokogiri (~> 1.8) chronic (0.10.2) coderay (1.1.2) - concurrent-ruby (1.0.5) + concurrent-ruby (1.1.4) crass (1.0.4) database_cleaner (1.7.0) debug_inspector (0.0.3) - devise (4.4.3) + devise (4.6.1) bcrypt (~> 3.0) orm_adapter (~> 0.1) railties (>= 4.1.0, < 6.0) responders warden (~> 1.2.3) - devise-i18n (1.6.2) - devise (>= 4.4) + devise-i18n (1.8.0) + devise (>= 4.6) docile (1.3.1) - erubi (1.7.1) + erubi (1.8.0) execjs (2.7.0) - factory_bot (4.10.0) - activesupport (>= 3.0.0) - factory_bot_rails (4.10.0) - factory_bot (~> 4.10.0) - railties (>= 3.0.0) - ffi (1.9.23) - formatador (0.2.5) - globalid (0.4.1) + factory_bot (5.0.2) activesupport (>= 4.2.0) - guard (2.14.2) + factory_bot_rails (5.0.1) + factory_bot (~> 5.0.0) + railties (>= 4.2.0) + ffi (1.10.0) + formatador (0.2.5) + globalid (0.4.2) + activesupport (>= 4.2.0) + guard (2.15.0) formatador (>= 0.2.4) listen (>= 2.7, < 4.0) lumberjack (>= 1.0.12, < 2.0) @@ -134,14 +134,14 @@ GEM has_scope (0.7.2) actionpack (>= 4.1) activesupport (>= 4.1) - hashie (3.5.7) - i18n (1.1.0) + hashie (3.6.0) + i18n (1.5.3) concurrent-ruby (~> 1.0) io-like (0.3.0) - jbuilder (2.7.0) + jbuilder (2.8.0) activesupport (>= 4.2.0) multi_json (>= 1.2) - json (2.1.0) + json (2.2.0) kaminari (1.1.1) activesupport (>= 4.1.0) kaminari-actionview (= 1.1.1) @@ -156,7 +156,7 @@ GEM kaminari-core (1.1.1) launchy (2.4.3) addressable (~> 2.3) - letter_opener (1.6.0) + letter_opener (1.7.0) launchy (~> 2.2) letter_opener_web (1.3.4) actionmailer (>= 3.2) @@ -170,97 +170,98 @@ GEM logging (2.2.2) little-plugger (~> 1.1) multi_json (~> 1.10) - loofah (2.2.2) + loofah (2.2.3) crass (~> 1.0.2) nokogiri (>= 1.5.9) lumberjack (1.0.13) - mail (2.7.0) + mail (2.7.1) mini_mime (>= 0.1.1) - marcel (0.3.2) + marcel (0.3.3) mimemagic (~> 0.3.2) - method_source (0.9.0) - mimemagic (0.3.2) - mini_mime (1.0.0) - mini_portile2 (2.3.0) + method_source (0.9.2) + mimemagic (0.3.3) + mini_mime (1.0.1) + mini_portile2 (2.4.0) minitest (5.11.3) - msgpack (1.2.4) + msgpack (1.2.7) multi_json (1.13.1) - mysql2 (0.5.1) + mysql2 (0.5.2) naught (1.1.0) nenv (0.3.0) net-scp (1.2.1) net-ssh (>= 2.6.5) - net-ssh (4.2.0) + net-ssh (5.1.0) nio4r (2.3.1) - nokogiri (1.8.4) - mini_portile2 (~> 2.3.0) + nokogiri (1.10.1) + mini_portile2 (~> 2.4.0) notiffany (0.1.1) nenv (~> 0.1) shellany (~> 0.0) - octicons (7.3.0) + octicons (8.5.0) nokogiri (>= 1.6.3.1) open4 (1.3.4) orm_adapter (0.5.0) - parallel (1.12.1) - parser (2.5.1.0) + parallel (1.14.0) + parser (2.6.0.0) ast (~> 2.4.0) - powerpack (0.1.1) - pry (0.11.3) + powerpack (0.1.2) + pry (0.12.2) coderay (~> 1.1.0) method_source (~> 0.9.0) - pry-byebug (3.6.0) - byebug (~> 10.0) + pry-byebug (3.7.0) + byebug (~> 11.0) pry (~> 0.10) - pry-rails (0.3.6) + pry-rails (0.3.9) pry (>= 0.10.4) - public_suffix (3.0.2) - puma (3.11.4) + public_suffix (3.0.3) + puma (3.12.0) pundit (1.1.0) activesupport (>= 3.0.0) - rack (2.0.5) - rack-contrib (2.0.1) + rack (2.0.6) + rack-contrib (2.1.0) rack (~> 2.0) - rack-proxy (0.6.4) + rack-proxy (0.6.5) rack rack-test (1.1.0) rack (>= 1.0, < 3) - rails (5.2.1) - actioncable (= 5.2.1) - actionmailer (= 5.2.1) - actionpack (= 5.2.1) - actionview (= 5.2.1) - activejob (= 5.2.1) - activemodel (= 5.2.1) - activerecord (= 5.2.1) - activestorage (= 5.2.1) - activesupport (= 5.2.1) + rails (5.2.2) + actioncable (= 5.2.2) + actionmailer (= 5.2.2) + actionpack (= 5.2.2) + actionview (= 5.2.2) + activejob (= 5.2.2) + activemodel (= 5.2.2) + activerecord (= 5.2.2) + activestorage (= 5.2.2) + activesupport (= 5.2.2) bundler (>= 1.3.0) - railties (= 5.2.1) + railties (= 5.2.2) sprockets-rails (>= 2.0.0) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) rails-html-sanitizer (1.0.4) loofah (~> 2.2, >= 2.2.2) - rails-i18n (5.1.1) + rails-i18n (5.1.3) i18n (>= 0.7, < 2) railties (>= 5.0, < 6) - railties (5.2.1) - actionpack (= 5.2.1) - activesupport (= 5.2.1) + railties (5.2.2) + actionpack (= 5.2.2) + activesupport (= 5.2.2) method_source rake (>= 0.8.7) thor (>= 0.19.0, < 2.0) rainbow (3.0.0) - rake (12.3.1) + rake (12.3.2) rb-fsevent (0.10.3) - rb-inotify (0.9.10) - ffi (>= 0.5.0, < 2) + rb-inotify (0.10.0) + ffi (~> 1.0) rbnacl (4.0.2) ffi - responders (2.4.0) - actionpack (>= 4.2.0, < 5.3) - railties (>= 4.2.0, < 5.3) + regexp_parser (1.3.0) + responders (2.4.1) + actionpack (>= 4.2.0, < 6.0) + railties (>= 4.2.0, < 6.0) rubocop (0.56.0) parallel (~> 1.10) parser (>= 2.5) @@ -268,10 +269,10 @@ GEM rainbow (>= 2.2.2, < 4.0) ruby-progressbar (~> 1.7) unicode-display_width (~> 1.0, >= 1.0.1) - ruby-progressbar (1.9.0) + ruby-progressbar (1.10.0) ruby_dep (1.5.0) - rubyzip (1.2.1) - sass (3.5.6) + rubyzip (1.2.2) + sass (3.7.3) sass-listen (~> 4.0.0) sass-listen (4.0.0) rb-fsevent (~> 0.9, >= 0.9.4) @@ -282,11 +283,11 @@ GEM sprockets (>= 2.8, < 4.0) sprockets-rails (>= 2.0, < 4.0) tilt (>= 1.1, < 3) - selenium-webdriver (3.12.0) + selenium-webdriver (3.141.0) childprocess (~> 0.5) - rubyzip (~> 1.2) + rubyzip (~> 1.2, >= 1.2.2) shellany (0.0.1) - simple_form (4.0.1) + simple_form (4.1.0) actionpack (>= 5.0) activemodel (>= 5.0) simplecov (0.16.1) @@ -306,28 +307,28 @@ GEM actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) - sshkit (1.16.1) + sshkit (1.18.2) net-scp (>= 1.1.2) net-ssh (>= 2.8.0) - thor (0.20.0) + thor (0.20.3) thread_safe (0.3.6) - tilt (2.0.8) - turbolinks (5.1.1) - turbolinks-source (~> 5.1) - turbolinks-source (5.1.0) + tilt (2.0.9) + turbolinks (5.2.0) + turbolinks-source (~> 5.2) + turbolinks-source (5.2.0) tzinfo (1.2.5) thread_safe (~> 0.1) - uglifier (4.1.10) + uglifier (4.1.20) execjs (>= 0.3.0, < 3) - unicode-display_width (1.3.2) - warden (1.2.7) - rack (>= 1.0) - web-console (3.6.2) + unicode-display_width (1.4.1) + warden (1.2.8) + rack (>= 2.0.6) + web-console (3.7.0) actionview (>= 5.0) activemodel (>= 5.0) bindex (>= 0.4.0) railties (>= 5.0) - webpacker (3.5.3) + webpacker (3.5.5) activesupport (>= 4.2) rack-proxy (>= 0.6.1) railties (>= 4.2) @@ -336,7 +337,7 @@ GEM websocket-extensions (0.1.3) whenever (0.10.0) chronic (>= 0.6.3) - xpath (3.0.0) + xpath (3.2.0) nokogiri (~> 1.8) PLATFORMS @@ -357,7 +358,7 @@ DEPENDENCIES database_cleaner devise (~> 4.4) devise-i18n (~> 1.6) - factory_bot_rails + factory_bot_rails (~> 5.0) guard guard-minitest has_scope @@ -398,4 +399,4 @@ RUBY VERSION ruby 2.3.3p222 BUNDLED WITH - 1.16.2 + 1.17.2 diff --git a/test/factories/check_logs.rb b/test/factories/check_logs.rb index 669e52e..02828b1 100644 --- a/test/factories/check_logs.rb +++ b/test/factories/check_logs.rb @@ -27,9 +27,9 @@ FactoryBot.define do factory :check_log do check - status :pending - exit_status nil - parsed_response nil - raw_response nil + status { :pending } + exit_status { nil } + parsed_response { nil } + raw_response { nil } end end diff --git a/test/factories/check_notifications.rb b/test/factories/check_notifications.rb index 3167933..8cc2fbb 100644 --- a/test/factories/check_notifications.rb +++ b/test/factories/check_notifications.rb @@ -25,20 +25,20 @@ FactoryBot.define do factory :check_notification do check notification - status :pending - sent_at nil + status { :pending } + sent_at { nil } trait :ongoing do - status :ongoing + status { :ongoing } end trait :succeed do - status :succeed + status { :succeed } sent_at { 1.day.ago } end trait :failed do - status :failed + status { :failed } end end end diff --git a/test/factories/checks.rb b/test/factories/checks.rb index 27c383c..a0ad5cd 100644 --- a/test/factories/checks.rb +++ b/test/factories/checks.rb @@ -34,62 +34,54 @@ FactoryBot.define do factory :check do user - kind :domain - domain "domain.fr" - domain_created_at Time.new(2016, 4, 1, 12, 0, 0, "+02:00") - domain_updated_at Time.new(2017, 3, 1, 12, 0, 0, "+02:00") - domain_expires_at Time.new(2019, 4, 1, 12, 0, 0, "+02:00") - active true - vendor nil - comment nil - last_run_at nil - last_success_at nil - consecutive_failures 0 - mode :auto + kind { :domain } + domain { "domain.fr" } + domain_created_at { Time.new(2016, 4, 1, 12, 0, 0, "+02:00") } + domain_updated_at { Time.new(2017, 3, 1, 12, 0, 0, "+02:00") } + domain_expires_at { Time.new(2019, 4, 1, 12, 0, 0, "+02:00") } + active { true } + vendor { nil } + comment { nil } + last_run_at { nil } + last_success_at { nil } + consecutive_failures { 0 } + mode { :auto } trait :domain do - kind :domain + kind { :domain } end trait :ssl do - kind :ssl + kind { :ssl } end trait :nil_dates do - domain_created_at nil - domain_updated_at nil - domain_expires_at nil + domain_created_at { nil } + domain_updated_at { nil } + domain_expires_at { nil } end trait :expires_next_week do - domain_expires_at 1.week.from_now + domain_expires_at { 1.week.from_now } end trait :expires_next_year do - domain_expires_at 1.year.from_now + domain_expires_at { 1.year.from_now } end trait :last_runs_failed do - consecutive_failures 5 - last_run_at 3.days.ago - 90.minutes - last_success_at 7.days.ago - 2.hours + consecutive_failures { 5 } + last_run_at { 3.days.ago - 90.minutes } + last_success_at { 7.days.ago - 2.hours } end trait :last_run_succeed do - last_run_at 25.hour.ago - last_success_at 25.hour.ago + last_run_at { 25.hours.ago } + last_success_at { 25.hours.ago } end trait :inactive do - active false - end - - trait :with_notifications do - after :create do |check| - create_list :check_notification, 2, - check: check, - notification: build(:notification, user: check.user) - end + active { false } end end end diff --git a/test/factories/notifications.rb b/test/factories/notifications.rb index 434e386..fee11d0 100644 --- a/test/factories/notifications.rb +++ b/test/factories/notifications.rb @@ -29,13 +29,13 @@ FactoryBot.define do factory :notification do user - interval 30 - channel :email - label { "#{recipient} (#{interval})" } - recipient "recipient@domain.fr" + interval { 30 } + channel { :email } + sequence(:label) { |n| "#{recipient}-#{n} (#{interval})" } + recipient { "recipient@domain.fr" } trait :email do - channel :email + channel { :email } end end end diff --git a/test/factories/users.rb b/test/factories/users.rb index 2387c3c..0304233 100644 --- a/test/factories/users.rb +++ b/test/factories/users.rb @@ -38,14 +38,14 @@ require "securerandom" FactoryBot.define do factory :user do sequence(:email) { |n| "user-#{n}@chexpire.org" } - password "password" - confirmed_at Time.new(2018, 4, 1, 12, 0, 0, "+02:00") - notifications_enabled true - locale "en" - tos_accepted true + password { "password" } + confirmed_at { Time.new(2018, 4, 1, 12, 0, 0, "+02:00") } + notifications_enabled { true } + locale { "en" } + tos_accepted { true } trait :fr do - locale "fr" + locale { "fr" } end end end diff --git a/test/system/checks_test.rb b/test/system/checks_test.rb index 71e459d..4546c45 100644 --- a/test/system/checks_test.rb +++ b/test/system/checks_test.rb @@ -32,9 +32,8 @@ class ChecksTest < ApplicationSystemTestCase fill_in("check[domain]", with: domain) page.find("body").click # simulate blur - fill_in("check[domain_expires_at]", with: "2022-04-05") - - click_button + fill_in("check[domain_expires_at]", with: Date.new(2022, 4, 5)) + click_button "Create Check" assert_equal checks_path, page.current_path @@ -53,48 +52,54 @@ class ChecksTest < ApplicationSystemTestCase fill_and_valid_new_check end - test "dissociate a notification" do - check = create(:check, :with_notifications, user: @user) + test "dettach a notification from a check" do + initial_notifications_count = 2 + check = create(:check, user: @user) + existing_notifications = create_list(:notification, initial_notifications_count, user: @user) + check.notifications << existing_notifications + notification = create(:notification, label: "label-notification", user: @user) check.notifications << notification visit edit_check_path(check) - uncheck notification.label - click_button "Update Check" notification.reload + check.reload + assert_equal 0, notification.checks_count - assert_equal 2, check.check_notifications.count + assert_equal initial_notifications_count, check.notifications.count end - test "associate a notification" do + test "attach a notification to a check" do check = create(:check, user: @user) notification = create(:notification, label: "label-notification", user: @user) - visit edit_check_path(check) + visit edit_check_path(check) check notification.label click_button "Update Check" notification.reload + check.reload assert_equal 1, notification.checks_count assert_equal 1, check.check_notifications.count end test "update a check" do - check = create(:check, :with_notifications, domain: "dom-with-notif.net", user: @user) + check = create(:check, domain: "dom-with-notif.net", user: @user) + check.notifications << create_list(:notification, 2, user: @user) + visit edit_check_path(check) - fill_in "check[comment]", with: "My comment" - click_button "Update Check" assert_equal checks_path, page.current_path - assert page.has_css?(".alert-success") + check.reload + assert_equal "My comment", check.comment end