From 6913aac7816fe586cd4a9195b272346ef83316dc Mon Sep 17 00:00:00 2001 From: odeane_croney Date: Wed, 24 Jun 2020 15:27:06 +0200 Subject: [PATCH 01/15] fixing gem bug, creating rspec folder and creating db migration to correct format --- .rspec | 1 + Gemfile | 3 +- Gemfile.lock | 168 +++++++++++------- README.md | 40 +++++ .../20160322070219_devise_create_users.rb | 2 +- .../20160322070937_add_name_to_users.rb | 2 +- ...34145_create_mailboxer.mailboxer_engine.rb | 2 +- ...dd_conversation_optout.mailboxer_engine.rb | 2 +- ...47_add_missing_indices.mailboxer_engine.rb | 2 +- db/schema.rb | 102 +++++------ spec/rails_helper.rb | 64 +++++++ spec/spec_helper.rb | 96 ++++++++++ 12 files changed, 360 insertions(+), 124 deletions(-) create mode 100644 .rspec create mode 100644 spec/rails_helper.rb create mode 100644 spec/spec_helper.rb diff --git a/.rspec b/.rspec new file mode 100644 index 0000000..c99d2e7 --- /dev/null +++ b/.rspec @@ -0,0 +1 @@ +--require spec_helper diff --git a/Gemfile b/Gemfile index ef80204..398ad65 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,5 @@ source 'https://rubygems.org' -ruby '2.4.3' +ruby '2.6.3' gem 'rails', '5.1.5' @@ -20,6 +20,7 @@ group :development do gem 'pry-byebug' gem 'spring' gem 'web-console', '~> 2.0' + gem 'rspec-rails' end group :production do diff --git a/Gemfile.lock b/Gemfile.lock index d4285bf..0027d53 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -38,26 +38,31 @@ GEM i18n (~> 0.7) minitest (~> 5.1) tzinfo (~> 1.1) + addressable (2.7.0) + public_suffix (>= 2.0.2, < 5.0) arel (8.0.0) - autoprefixer-rails (8.6.4) + autoprefixer-rails (9.8.4) execjs - bcrypt (3.1.12) + bcrypt (3.1.13) binding_of_caller (0.8.0) debug_inspector (>= 0.0.1) - bootstrap-sass (3.3.7) + bootstrap-sass (3.4.1) autoprefixer-rails (>= 5.2.1) - sass (>= 3.3.4) - builder (3.2.3) - byebug (10.0.2) - carrierwave (1.2.3) - activemodel (>= 4.0.0) - activesupport (>= 4.0.0) - mime-types (>= 1.16) - chosen-rails (1.8.3) + sassc (>= 2.0.0) + builder (3.2.4) + byebug (11.1.3) + carrierwave (2.1.0) + activemodel (>= 5.0.0) + activesupport (>= 5.0.0) + addressable (~> 2.6) + image_processing (~> 1.1) + mimemagic (>= 0.3.0) + mini_mime (>= 0.1.3) + chosen-rails (1.9.0) coffee-rails (>= 3.2) railties (>= 3.0) - sass-rails (>= 3.2) - coderay (1.1.2) + sassc-rails (>= 2.1.2) + coderay (1.1.3) coffee-rails (4.2.2) coffee-script (>= 2.2.0) railties (>= 4.0.0) @@ -65,59 +70,61 @@ GEM coffee-script-source execjs coffee-script-source (1.12.2) - concurrent-ruby (1.0.5) - crass (1.0.4) + concurrent-ruby (1.1.6) + crass (1.0.6) debug_inspector (0.0.3) - devise (4.4.3) + devise (4.7.2) bcrypt (~> 3.0) orm_adapter (~> 0.1) - railties (>= 4.1.0, < 6.0) + railties (>= 4.1.0) responders warden (~> 1.2.3) - erubi (1.7.1) + diff-lcs (1.4.2) + erubi (1.9.0) execjs (2.7.0) - ffi (1.9.25) - globalid (0.4.1) + ffi (1.13.1) + globalid (0.4.2) activesupport (>= 4.2.0) i18n (0.9.5) concurrent-ruby (~> 1.0) - jbuilder (2.7.0) - activesupport (>= 4.2.0) - multi_json (>= 1.2) - jquery-rails (4.3.3) + image_processing (1.11.0) + mini_magick (>= 4.9.5, < 5) + ruby-vips (>= 2.0.17, < 3) + jbuilder (2.10.0) + activesupport (>= 5.0.0) + jquery-rails (4.4.0) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) - loofah (2.2.2) + loofah (2.2.3) crass (~> 1.0.2) nokogiri (>= 1.5.9) - mail (2.7.0) + mail (2.7.1) mini_mime (>= 0.1.1) mailboxer (0.15.1) carrierwave (>= 0.5.8) rails (>= 5.0.0) - method_source (0.9.0) - mime-types (3.1) - mime-types-data (~> 3.2015) - mime-types-data (3.2016.0521) - mini_mime (1.0.0) - mini_portile2 (2.3.0) - minitest (5.11.3) - multi_json (1.13.1) - nio4r (2.3.1) - nokogiri (1.8.3) - mini_portile2 (~> 2.3.0) + method_source (1.0.0) + mimemagic (0.3.5) + mini_magick (4.10.1) + mini_mime (1.0.2) + mini_portile2 (2.4.0) + minitest (5.14.1) + nio4r (2.5.2) + nokogiri (1.10.9) + mini_portile2 (~> 2.4.0) orm_adapter (0.5.0) pg (0.21.0) - pry (0.11.3) - coderay (~> 1.1.0) - method_source (~> 0.9.0) - pry-byebug (3.6.0) - byebug (~> 10.0) - pry (~> 0.10) - puma (3.11.4) - rack (2.0.5) - rack-test (1.0.0) + pry (0.13.1) + coderay (~> 1.1) + method_source (~> 1.0) + pry-byebug (3.9.0) + byebug (~> 11.0) + pry (~> 0.13.0) + public_suffix (4.0.5) + puma (3.12.6) + rack (2.2.3) + rack-test (1.1.0) rack (>= 1.0, < 3) rails (5.1.5) actioncable (= 5.1.5) @@ -148,13 +155,32 @@ GEM rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) rake (11.3.0) - rb-fsevent (0.10.3) - rb-inotify (0.9.10) - ffi (>= 0.5.0, < 2) - responders (2.4.0) - actionpack (>= 4.2.0, < 5.3) - railties (>= 4.2.0, < 5.3) - sass (3.5.6) + rb-fsevent (0.10.4) + rb-inotify (0.10.1) + ffi (~> 1.0) + responders (3.0.1) + actionpack (>= 5.0) + railties (>= 5.0) + rspec-core (3.9.2) + rspec-support (~> 3.9.3) + rspec-expectations (3.9.2) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.9.0) + rspec-mocks (3.9.1) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.9.0) + rspec-rails (4.0.1) + actionpack (>= 4.2) + activesupport (>= 4.2) + railties (>= 4.2) + rspec-core (~> 3.9) + rspec-expectations (~> 3.9) + rspec-mocks (~> 3.9) + rspec-support (~> 3.9) + rspec-support (3.9.3) + ruby-vips (2.0.17) + ffi (~> 1.9) + sass (3.7.4) sass-listen (~> 4.0.0) sass-listen (4.0.0) rb-fsevent (~> 0.9, >= 0.9.4) @@ -165,8 +191,15 @@ GEM sprockets (>= 2.8, < 4.0) sprockets-rails (>= 2.0, < 4.0) tilt (>= 1.1, < 3) - spring (2.0.2) - activesupport (>= 4.2) + sassc (2.4.0) + ffi (~> 1.9) + sassc-rails (2.1.2) + railties (>= 4.0.0) + sassc (>= 2.0) + sprockets (> 3.0) + sprockets-rails + tilt + spring (2.1.0) sprockets (3.7.2) concurrent-ruby (~> 1.0) rack (> 1, < 3) @@ -174,18 +207,18 @@ GEM actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) - thor (0.20.0) + thor (1.0.1) thread_safe (0.3.6) - tilt (2.0.8) - turbolinks (5.1.1) - turbolinks-source (~> 5.1) - turbolinks-source (5.1.0) - tzinfo (1.2.5) + tilt (2.0.10) + turbolinks (5.2.1) + turbolinks-source (~> 5.2) + turbolinks-source (5.2.0) + tzinfo (1.2.7) thread_safe (~> 0.1) - uglifier (4.1.14) + uglifier (4.2.0) execjs (>= 0.3.0, < 3) - warden (1.2.7) - rack (>= 1.0) + warden (1.2.8) + rack (>= 2.0.6) web-console (2.3.0) activemodel (>= 4.0) binding_of_caller (>= 0.7.2) @@ -193,7 +226,7 @@ GEM sprockets-rails (>= 2.0, < 4.0) websocket-driver (0.6.5) websocket-extensions (>= 0.1.0) - websocket-extensions (0.1.3) + websocket-extensions (0.1.5) PLATFORMS ruby @@ -213,6 +246,7 @@ DEPENDENCIES rails-html-sanitizer (~> 1.0.4) rails_12factor rake (~> 11.1, >= 11.1.2) + rspec-rails sass-rails (~> 5.0) spring sprockets (~> 3.7.2) @@ -221,7 +255,7 @@ DEPENDENCIES web-console (~> 2.0) RUBY VERSION - ruby 2.4.3p205 + ruby 2.6.3p62 BUNDLED WITH - 1.16.1 + 2.1.4 diff --git a/README.md b/README.md index 3837735..2b16c63 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,43 @@ ## CA Mailboxer 2018 Code base for week 5 challenge - Working with legacy code + + + + +User Stories + +As a message sender +I want an application that allows me to compose messages, +So that I can send to my friends and family. + +As a message sender +I want to have a confirmation prompt after sending a message +So that i know the message was sucessfully sent. + + +As a user +I want to have an account with a password that I can login into, +So that I can can keep my messages private. + + +As a message sender +I want to have an inbox +So that I can store my messages + + +As a user +In order to see my sent message +i + + + +As a message sender +I want to be able to delete messages from my inbox and sent +So that I can remove unwanted messages. + + + +As a message sender +I want to store my recipients +So that I do not need to re-enter their information when I want to message them. diff --git a/db/migrate/20160322070219_devise_create_users.rb b/db/migrate/20160322070219_devise_create_users.rb index 2d82e68..b79efdb 100644 --- a/db/migrate/20160322070219_devise_create_users.rb +++ b/db/migrate/20160322070219_devise_create_users.rb @@ -1,4 +1,4 @@ -class DeviseCreateUsers < ActiveRecord::Migration +class DeviseCreateUsers < ActiveRecord::Migration[4.2] def change create_table(:users) do |t| ## Database authenticatable diff --git a/db/migrate/20160322070937_add_name_to_users.rb b/db/migrate/20160322070937_add_name_to_users.rb index bac750e..627b752 100644 --- a/db/migrate/20160322070937_add_name_to_users.rb +++ b/db/migrate/20160322070937_add_name_to_users.rb @@ -1,4 +1,4 @@ -class AddNameToUsers < ActiveRecord::Migration +class AddNameToUsers < ActiveRecord::Migration[4.2] def change add_column :users, :name, :string end diff --git a/db/migrate/20160322134145_create_mailboxer.mailboxer_engine.rb b/db/migrate/20160322134145_create_mailboxer.mailboxer_engine.rb index f1153f8..8985ef8 100644 --- a/db/migrate/20160322134145_create_mailboxer.mailboxer_engine.rb +++ b/db/migrate/20160322134145_create_mailboxer.mailboxer_engine.rb @@ -1,5 +1,5 @@ # This migration comes from mailboxer_engine (originally 20110511145103) -class CreateMailboxer < ActiveRecord::Migration +class CreateMailboxer < ActiveRecord::Migration[4.2] def self.up #Tables #Conversations diff --git a/db/migrate/20160322134146_add_conversation_optout.mailboxer_engine.rb b/db/migrate/20160322134146_add_conversation_optout.mailboxer_engine.rb index c4f4555..a9860bd 100644 --- a/db/migrate/20160322134146_add_conversation_optout.mailboxer_engine.rb +++ b/db/migrate/20160322134146_add_conversation_optout.mailboxer_engine.rb @@ -1,5 +1,5 @@ # This migration comes from mailboxer_engine (originally 20131206080416) -class AddConversationOptout < ActiveRecord::Migration +class AddConversationOptout < ActiveRecord::Migration[4.2] def self.up create_table :mailboxer_conversation_opt_outs do |t| t.references :unsubscriber, :polymorphic => true diff --git a/db/migrate/20160322134147_add_missing_indices.mailboxer_engine.rb b/db/migrate/20160322134147_add_missing_indices.mailboxer_engine.rb index 7444271..4ee0c7e 100644 --- a/db/migrate/20160322134147_add_missing_indices.mailboxer_engine.rb +++ b/db/migrate/20160322134147_add_missing_indices.mailboxer_engine.rb @@ -1,5 +1,5 @@ # This migration comes from mailboxer_engine (originally 20131206080417) -class AddMissingIndices < ActiveRecord::Migration +class AddMissingIndices < ActiveRecord::Migration[4.2] def change # We'll explicitly specify its name, as the auto-generated name is too long and exceeds 63 # characters limitation. diff --git a/db/schema.rb b/db/schema.rb index b49dd08..22fce58 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -15,72 +15,72 @@ # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" - create_table "mailboxer_conversation_opt_outs", force: :cascade do |t| - t.string "unsubscriber_type" + create_table "mailboxer_conversation_opt_outs", id: :serial, force: :cascade do |t| + t.string "unsubscriber_type" t.integer "unsubscriber_id" t.integer "conversation_id" - t.index ["conversation_id"], name: "index_mailboxer_conversation_opt_outs_on_conversation_id", using: :btree - t.index ["unsubscriber_id", "unsubscriber_type"], name: "index_mailboxer_conversation_opt_outs_on_unsubscriber_id_type", using: :btree + t.index ["conversation_id"], name: "index_mailboxer_conversation_opt_outs_on_conversation_id" + t.index ["unsubscriber_id", "unsubscriber_type"], name: "index_mailboxer_conversation_opt_outs_on_unsubscriber_id_type" end - create_table "mailboxer_conversations", force: :cascade do |t| - t.string "subject", default: "" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + create_table "mailboxer_conversations", id: :serial, force: :cascade do |t| + t.string "subject", default: "" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "mailboxer_notifications", force: :cascade do |t| - t.string "type" - t.text "body" - t.string "subject", default: "" - t.string "sender_type" - t.integer "sender_id" - t.integer "conversation_id" - t.boolean "draft", default: false - t.string "notification_code" - t.string "notified_object_type" - t.integer "notified_object_id" - t.string "attachment" - t.datetime "updated_at", null: false - t.datetime "created_at", null: false - t.boolean "global", default: false + create_table "mailboxer_notifications", id: :serial, force: :cascade do |t| + t.string "type" + t.text "body" + t.string "subject", default: "" + t.string "sender_type" + t.integer "sender_id" + t.integer "conversation_id" + t.boolean "draft", default: false + t.string "notification_code" + t.string "notified_object_type" + t.integer "notified_object_id" + t.string "attachment" + t.datetime "updated_at", null: false + t.datetime "created_at", null: false + t.boolean "global", default: false t.datetime "expires" - t.index ["conversation_id"], name: "index_mailboxer_notifications_on_conversation_id", using: :btree - t.index ["notified_object_id", "notified_object_type"], name: "index_mailboxer_notifications_on_notified_object_id_and_type", using: :btree - t.index ["sender_id", "sender_type"], name: "index_mailboxer_notifications_on_sender_id_and_sender_type", using: :btree - t.index ["type"], name: "index_mailboxer_notifications_on_type", using: :btree + t.index ["conversation_id"], name: "index_mailboxer_notifications_on_conversation_id" + t.index ["notified_object_id", "notified_object_type"], name: "index_mailboxer_notifications_on_notified_object_id_and_type" + t.index ["sender_id", "sender_type"], name: "index_mailboxer_notifications_on_sender_id_and_sender_type" + t.index ["type"], name: "index_mailboxer_notifications_on_type" end - create_table "mailboxer_receipts", force: :cascade do |t| - t.string "receiver_type" - t.integer "receiver_id" - t.integer "notification_id", null: false - t.boolean "is_read", default: false - t.boolean "trashed", default: false - t.boolean "deleted", default: false - t.string "mailbox_type", limit: 25 - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.index ["notification_id"], name: "index_mailboxer_receipts_on_notification_id", using: :btree - t.index ["receiver_id", "receiver_type"], name: "index_mailboxer_receipts_on_receiver_id_and_receiver_type", using: :btree + create_table "mailboxer_receipts", id: :serial, force: :cascade do |t| + t.string "receiver_type" + t.integer "receiver_id" + t.integer "notification_id", null: false + t.boolean "is_read", default: false + t.boolean "trashed", default: false + t.boolean "deleted", default: false + t.string "mailbox_type", limit: 25 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["notification_id"], name: "index_mailboxer_receipts_on_notification_id" + t.index ["receiver_id", "receiver_type"], name: "index_mailboxer_receipts_on_receiver_id_and_receiver_type" end - create_table "users", force: :cascade do |t| - t.string "email", default: "", null: false - t.string "encrypted_password", default: "", null: false - t.string "reset_password_token" + create_table "users", id: :serial, force: :cascade do |t| + t.string "email", default: "", null: false + t.string "encrypted_password", default: "", null: false + t.string "reset_password_token" t.datetime "reset_password_sent_at" t.datetime "remember_created_at" - t.integer "sign_in_count", default: 0, null: false + t.integer "sign_in_count", default: 0, null: false t.datetime "current_sign_in_at" t.datetime "last_sign_in_at" - t.inet "current_sign_in_ip" - t.inet "last_sign_in_ip" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.string "name" - t.index ["email"], name: "index_users_on_email", unique: true, using: :btree - t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree + t.inet "current_sign_in_ip" + t.inet "last_sign_in_ip" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "name" + t.index ["email"], name: "index_users_on_email", unique: true + t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true end add_foreign_key "mailboxer_conversation_opt_outs", "mailboxer_conversations", column: "conversation_id", name: "mb_opt_outs_on_conversations_id" diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb new file mode 100644 index 0000000..00345af --- /dev/null +++ b/spec/rails_helper.rb @@ -0,0 +1,64 @@ +# This file is copied to spec/ when you run 'rails generate rspec:install' +require 'spec_helper' +ENV['RAILS_ENV'] ||= 'test' +require File.expand_path('../config/environment', __dir__) +# Prevent database truncation if the environment is production +abort("The Rails environment is running in production mode!") if Rails.env.production? +require 'rspec/rails' +# Add additional requires below this line. Rails is not loaded until this point! + +# Requires supporting ruby files with custom matchers and macros, etc, in +# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are +# run as spec files by default. This means that files in spec/support that end +# in _spec.rb will both be required and run as specs, causing the specs to be +# run twice. It is recommended that you do not name files matching this glob to +# end with _spec.rb. You can configure this pattern with the --pattern +# option on the command line or in ~/.rspec, .rspec or `.rspec-local`. +# +# The following line is provided for convenience purposes. It has the downside +# of increasing the boot-up time by auto-requiring all files in the support +# directory. Alternatively, in the individual `*_spec.rb` files, manually +# require only the support files necessary. +# +# Dir[Rails.root.join('spec', 'support', '**', '*.rb')].sort.each { |f| require f } + +# Checks for pending migrations and applies them before tests are run. +# If you are not using ActiveRecord, you can remove these lines. +begin + ActiveRecord::Migration.maintain_test_schema! +rescue ActiveRecord::PendingMigrationError => e + puts e.to_s.strip + exit 1 +end +RSpec.configure do |config| + # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures + config.fixture_path = "#{::Rails.root}/spec/fixtures" + + # If you're not using ActiveRecord, or you'd prefer not to run each of your + # examples within a transaction, remove the following line or assign false + # instead of true. + config.use_transactional_fixtures = true + + # You can uncomment this line to turn off ActiveRecord support entirely. + # config.use_active_record = false + + # RSpec Rails can automatically mix in different behaviours to your tests + # based on their file location, for example enabling you to call `get` and + # `post` in specs under `spec/controllers`. + # + # You can disable this behaviour by removing the line below, and instead + # explicitly tag your specs with their type, e.g.: + # + # RSpec.describe UsersController, type: :controller do + # # ... + # end + # + # The different available types are documented in the features, such as in + # https://relishapp.com/rspec/rspec-rails/docs + config.infer_spec_type_from_file_location! + + # Filter lines from Rails gems in backtraces. + config.filter_rails_from_backtrace! + # arbitrary gems may also be filtered via: + # config.filter_gems_from_backtrace("gem name") +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..ce33d66 --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,96 @@ +# This file was generated by the `rails generate rspec:install` command. Conventionally, all +# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. +# The generated `.rspec` file contains `--require spec_helper` which will cause +# this file to always be loaded, without a need to explicitly require it in any +# files. +# +# Given that it is always loaded, you are encouraged to keep this file as +# light-weight as possible. Requiring heavyweight dependencies from this file +# will add to the boot time of your test suite on EVERY test run, even for an +# individual file that may not need all of that loaded. Instead, consider making +# a separate helper file that requires the additional dependencies and performs +# the additional setup, and require it from the spec files that actually need +# it. +# +# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration +RSpec.configure do |config| + # rspec-expectations config goes here. You can use an alternate + # assertion/expectation library such as wrong or the stdlib/minitest + # assertions if you prefer. + config.expect_with :rspec do |expectations| + # This option will default to `true` in RSpec 4. It makes the `description` + # and `failure_message` of custom matchers include text for helper methods + # defined using `chain`, e.g.: + # be_bigger_than(2).and_smaller_than(4).description + # # => "be bigger than 2 and smaller than 4" + # ...rather than: + # # => "be bigger than 2" + expectations.include_chain_clauses_in_custom_matcher_descriptions = true + end + + # rspec-mocks config goes here. You can use an alternate test double + # library (such as bogus or mocha) by changing the `mock_with` option here. + config.mock_with :rspec do |mocks| + # Prevents you from mocking or stubbing a method that does not exist on + # a real object. This is generally recommended, and will default to + # `true` in RSpec 4. + mocks.verify_partial_doubles = true + end + + # 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 + +# The settings below are suggested to provide a good initial experience +# with RSpec, but feel free to customize to your heart's content. +=begin + # 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 + # file, and it's useful to allow more verbose output when running an + # individual spec file. + if config.files_to_run.one? + # Use the documentation formatter for detailed output, + # unless a formatter has already been configured + # (e.g. via a command-line flag). + config.default_formatter = "doc" + end + + # 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 + + # 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 + # the seed, which is printed after each run. + # --seed 1234 + config.order = :random + + # Seed global randomization in this process using the `--seed` CLI option. + # Setting this allows you to use `--seed` to deterministically reproduce + # test failures related to randomization by passing the same `--seed` value + # as the one that triggered the failure. + Kernel.srand config.seed +=end +end From c1720bd362e50bd9619079cbdea31fdf069f41d1 Mon Sep 17 00:00:00 2001 From: Alex_Bellamy Date: Wed, 24 Jun 2020 15:27:57 +0200 Subject: [PATCH 02/15] installing Rspec, creating a database, updating migration version, app now loads on server --- .rspec | 3 + Gemfile | 3 +- Gemfile.lock | 168 +++++++++++------- .../20160322070219_devise_create_users.rb | 2 +- .../20160322070937_add_name_to_users.rb | 2 +- ...34145_create_mailboxer.mailboxer_engine.rb | 2 +- ...dd_conversation_optout.mailboxer_engine.rb | 2 +- ...47_add_missing_indices.mailboxer_engine.rb | 2 +- db/schema.rb | 102 +++++------ spec/rails_helper.rb | 64 +++++++ spec/spec_helper.rb | 96 ++++++++++ 11 files changed, 322 insertions(+), 124 deletions(-) create mode 100644 .rspec create mode 100644 spec/rails_helper.rb create mode 100644 spec/spec_helper.rb diff --git a/.rspec b/.rspec new file mode 100644 index 0000000..bb69742 --- /dev/null +++ b/.rspec @@ -0,0 +1,3 @@ +--require spec_helper +--format documentation +--color \ No newline at end of file diff --git a/Gemfile b/Gemfile index ef80204..398ad65 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,5 @@ source 'https://rubygems.org' -ruby '2.4.3' +ruby '2.6.3' gem 'rails', '5.1.5' @@ -20,6 +20,7 @@ group :development do gem 'pry-byebug' gem 'spring' gem 'web-console', '~> 2.0' + gem 'rspec-rails' end group :production do diff --git a/Gemfile.lock b/Gemfile.lock index d4285bf..0027d53 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -38,26 +38,31 @@ GEM i18n (~> 0.7) minitest (~> 5.1) tzinfo (~> 1.1) + addressable (2.7.0) + public_suffix (>= 2.0.2, < 5.0) arel (8.0.0) - autoprefixer-rails (8.6.4) + autoprefixer-rails (9.8.4) execjs - bcrypt (3.1.12) + bcrypt (3.1.13) binding_of_caller (0.8.0) debug_inspector (>= 0.0.1) - bootstrap-sass (3.3.7) + bootstrap-sass (3.4.1) autoprefixer-rails (>= 5.2.1) - sass (>= 3.3.4) - builder (3.2.3) - byebug (10.0.2) - carrierwave (1.2.3) - activemodel (>= 4.0.0) - activesupport (>= 4.0.0) - mime-types (>= 1.16) - chosen-rails (1.8.3) + sassc (>= 2.0.0) + builder (3.2.4) + byebug (11.1.3) + carrierwave (2.1.0) + activemodel (>= 5.0.0) + activesupport (>= 5.0.0) + addressable (~> 2.6) + image_processing (~> 1.1) + mimemagic (>= 0.3.0) + mini_mime (>= 0.1.3) + chosen-rails (1.9.0) coffee-rails (>= 3.2) railties (>= 3.0) - sass-rails (>= 3.2) - coderay (1.1.2) + sassc-rails (>= 2.1.2) + coderay (1.1.3) coffee-rails (4.2.2) coffee-script (>= 2.2.0) railties (>= 4.0.0) @@ -65,59 +70,61 @@ GEM coffee-script-source execjs coffee-script-source (1.12.2) - concurrent-ruby (1.0.5) - crass (1.0.4) + concurrent-ruby (1.1.6) + crass (1.0.6) debug_inspector (0.0.3) - devise (4.4.3) + devise (4.7.2) bcrypt (~> 3.0) orm_adapter (~> 0.1) - railties (>= 4.1.0, < 6.0) + railties (>= 4.1.0) responders warden (~> 1.2.3) - erubi (1.7.1) + diff-lcs (1.4.2) + erubi (1.9.0) execjs (2.7.0) - ffi (1.9.25) - globalid (0.4.1) + ffi (1.13.1) + globalid (0.4.2) activesupport (>= 4.2.0) i18n (0.9.5) concurrent-ruby (~> 1.0) - jbuilder (2.7.0) - activesupport (>= 4.2.0) - multi_json (>= 1.2) - jquery-rails (4.3.3) + image_processing (1.11.0) + mini_magick (>= 4.9.5, < 5) + ruby-vips (>= 2.0.17, < 3) + jbuilder (2.10.0) + activesupport (>= 5.0.0) + jquery-rails (4.4.0) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) - loofah (2.2.2) + loofah (2.2.3) crass (~> 1.0.2) nokogiri (>= 1.5.9) - mail (2.7.0) + mail (2.7.1) mini_mime (>= 0.1.1) mailboxer (0.15.1) carrierwave (>= 0.5.8) rails (>= 5.0.0) - method_source (0.9.0) - mime-types (3.1) - mime-types-data (~> 3.2015) - mime-types-data (3.2016.0521) - mini_mime (1.0.0) - mini_portile2 (2.3.0) - minitest (5.11.3) - multi_json (1.13.1) - nio4r (2.3.1) - nokogiri (1.8.3) - mini_portile2 (~> 2.3.0) + method_source (1.0.0) + mimemagic (0.3.5) + mini_magick (4.10.1) + mini_mime (1.0.2) + mini_portile2 (2.4.0) + minitest (5.14.1) + nio4r (2.5.2) + nokogiri (1.10.9) + mini_portile2 (~> 2.4.0) orm_adapter (0.5.0) pg (0.21.0) - pry (0.11.3) - coderay (~> 1.1.0) - method_source (~> 0.9.0) - pry-byebug (3.6.0) - byebug (~> 10.0) - pry (~> 0.10) - puma (3.11.4) - rack (2.0.5) - rack-test (1.0.0) + pry (0.13.1) + coderay (~> 1.1) + method_source (~> 1.0) + pry-byebug (3.9.0) + byebug (~> 11.0) + pry (~> 0.13.0) + public_suffix (4.0.5) + puma (3.12.6) + rack (2.2.3) + rack-test (1.1.0) rack (>= 1.0, < 3) rails (5.1.5) actioncable (= 5.1.5) @@ -148,13 +155,32 @@ GEM rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) rake (11.3.0) - rb-fsevent (0.10.3) - rb-inotify (0.9.10) - ffi (>= 0.5.0, < 2) - responders (2.4.0) - actionpack (>= 4.2.0, < 5.3) - railties (>= 4.2.0, < 5.3) - sass (3.5.6) + rb-fsevent (0.10.4) + rb-inotify (0.10.1) + ffi (~> 1.0) + responders (3.0.1) + actionpack (>= 5.0) + railties (>= 5.0) + rspec-core (3.9.2) + rspec-support (~> 3.9.3) + rspec-expectations (3.9.2) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.9.0) + rspec-mocks (3.9.1) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.9.0) + rspec-rails (4.0.1) + actionpack (>= 4.2) + activesupport (>= 4.2) + railties (>= 4.2) + rspec-core (~> 3.9) + rspec-expectations (~> 3.9) + rspec-mocks (~> 3.9) + rspec-support (~> 3.9) + rspec-support (3.9.3) + ruby-vips (2.0.17) + ffi (~> 1.9) + sass (3.7.4) sass-listen (~> 4.0.0) sass-listen (4.0.0) rb-fsevent (~> 0.9, >= 0.9.4) @@ -165,8 +191,15 @@ GEM sprockets (>= 2.8, < 4.0) sprockets-rails (>= 2.0, < 4.0) tilt (>= 1.1, < 3) - spring (2.0.2) - activesupport (>= 4.2) + sassc (2.4.0) + ffi (~> 1.9) + sassc-rails (2.1.2) + railties (>= 4.0.0) + sassc (>= 2.0) + sprockets (> 3.0) + sprockets-rails + tilt + spring (2.1.0) sprockets (3.7.2) concurrent-ruby (~> 1.0) rack (> 1, < 3) @@ -174,18 +207,18 @@ GEM actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) - thor (0.20.0) + thor (1.0.1) thread_safe (0.3.6) - tilt (2.0.8) - turbolinks (5.1.1) - turbolinks-source (~> 5.1) - turbolinks-source (5.1.0) - tzinfo (1.2.5) + tilt (2.0.10) + turbolinks (5.2.1) + turbolinks-source (~> 5.2) + turbolinks-source (5.2.0) + tzinfo (1.2.7) thread_safe (~> 0.1) - uglifier (4.1.14) + uglifier (4.2.0) execjs (>= 0.3.0, < 3) - warden (1.2.7) - rack (>= 1.0) + warden (1.2.8) + rack (>= 2.0.6) web-console (2.3.0) activemodel (>= 4.0) binding_of_caller (>= 0.7.2) @@ -193,7 +226,7 @@ GEM sprockets-rails (>= 2.0, < 4.0) websocket-driver (0.6.5) websocket-extensions (>= 0.1.0) - websocket-extensions (0.1.3) + websocket-extensions (0.1.5) PLATFORMS ruby @@ -213,6 +246,7 @@ DEPENDENCIES rails-html-sanitizer (~> 1.0.4) rails_12factor rake (~> 11.1, >= 11.1.2) + rspec-rails sass-rails (~> 5.0) spring sprockets (~> 3.7.2) @@ -221,7 +255,7 @@ DEPENDENCIES web-console (~> 2.0) RUBY VERSION - ruby 2.4.3p205 + ruby 2.6.3p62 BUNDLED WITH - 1.16.1 + 2.1.4 diff --git a/db/migrate/20160322070219_devise_create_users.rb b/db/migrate/20160322070219_devise_create_users.rb index 2d82e68..b79efdb 100644 --- a/db/migrate/20160322070219_devise_create_users.rb +++ b/db/migrate/20160322070219_devise_create_users.rb @@ -1,4 +1,4 @@ -class DeviseCreateUsers < ActiveRecord::Migration +class DeviseCreateUsers < ActiveRecord::Migration[4.2] def change create_table(:users) do |t| ## Database authenticatable diff --git a/db/migrate/20160322070937_add_name_to_users.rb b/db/migrate/20160322070937_add_name_to_users.rb index bac750e..627b752 100644 --- a/db/migrate/20160322070937_add_name_to_users.rb +++ b/db/migrate/20160322070937_add_name_to_users.rb @@ -1,4 +1,4 @@ -class AddNameToUsers < ActiveRecord::Migration +class AddNameToUsers < ActiveRecord::Migration[4.2] def change add_column :users, :name, :string end diff --git a/db/migrate/20160322134145_create_mailboxer.mailboxer_engine.rb b/db/migrate/20160322134145_create_mailboxer.mailboxer_engine.rb index f1153f8..8985ef8 100644 --- a/db/migrate/20160322134145_create_mailboxer.mailboxer_engine.rb +++ b/db/migrate/20160322134145_create_mailboxer.mailboxer_engine.rb @@ -1,5 +1,5 @@ # This migration comes from mailboxer_engine (originally 20110511145103) -class CreateMailboxer < ActiveRecord::Migration +class CreateMailboxer < ActiveRecord::Migration[4.2] def self.up #Tables #Conversations diff --git a/db/migrate/20160322134146_add_conversation_optout.mailboxer_engine.rb b/db/migrate/20160322134146_add_conversation_optout.mailboxer_engine.rb index c4f4555..a9860bd 100644 --- a/db/migrate/20160322134146_add_conversation_optout.mailboxer_engine.rb +++ b/db/migrate/20160322134146_add_conversation_optout.mailboxer_engine.rb @@ -1,5 +1,5 @@ # This migration comes from mailboxer_engine (originally 20131206080416) -class AddConversationOptout < ActiveRecord::Migration +class AddConversationOptout < ActiveRecord::Migration[4.2] def self.up create_table :mailboxer_conversation_opt_outs do |t| t.references :unsubscriber, :polymorphic => true diff --git a/db/migrate/20160322134147_add_missing_indices.mailboxer_engine.rb b/db/migrate/20160322134147_add_missing_indices.mailboxer_engine.rb index 7444271..4ee0c7e 100644 --- a/db/migrate/20160322134147_add_missing_indices.mailboxer_engine.rb +++ b/db/migrate/20160322134147_add_missing_indices.mailboxer_engine.rb @@ -1,5 +1,5 @@ # This migration comes from mailboxer_engine (originally 20131206080417) -class AddMissingIndices < ActiveRecord::Migration +class AddMissingIndices < ActiveRecord::Migration[4.2] def change # We'll explicitly specify its name, as the auto-generated name is too long and exceeds 63 # characters limitation. diff --git a/db/schema.rb b/db/schema.rb index b49dd08..22fce58 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -15,72 +15,72 @@ # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" - create_table "mailboxer_conversation_opt_outs", force: :cascade do |t| - t.string "unsubscriber_type" + create_table "mailboxer_conversation_opt_outs", id: :serial, force: :cascade do |t| + t.string "unsubscriber_type" t.integer "unsubscriber_id" t.integer "conversation_id" - t.index ["conversation_id"], name: "index_mailboxer_conversation_opt_outs_on_conversation_id", using: :btree - t.index ["unsubscriber_id", "unsubscriber_type"], name: "index_mailboxer_conversation_opt_outs_on_unsubscriber_id_type", using: :btree + t.index ["conversation_id"], name: "index_mailboxer_conversation_opt_outs_on_conversation_id" + t.index ["unsubscriber_id", "unsubscriber_type"], name: "index_mailboxer_conversation_opt_outs_on_unsubscriber_id_type" end - create_table "mailboxer_conversations", force: :cascade do |t| - t.string "subject", default: "" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + create_table "mailboxer_conversations", id: :serial, force: :cascade do |t| + t.string "subject", default: "" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "mailboxer_notifications", force: :cascade do |t| - t.string "type" - t.text "body" - t.string "subject", default: "" - t.string "sender_type" - t.integer "sender_id" - t.integer "conversation_id" - t.boolean "draft", default: false - t.string "notification_code" - t.string "notified_object_type" - t.integer "notified_object_id" - t.string "attachment" - t.datetime "updated_at", null: false - t.datetime "created_at", null: false - t.boolean "global", default: false + create_table "mailboxer_notifications", id: :serial, force: :cascade do |t| + t.string "type" + t.text "body" + t.string "subject", default: "" + t.string "sender_type" + t.integer "sender_id" + t.integer "conversation_id" + t.boolean "draft", default: false + t.string "notification_code" + t.string "notified_object_type" + t.integer "notified_object_id" + t.string "attachment" + t.datetime "updated_at", null: false + t.datetime "created_at", null: false + t.boolean "global", default: false t.datetime "expires" - t.index ["conversation_id"], name: "index_mailboxer_notifications_on_conversation_id", using: :btree - t.index ["notified_object_id", "notified_object_type"], name: "index_mailboxer_notifications_on_notified_object_id_and_type", using: :btree - t.index ["sender_id", "sender_type"], name: "index_mailboxer_notifications_on_sender_id_and_sender_type", using: :btree - t.index ["type"], name: "index_mailboxer_notifications_on_type", using: :btree + t.index ["conversation_id"], name: "index_mailboxer_notifications_on_conversation_id" + t.index ["notified_object_id", "notified_object_type"], name: "index_mailboxer_notifications_on_notified_object_id_and_type" + t.index ["sender_id", "sender_type"], name: "index_mailboxer_notifications_on_sender_id_and_sender_type" + t.index ["type"], name: "index_mailboxer_notifications_on_type" end - create_table "mailboxer_receipts", force: :cascade do |t| - t.string "receiver_type" - t.integer "receiver_id" - t.integer "notification_id", null: false - t.boolean "is_read", default: false - t.boolean "trashed", default: false - t.boolean "deleted", default: false - t.string "mailbox_type", limit: 25 - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.index ["notification_id"], name: "index_mailboxer_receipts_on_notification_id", using: :btree - t.index ["receiver_id", "receiver_type"], name: "index_mailboxer_receipts_on_receiver_id_and_receiver_type", using: :btree + create_table "mailboxer_receipts", id: :serial, force: :cascade do |t| + t.string "receiver_type" + t.integer "receiver_id" + t.integer "notification_id", null: false + t.boolean "is_read", default: false + t.boolean "trashed", default: false + t.boolean "deleted", default: false + t.string "mailbox_type", limit: 25 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["notification_id"], name: "index_mailboxer_receipts_on_notification_id" + t.index ["receiver_id", "receiver_type"], name: "index_mailboxer_receipts_on_receiver_id_and_receiver_type" end - create_table "users", force: :cascade do |t| - t.string "email", default: "", null: false - t.string "encrypted_password", default: "", null: false - t.string "reset_password_token" + create_table "users", id: :serial, force: :cascade do |t| + t.string "email", default: "", null: false + t.string "encrypted_password", default: "", null: false + t.string "reset_password_token" t.datetime "reset_password_sent_at" t.datetime "remember_created_at" - t.integer "sign_in_count", default: 0, null: false + t.integer "sign_in_count", default: 0, null: false t.datetime "current_sign_in_at" t.datetime "last_sign_in_at" - t.inet "current_sign_in_ip" - t.inet "last_sign_in_ip" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.string "name" - t.index ["email"], name: "index_users_on_email", unique: true, using: :btree - t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree + t.inet "current_sign_in_ip" + t.inet "last_sign_in_ip" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "name" + t.index ["email"], name: "index_users_on_email", unique: true + t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true end add_foreign_key "mailboxer_conversation_opt_outs", "mailboxer_conversations", column: "conversation_id", name: "mb_opt_outs_on_conversations_id" diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb new file mode 100644 index 0000000..00345af --- /dev/null +++ b/spec/rails_helper.rb @@ -0,0 +1,64 @@ +# This file is copied to spec/ when you run 'rails generate rspec:install' +require 'spec_helper' +ENV['RAILS_ENV'] ||= 'test' +require File.expand_path('../config/environment', __dir__) +# Prevent database truncation if the environment is production +abort("The Rails environment is running in production mode!") if Rails.env.production? +require 'rspec/rails' +# Add additional requires below this line. Rails is not loaded until this point! + +# Requires supporting ruby files with custom matchers and macros, etc, in +# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are +# run as spec files by default. This means that files in spec/support that end +# in _spec.rb will both be required and run as specs, causing the specs to be +# run twice. It is recommended that you do not name files matching this glob to +# end with _spec.rb. You can configure this pattern with the --pattern +# option on the command line or in ~/.rspec, .rspec or `.rspec-local`. +# +# The following line is provided for convenience purposes. It has the downside +# of increasing the boot-up time by auto-requiring all files in the support +# directory. Alternatively, in the individual `*_spec.rb` files, manually +# require only the support files necessary. +# +# Dir[Rails.root.join('spec', 'support', '**', '*.rb')].sort.each { |f| require f } + +# Checks for pending migrations and applies them before tests are run. +# If you are not using ActiveRecord, you can remove these lines. +begin + ActiveRecord::Migration.maintain_test_schema! +rescue ActiveRecord::PendingMigrationError => e + puts e.to_s.strip + exit 1 +end +RSpec.configure do |config| + # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures + config.fixture_path = "#{::Rails.root}/spec/fixtures" + + # If you're not using ActiveRecord, or you'd prefer not to run each of your + # examples within a transaction, remove the following line or assign false + # instead of true. + config.use_transactional_fixtures = true + + # You can uncomment this line to turn off ActiveRecord support entirely. + # config.use_active_record = false + + # RSpec Rails can automatically mix in different behaviours to your tests + # based on their file location, for example enabling you to call `get` and + # `post` in specs under `spec/controllers`. + # + # You can disable this behaviour by removing the line below, and instead + # explicitly tag your specs with their type, e.g.: + # + # RSpec.describe UsersController, type: :controller do + # # ... + # end + # + # The different available types are documented in the features, such as in + # https://relishapp.com/rspec/rspec-rails/docs + config.infer_spec_type_from_file_location! + + # Filter lines from Rails gems in backtraces. + config.filter_rails_from_backtrace! + # arbitrary gems may also be filtered via: + # config.filter_gems_from_backtrace("gem name") +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..ce33d66 --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,96 @@ +# This file was generated by the `rails generate rspec:install` command. Conventionally, all +# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. +# The generated `.rspec` file contains `--require spec_helper` which will cause +# this file to always be loaded, without a need to explicitly require it in any +# files. +# +# Given that it is always loaded, you are encouraged to keep this file as +# light-weight as possible. Requiring heavyweight dependencies from this file +# will add to the boot time of your test suite on EVERY test run, even for an +# individual file that may not need all of that loaded. Instead, consider making +# a separate helper file that requires the additional dependencies and performs +# the additional setup, and require it from the spec files that actually need +# it. +# +# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration +RSpec.configure do |config| + # rspec-expectations config goes here. You can use an alternate + # assertion/expectation library such as wrong or the stdlib/minitest + # assertions if you prefer. + config.expect_with :rspec do |expectations| + # This option will default to `true` in RSpec 4. It makes the `description` + # and `failure_message` of custom matchers include text for helper methods + # defined using `chain`, e.g.: + # be_bigger_than(2).and_smaller_than(4).description + # # => "be bigger than 2 and smaller than 4" + # ...rather than: + # # => "be bigger than 2" + expectations.include_chain_clauses_in_custom_matcher_descriptions = true + end + + # rspec-mocks config goes here. You can use an alternate test double + # library (such as bogus or mocha) by changing the `mock_with` option here. + config.mock_with :rspec do |mocks| + # Prevents you from mocking or stubbing a method that does not exist on + # a real object. This is generally recommended, and will default to + # `true` in RSpec 4. + mocks.verify_partial_doubles = true + end + + # 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 + +# The settings below are suggested to provide a good initial experience +# with RSpec, but feel free to customize to your heart's content. +=begin + # 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 + # file, and it's useful to allow more verbose output when running an + # individual spec file. + if config.files_to_run.one? + # Use the documentation formatter for detailed output, + # unless a formatter has already been configured + # (e.g. via a command-line flag). + config.default_formatter = "doc" + end + + # 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 + + # 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 + # the seed, which is printed after each run. + # --seed 1234 + config.order = :random + + # Seed global randomization in this process using the `--seed` CLI option. + # Setting this allows you to use `--seed` to deterministically reproduce + # test failures related to randomization by passing the same `--seed` value + # as the one that triggered the failure. + Kernel.srand config.seed +=end +end From 76f71746031d7ddefb515c1534f45f30bb1105d2 Mon Sep 17 00:00:00 2001 From: felixoppongwillborg Date: Wed, 24 Jun 2020 15:29:23 +0200 Subject: [PATCH 03/15] created a specfolder and updated the db migration version to 4.2 and created a db migartion for add_missing_indices.mailboxer_engine --- .rspec | 3 + Gemfile | 3 +- Gemfile.lock | 168 +++++++++++------- .../20160322070219_devise_create_users.rb | 2 +- .../20160322070937_add_name_to_users.rb | 2 +- ...34145_create_mailboxer.mailboxer_engine.rb | 2 +- ...dd_conversation_optout.mailboxer_engine.rb | 2 +- ...47_add_missing_indices.mailboxer_engine.rb | 2 +- db/schema.rb | 102 +++++------ spec/rails_helper.rb | 64 +++++++ spec/spec_helper.rb | 96 ++++++++++ 11 files changed, 322 insertions(+), 124 deletions(-) create mode 100644 .rspec create mode 100644 spec/rails_helper.rb create mode 100644 spec/spec_helper.rb diff --git a/.rspec b/.rspec new file mode 100644 index 0000000..f6f85f5 --- /dev/null +++ b/.rspec @@ -0,0 +1,3 @@ +--require spec_helper +--color +--format documentation \ No newline at end of file diff --git a/Gemfile b/Gemfile index ef80204..398ad65 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,5 @@ source 'https://rubygems.org' -ruby '2.4.3' +ruby '2.6.3' gem 'rails', '5.1.5' @@ -20,6 +20,7 @@ group :development do gem 'pry-byebug' gem 'spring' gem 'web-console', '~> 2.0' + gem 'rspec-rails' end group :production do diff --git a/Gemfile.lock b/Gemfile.lock index d4285bf..346d26b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -38,26 +38,31 @@ GEM i18n (~> 0.7) minitest (~> 5.1) tzinfo (~> 1.1) + addressable (2.7.0) + public_suffix (>= 2.0.2, < 5.0) arel (8.0.0) - autoprefixer-rails (8.6.4) + autoprefixer-rails (9.8.4) execjs - bcrypt (3.1.12) + bcrypt (3.1.13) binding_of_caller (0.8.0) debug_inspector (>= 0.0.1) - bootstrap-sass (3.3.7) + bootstrap-sass (3.4.1) autoprefixer-rails (>= 5.2.1) - sass (>= 3.3.4) - builder (3.2.3) - byebug (10.0.2) - carrierwave (1.2.3) - activemodel (>= 4.0.0) - activesupport (>= 4.0.0) - mime-types (>= 1.16) - chosen-rails (1.8.3) + sassc (>= 2.0.0) + builder (3.2.4) + byebug (11.1.3) + carrierwave (2.1.0) + activemodel (>= 5.0.0) + activesupport (>= 5.0.0) + addressable (~> 2.6) + image_processing (~> 1.1) + mimemagic (>= 0.3.0) + mini_mime (>= 0.1.3) + chosen-rails (1.9.0) coffee-rails (>= 3.2) railties (>= 3.0) - sass-rails (>= 3.2) - coderay (1.1.2) + sassc-rails (>= 2.1.2) + coderay (1.1.3) coffee-rails (4.2.2) coffee-script (>= 2.2.0) railties (>= 4.0.0) @@ -65,59 +70,61 @@ GEM coffee-script-source execjs coffee-script-source (1.12.2) - concurrent-ruby (1.0.5) - crass (1.0.4) + concurrent-ruby (1.1.6) + crass (1.0.6) debug_inspector (0.0.3) - devise (4.4.3) + devise (4.7.2) bcrypt (~> 3.0) orm_adapter (~> 0.1) - railties (>= 4.1.0, < 6.0) + railties (>= 4.1.0) responders warden (~> 1.2.3) - erubi (1.7.1) + diff-lcs (1.4.2) + erubi (1.9.0) execjs (2.7.0) - ffi (1.9.25) - globalid (0.4.1) + ffi (1.13.1) + globalid (0.4.2) activesupport (>= 4.2.0) i18n (0.9.5) concurrent-ruby (~> 1.0) - jbuilder (2.7.0) - activesupport (>= 4.2.0) - multi_json (>= 1.2) - jquery-rails (4.3.3) + image_processing (1.11.0) + mini_magick (>= 4.9.5, < 5) + ruby-vips (>= 2.0.17, < 3) + jbuilder (2.10.0) + activesupport (>= 5.0.0) + jquery-rails (4.4.0) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) - loofah (2.2.2) + loofah (2.2.3) crass (~> 1.0.2) nokogiri (>= 1.5.9) - mail (2.7.0) + mail (2.7.1) mini_mime (>= 0.1.1) mailboxer (0.15.1) carrierwave (>= 0.5.8) rails (>= 5.0.0) - method_source (0.9.0) - mime-types (3.1) - mime-types-data (~> 3.2015) - mime-types-data (3.2016.0521) - mini_mime (1.0.0) - mini_portile2 (2.3.0) - minitest (5.11.3) - multi_json (1.13.1) - nio4r (2.3.1) - nokogiri (1.8.3) - mini_portile2 (~> 2.3.0) + method_source (1.0.0) + mimemagic (0.3.5) + mini_magick (4.10.1) + mini_mime (1.0.2) + mini_portile2 (2.4.0) + minitest (5.14.1) + nio4r (2.5.2) + nokogiri (1.10.9) + mini_portile2 (~> 2.4.0) orm_adapter (0.5.0) pg (0.21.0) - pry (0.11.3) - coderay (~> 1.1.0) - method_source (~> 0.9.0) - pry-byebug (3.6.0) - byebug (~> 10.0) - pry (~> 0.10) - puma (3.11.4) - rack (2.0.5) - rack-test (1.0.0) + pry (0.13.1) + coderay (~> 1.1) + method_source (~> 1.0) + pry-byebug (3.9.0) + byebug (~> 11.0) + pry (~> 0.13.0) + public_suffix (4.0.5) + puma (3.12.6) + rack (2.2.3) + rack-test (1.1.0) rack (>= 1.0, < 3) rails (5.1.5) actioncable (= 5.1.5) @@ -148,13 +155,32 @@ GEM rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) rake (11.3.0) - rb-fsevent (0.10.3) - rb-inotify (0.9.10) - ffi (>= 0.5.0, < 2) - responders (2.4.0) - actionpack (>= 4.2.0, < 5.3) - railties (>= 4.2.0, < 5.3) - sass (3.5.6) + rb-fsevent (0.10.4) + rb-inotify (0.10.1) + ffi (~> 1.0) + responders (3.0.1) + actionpack (>= 5.0) + railties (>= 5.0) + rspec-core (3.9.2) + rspec-support (~> 3.9.3) + rspec-expectations (3.9.2) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.9.0) + rspec-mocks (3.9.1) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.9.0) + rspec-rails (4.0.1) + actionpack (>= 4.2) + activesupport (>= 4.2) + railties (>= 4.2) + rspec-core (~> 3.9) + rspec-expectations (~> 3.9) + rspec-mocks (~> 3.9) + rspec-support (~> 3.9) + rspec-support (3.9.3) + ruby-vips (2.0.17) + ffi (~> 1.9) + sass (3.7.4) sass-listen (~> 4.0.0) sass-listen (4.0.0) rb-fsevent (~> 0.9, >= 0.9.4) @@ -165,8 +191,15 @@ GEM sprockets (>= 2.8, < 4.0) sprockets-rails (>= 2.0, < 4.0) tilt (>= 1.1, < 3) - spring (2.0.2) - activesupport (>= 4.2) + sassc (2.4.0) + ffi (~> 1.9) + sassc-rails (2.1.2) + railties (>= 4.0.0) + sassc (>= 2.0) + sprockets (> 3.0) + sprockets-rails + tilt + spring (2.1.0) sprockets (3.7.2) concurrent-ruby (~> 1.0) rack (> 1, < 3) @@ -174,18 +207,18 @@ GEM actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) - thor (0.20.0) + thor (1.0.1) thread_safe (0.3.6) - tilt (2.0.8) - turbolinks (5.1.1) - turbolinks-source (~> 5.1) - turbolinks-source (5.1.0) - tzinfo (1.2.5) + tilt (2.0.10) + turbolinks (5.2.1) + turbolinks-source (~> 5.2) + turbolinks-source (5.2.0) + tzinfo (1.2.7) thread_safe (~> 0.1) - uglifier (4.1.14) + uglifier (4.2.0) execjs (>= 0.3.0, < 3) - warden (1.2.7) - rack (>= 1.0) + warden (1.2.8) + rack (>= 2.0.6) web-console (2.3.0) activemodel (>= 4.0) binding_of_caller (>= 0.7.2) @@ -193,7 +226,7 @@ GEM sprockets-rails (>= 2.0, < 4.0) websocket-driver (0.6.5) websocket-extensions (>= 0.1.0) - websocket-extensions (0.1.3) + websocket-extensions (0.1.5) PLATFORMS ruby @@ -213,6 +246,7 @@ DEPENDENCIES rails-html-sanitizer (~> 1.0.4) rails_12factor rake (~> 11.1, >= 11.1.2) + rspec-rails sass-rails (~> 5.0) spring sprockets (~> 3.7.2) @@ -221,7 +255,7 @@ DEPENDENCIES web-console (~> 2.0) RUBY VERSION - ruby 2.4.3p205 + ruby 2.6.3p62 BUNDLED WITH - 1.16.1 + 1.17.3 diff --git a/db/migrate/20160322070219_devise_create_users.rb b/db/migrate/20160322070219_devise_create_users.rb index 2d82e68..b79efdb 100644 --- a/db/migrate/20160322070219_devise_create_users.rb +++ b/db/migrate/20160322070219_devise_create_users.rb @@ -1,4 +1,4 @@ -class DeviseCreateUsers < ActiveRecord::Migration +class DeviseCreateUsers < ActiveRecord::Migration[4.2] def change create_table(:users) do |t| ## Database authenticatable diff --git a/db/migrate/20160322070937_add_name_to_users.rb b/db/migrate/20160322070937_add_name_to_users.rb index bac750e..627b752 100644 --- a/db/migrate/20160322070937_add_name_to_users.rb +++ b/db/migrate/20160322070937_add_name_to_users.rb @@ -1,4 +1,4 @@ -class AddNameToUsers < ActiveRecord::Migration +class AddNameToUsers < ActiveRecord::Migration[4.2] def change add_column :users, :name, :string end diff --git a/db/migrate/20160322134145_create_mailboxer.mailboxer_engine.rb b/db/migrate/20160322134145_create_mailboxer.mailboxer_engine.rb index f1153f8..8985ef8 100644 --- a/db/migrate/20160322134145_create_mailboxer.mailboxer_engine.rb +++ b/db/migrate/20160322134145_create_mailboxer.mailboxer_engine.rb @@ -1,5 +1,5 @@ # This migration comes from mailboxer_engine (originally 20110511145103) -class CreateMailboxer < ActiveRecord::Migration +class CreateMailboxer < ActiveRecord::Migration[4.2] def self.up #Tables #Conversations diff --git a/db/migrate/20160322134146_add_conversation_optout.mailboxer_engine.rb b/db/migrate/20160322134146_add_conversation_optout.mailboxer_engine.rb index c4f4555..a9860bd 100644 --- a/db/migrate/20160322134146_add_conversation_optout.mailboxer_engine.rb +++ b/db/migrate/20160322134146_add_conversation_optout.mailboxer_engine.rb @@ -1,5 +1,5 @@ # This migration comes from mailboxer_engine (originally 20131206080416) -class AddConversationOptout < ActiveRecord::Migration +class AddConversationOptout < ActiveRecord::Migration[4.2] def self.up create_table :mailboxer_conversation_opt_outs do |t| t.references :unsubscriber, :polymorphic => true diff --git a/db/migrate/20160322134147_add_missing_indices.mailboxer_engine.rb b/db/migrate/20160322134147_add_missing_indices.mailboxer_engine.rb index 7444271..4ee0c7e 100644 --- a/db/migrate/20160322134147_add_missing_indices.mailboxer_engine.rb +++ b/db/migrate/20160322134147_add_missing_indices.mailboxer_engine.rb @@ -1,5 +1,5 @@ # This migration comes from mailboxer_engine (originally 20131206080417) -class AddMissingIndices < ActiveRecord::Migration +class AddMissingIndices < ActiveRecord::Migration[4.2] def change # We'll explicitly specify its name, as the auto-generated name is too long and exceeds 63 # characters limitation. diff --git a/db/schema.rb b/db/schema.rb index b49dd08..22fce58 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -15,72 +15,72 @@ # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" - create_table "mailboxer_conversation_opt_outs", force: :cascade do |t| - t.string "unsubscriber_type" + create_table "mailboxer_conversation_opt_outs", id: :serial, force: :cascade do |t| + t.string "unsubscriber_type" t.integer "unsubscriber_id" t.integer "conversation_id" - t.index ["conversation_id"], name: "index_mailboxer_conversation_opt_outs_on_conversation_id", using: :btree - t.index ["unsubscriber_id", "unsubscriber_type"], name: "index_mailboxer_conversation_opt_outs_on_unsubscriber_id_type", using: :btree + t.index ["conversation_id"], name: "index_mailboxer_conversation_opt_outs_on_conversation_id" + t.index ["unsubscriber_id", "unsubscriber_type"], name: "index_mailboxer_conversation_opt_outs_on_unsubscriber_id_type" end - create_table "mailboxer_conversations", force: :cascade do |t| - t.string "subject", default: "" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + create_table "mailboxer_conversations", id: :serial, force: :cascade do |t| + t.string "subject", default: "" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "mailboxer_notifications", force: :cascade do |t| - t.string "type" - t.text "body" - t.string "subject", default: "" - t.string "sender_type" - t.integer "sender_id" - t.integer "conversation_id" - t.boolean "draft", default: false - t.string "notification_code" - t.string "notified_object_type" - t.integer "notified_object_id" - t.string "attachment" - t.datetime "updated_at", null: false - t.datetime "created_at", null: false - t.boolean "global", default: false + create_table "mailboxer_notifications", id: :serial, force: :cascade do |t| + t.string "type" + t.text "body" + t.string "subject", default: "" + t.string "sender_type" + t.integer "sender_id" + t.integer "conversation_id" + t.boolean "draft", default: false + t.string "notification_code" + t.string "notified_object_type" + t.integer "notified_object_id" + t.string "attachment" + t.datetime "updated_at", null: false + t.datetime "created_at", null: false + t.boolean "global", default: false t.datetime "expires" - t.index ["conversation_id"], name: "index_mailboxer_notifications_on_conversation_id", using: :btree - t.index ["notified_object_id", "notified_object_type"], name: "index_mailboxer_notifications_on_notified_object_id_and_type", using: :btree - t.index ["sender_id", "sender_type"], name: "index_mailboxer_notifications_on_sender_id_and_sender_type", using: :btree - t.index ["type"], name: "index_mailboxer_notifications_on_type", using: :btree + t.index ["conversation_id"], name: "index_mailboxer_notifications_on_conversation_id" + t.index ["notified_object_id", "notified_object_type"], name: "index_mailboxer_notifications_on_notified_object_id_and_type" + t.index ["sender_id", "sender_type"], name: "index_mailboxer_notifications_on_sender_id_and_sender_type" + t.index ["type"], name: "index_mailboxer_notifications_on_type" end - create_table "mailboxer_receipts", force: :cascade do |t| - t.string "receiver_type" - t.integer "receiver_id" - t.integer "notification_id", null: false - t.boolean "is_read", default: false - t.boolean "trashed", default: false - t.boolean "deleted", default: false - t.string "mailbox_type", limit: 25 - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.index ["notification_id"], name: "index_mailboxer_receipts_on_notification_id", using: :btree - t.index ["receiver_id", "receiver_type"], name: "index_mailboxer_receipts_on_receiver_id_and_receiver_type", using: :btree + create_table "mailboxer_receipts", id: :serial, force: :cascade do |t| + t.string "receiver_type" + t.integer "receiver_id" + t.integer "notification_id", null: false + t.boolean "is_read", default: false + t.boolean "trashed", default: false + t.boolean "deleted", default: false + t.string "mailbox_type", limit: 25 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["notification_id"], name: "index_mailboxer_receipts_on_notification_id" + t.index ["receiver_id", "receiver_type"], name: "index_mailboxer_receipts_on_receiver_id_and_receiver_type" end - create_table "users", force: :cascade do |t| - t.string "email", default: "", null: false - t.string "encrypted_password", default: "", null: false - t.string "reset_password_token" + create_table "users", id: :serial, force: :cascade do |t| + t.string "email", default: "", null: false + t.string "encrypted_password", default: "", null: false + t.string "reset_password_token" t.datetime "reset_password_sent_at" t.datetime "remember_created_at" - t.integer "sign_in_count", default: 0, null: false + t.integer "sign_in_count", default: 0, null: false t.datetime "current_sign_in_at" t.datetime "last_sign_in_at" - t.inet "current_sign_in_ip" - t.inet "last_sign_in_ip" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.string "name" - t.index ["email"], name: "index_users_on_email", unique: true, using: :btree - t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree + t.inet "current_sign_in_ip" + t.inet "last_sign_in_ip" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "name" + t.index ["email"], name: "index_users_on_email", unique: true + t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true end add_foreign_key "mailboxer_conversation_opt_outs", "mailboxer_conversations", column: "conversation_id", name: "mb_opt_outs_on_conversations_id" diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb new file mode 100644 index 0000000..00345af --- /dev/null +++ b/spec/rails_helper.rb @@ -0,0 +1,64 @@ +# This file is copied to spec/ when you run 'rails generate rspec:install' +require 'spec_helper' +ENV['RAILS_ENV'] ||= 'test' +require File.expand_path('../config/environment', __dir__) +# Prevent database truncation if the environment is production +abort("The Rails environment is running in production mode!") if Rails.env.production? +require 'rspec/rails' +# Add additional requires below this line. Rails is not loaded until this point! + +# Requires supporting ruby files with custom matchers and macros, etc, in +# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are +# run as spec files by default. This means that files in spec/support that end +# in _spec.rb will both be required and run as specs, causing the specs to be +# run twice. It is recommended that you do not name files matching this glob to +# end with _spec.rb. You can configure this pattern with the --pattern +# option on the command line or in ~/.rspec, .rspec or `.rspec-local`. +# +# The following line is provided for convenience purposes. It has the downside +# of increasing the boot-up time by auto-requiring all files in the support +# directory. Alternatively, in the individual `*_spec.rb` files, manually +# require only the support files necessary. +# +# Dir[Rails.root.join('spec', 'support', '**', '*.rb')].sort.each { |f| require f } + +# Checks for pending migrations and applies them before tests are run. +# If you are not using ActiveRecord, you can remove these lines. +begin + ActiveRecord::Migration.maintain_test_schema! +rescue ActiveRecord::PendingMigrationError => e + puts e.to_s.strip + exit 1 +end +RSpec.configure do |config| + # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures + config.fixture_path = "#{::Rails.root}/spec/fixtures" + + # If you're not using ActiveRecord, or you'd prefer not to run each of your + # examples within a transaction, remove the following line or assign false + # instead of true. + config.use_transactional_fixtures = true + + # You can uncomment this line to turn off ActiveRecord support entirely. + # config.use_active_record = false + + # RSpec Rails can automatically mix in different behaviours to your tests + # based on their file location, for example enabling you to call `get` and + # `post` in specs under `spec/controllers`. + # + # You can disable this behaviour by removing the line below, and instead + # explicitly tag your specs with their type, e.g.: + # + # RSpec.describe UsersController, type: :controller do + # # ... + # end + # + # The different available types are documented in the features, such as in + # https://relishapp.com/rspec/rspec-rails/docs + config.infer_spec_type_from_file_location! + + # Filter lines from Rails gems in backtraces. + config.filter_rails_from_backtrace! + # arbitrary gems may also be filtered via: + # config.filter_gems_from_backtrace("gem name") +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..ce33d66 --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,96 @@ +# This file was generated by the `rails generate rspec:install` command. Conventionally, all +# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. +# The generated `.rspec` file contains `--require spec_helper` which will cause +# this file to always be loaded, without a need to explicitly require it in any +# files. +# +# Given that it is always loaded, you are encouraged to keep this file as +# light-weight as possible. Requiring heavyweight dependencies from this file +# will add to the boot time of your test suite on EVERY test run, even for an +# individual file that may not need all of that loaded. Instead, consider making +# a separate helper file that requires the additional dependencies and performs +# the additional setup, and require it from the spec files that actually need +# it. +# +# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration +RSpec.configure do |config| + # rspec-expectations config goes here. You can use an alternate + # assertion/expectation library such as wrong or the stdlib/minitest + # assertions if you prefer. + config.expect_with :rspec do |expectations| + # This option will default to `true` in RSpec 4. It makes the `description` + # and `failure_message` of custom matchers include text for helper methods + # defined using `chain`, e.g.: + # be_bigger_than(2).and_smaller_than(4).description + # # => "be bigger than 2 and smaller than 4" + # ...rather than: + # # => "be bigger than 2" + expectations.include_chain_clauses_in_custom_matcher_descriptions = true + end + + # rspec-mocks config goes here. You can use an alternate test double + # library (such as bogus or mocha) by changing the `mock_with` option here. + config.mock_with :rspec do |mocks| + # Prevents you from mocking or stubbing a method that does not exist on + # a real object. This is generally recommended, and will default to + # `true` in RSpec 4. + mocks.verify_partial_doubles = true + end + + # 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 + +# The settings below are suggested to provide a good initial experience +# with RSpec, but feel free to customize to your heart's content. +=begin + # 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 + # file, and it's useful to allow more verbose output when running an + # individual spec file. + if config.files_to_run.one? + # Use the documentation formatter for detailed output, + # unless a formatter has already been configured + # (e.g. via a command-line flag). + config.default_formatter = "doc" + end + + # 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 + + # 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 + # the seed, which is printed after each run. + # --seed 1234 + config.order = :random + + # Seed global randomization in this process using the `--seed` CLI option. + # Setting this allows you to use `--seed` to deterministically reproduce + # test failures related to randomization by passing the same `--seed` value + # as the one that triggered the failure. + Kernel.srand config.seed +=end +end From 2583dc9c8c4c57354c909392365f0167f3774387 Mon Sep 17 00:00:00 2001 From: Alex_Bellamy Date: Wed, 24 Jun 2020 18:24:28 +0200 Subject: [PATCH 04/15] login functionality - adding test to ensure Login button is present and the button functions which pass --- Gemfile | 1 + Gemfile.lock | 12 ++++++++++++ spec/user_can_log_in_spec.rb | 15 +++++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 spec/user_can_log_in_spec.rb diff --git a/Gemfile b/Gemfile index 398ad65..f448d1c 100644 --- a/Gemfile +++ b/Gemfile @@ -21,6 +21,7 @@ group :development do gem 'spring' gem 'web-console', '~> 2.0' gem 'rspec-rails' + gem 'capybara' end group :production do diff --git a/Gemfile.lock b/Gemfile.lock index 0027d53..c83fee2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -51,6 +51,14 @@ GEM sassc (>= 2.0.0) builder (3.2.4) byebug (11.1.3) + capybara (3.33.0) + addressable + mini_mime (>= 0.1.3) + nokogiri (~> 1.8) + rack (>= 1.6.0) + rack-test (>= 0.6.3) + regexp_parser (~> 1.5) + xpath (~> 3.2) carrierwave (2.1.0) activemodel (>= 5.0.0) activesupport (>= 5.0.0) @@ -158,6 +166,7 @@ GEM rb-fsevent (0.10.4) rb-inotify (0.10.1) ffi (~> 1.0) + regexp_parser (1.7.1) responders (3.0.1) actionpack (>= 5.0) railties (>= 5.0) @@ -227,12 +236,15 @@ GEM websocket-driver (0.6.5) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) + xpath (3.2.0) + nokogiri (~> 1.8) PLATFORMS ruby DEPENDENCIES bootstrap-sass + capybara chosen-rails devise jbuilder (~> 2.0) diff --git a/spec/user_can_log_in_spec.rb b/spec/user_can_log_in_spec.rb new file mode 100644 index 0000000..649fb62 --- /dev/null +++ b/spec/user_can_log_in_spec.rb @@ -0,0 +1,15 @@ +require "rails_helper" + +feature 'User can log in' do + context 'Sign in to account' + before do + visit root_path +end + +it 'displays a log in button' do + expect(page).to have_content 'Login' + click_on 'Login' +end +end + + From 2368b8d3f7e6ae3bf9594169b3cbb2405cb74700 Mon Sep 17 00:00:00 2001 From: felixoppongwillborg Date: Wed, 24 Jun 2020 21:03:37 +0200 Subject: [PATCH 05/15] wrote teo new tests for log in feature, first i changed root_path to user_session_path then wrote test to locate Email to make sure i was in the right path second test was for filling in email, password and then clickon log in button --- Gemfile | 1 + Gemfile.lock | 12 ++++++++++ db/schema.rb | 2 +- spec/feature/user_can_log_in_feature_spec.rb | 24 ++++++++++++++++++++ 4 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 spec/feature/user_can_log_in_feature_spec.rb diff --git a/Gemfile b/Gemfile index 398ad65..f448d1c 100644 --- a/Gemfile +++ b/Gemfile @@ -21,6 +21,7 @@ group :development do gem 'spring' gem 'web-console', '~> 2.0' gem 'rspec-rails' + gem 'capybara' end group :production do diff --git a/Gemfile.lock b/Gemfile.lock index 346d26b..b0080fc 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -51,6 +51,14 @@ GEM sassc (>= 2.0.0) builder (3.2.4) byebug (11.1.3) + capybara (3.33.0) + addressable + mini_mime (>= 0.1.3) + nokogiri (~> 1.8) + rack (>= 1.6.0) + rack-test (>= 0.6.3) + regexp_parser (~> 1.5) + xpath (~> 3.2) carrierwave (2.1.0) activemodel (>= 5.0.0) activesupport (>= 5.0.0) @@ -158,6 +166,7 @@ GEM rb-fsevent (0.10.4) rb-inotify (0.10.1) ffi (~> 1.0) + regexp_parser (1.7.1) responders (3.0.1) actionpack (>= 5.0) railties (>= 5.0) @@ -227,12 +236,15 @@ GEM websocket-driver (0.6.5) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) + xpath (3.2.0) + nokogiri (~> 1.8) PLATFORMS ruby DEPENDENCIES bootstrap-sass + capybara chosen-rails devise jbuilder (~> 2.0) diff --git a/db/schema.rb b/db/schema.rb index 22fce58..da403e3 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -86,4 +86,4 @@ add_foreign_key "mailboxer_conversation_opt_outs", "mailboxer_conversations", column: "conversation_id", name: "mb_opt_outs_on_conversations_id" add_foreign_key "mailboxer_notifications", "mailboxer_conversations", column: "conversation_id", name: "notifications_on_conversation_id" add_foreign_key "mailboxer_receipts", "mailboxer_notifications", column: "notification_id", name: "receipts_on_notification_id" -end +end \ No newline at end of file diff --git a/spec/feature/user_can_log_in_feature_spec.rb b/spec/feature/user_can_log_in_feature_spec.rb new file mode 100644 index 0000000..9b55ca4 --- /dev/null +++ b/spec/feature/user_can_log_in_feature_spec.rb @@ -0,0 +1,24 @@ +require "rails_helper" + +feature 'User can log in' do + context 'Sign in to account' + before do + visit user_session_path +end + +it 'displays a log in button' do + expect(page).to have_content 'Login' + click_on 'Login' +end + +it 'displays a email form' do + expect(page).to have_content 'Email' +end + +it 'fills in email and password' do + fill_in "Email", :with => "admin@admin.com" + fill_in "Password", :with => "password" + click_on "Log in" +end + +end \ No newline at end of file From 62fbc436ab17cc0ecd4336ec6f726d029a21fe5c Mon Sep 17 00:00:00 2001 From: felixoppongwillborg Date: Thu, 25 Jun 2020 09:32:21 +0200 Subject: [PATCH 06/15] writing test for redirecting efter log in --- spec/feature/user_can_log_in_feature_spec.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spec/feature/user_can_log_in_feature_spec.rb b/spec/feature/user_can_log_in_feature_spec.rb index 9b55ca4..5a09128 100644 --- a/spec/feature/user_can_log_in_feature_spec.rb +++ b/spec/feature/user_can_log_in_feature_spec.rb @@ -21,4 +21,8 @@ click_on "Log in" end +it 'redirect user to ladning page' do + expect(page).to have_content 'Signed in successfully.' +end + end \ No newline at end of file From d3d15580843b410b3595c83957606a1c414e7c9f Mon Sep 17 00:00:00 2001 From: felixoppongwillborg Date: Thu, 25 Jun 2020 09:42:21 +0200 Subject: [PATCH 07/15] updated README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3837735..61ebc1b 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ ## CA Mailboxer 2018 -Code base for week 5 challenge - Working with legacy code +Code base for week 5 challenge - Working with legacy code... From d909ed51d02519c16312054db6952fd600704bbd Mon Sep 17 00:00:00 2001 From: odeane_croney Date: Thu, 25 Jun 2020 11:50:20 +0200 Subject: [PATCH 08/15] setting up factor bot, adding shoulder matcher --- Gemfile | 8 +-- Gemfile.lock | 22 ++++---- db/schema.rb | 2 +- spec/factories/user.rb | 7 +++ spec/feature/user_can_log_in_feature_spec.rb | 11 ++-- spec/models/user_spec.rb | 20 +++++++ spec/rails_helper.rb | 56 ++++---------------- 7 files changed, 59 insertions(+), 67 deletions(-) create mode 100644 spec/factories/user.rb create mode 100644 spec/models/user_spec.rb diff --git a/Gemfile b/Gemfile index 6a9b94b..dd6b608 100644 --- a/Gemfile +++ b/Gemfile @@ -20,11 +20,13 @@ group :development do gem 'pry-byebug' gem 'spring' gem 'web-console', '~> 2.0' +end + +group :development, :test do gem 'rspec-rails' -<<<<<<< HEAD -======= + gem 'shoulda-matchers' gem 'capybara' ->>>>>>> d3d15580843b410b3595c83957606a1c414e7c9f + gem 'factory_bot_rails' end group :production do diff --git a/Gemfile.lock b/Gemfile.lock index 0614b22..262a37c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -51,8 +51,6 @@ GEM sassc (>= 2.0.0) builder (3.2.4) byebug (11.1.3) -<<<<<<< HEAD -======= capybara (3.33.0) addressable mini_mime (>= 0.1.3) @@ -61,7 +59,6 @@ GEM rack-test (>= 0.6.3) regexp_parser (~> 1.5) xpath (~> 3.2) ->>>>>>> d3d15580843b410b3595c83957606a1c414e7c9f carrierwave (2.1.0) activemodel (>= 5.0.0) activesupport (>= 5.0.0) @@ -93,6 +90,11 @@ GEM diff-lcs (1.4.2) erubi (1.9.0) execjs (2.7.0) + factory_bot (6.0.2) + activesupport (>= 5.0.0) + factory_bot_rails (6.0.0) + factory_bot (~> 6.0.0) + railties (>= 5.0.0) ffi (1.13.1) globalid (0.4.2) activesupport (>= 4.2.0) @@ -169,10 +171,7 @@ GEM rb-fsevent (0.10.4) rb-inotify (0.10.1) ffi (~> 1.0) -<<<<<<< HEAD -======= regexp_parser (1.7.1) ->>>>>>> d3d15580843b410b3595c83957606a1c414e7c9f responders (3.0.1) actionpack (>= 5.0) railties (>= 5.0) @@ -214,6 +213,8 @@ GEM sprockets (> 3.0) sprockets-rails tilt + shoulda-matchers (4.3.0) + activesupport (>= 4.2.0) spring (2.1.0) sprockets (3.7.2) concurrent-ruby (~> 1.0) @@ -242,11 +243,8 @@ GEM websocket-driver (0.6.5) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) -<<<<<<< HEAD -======= xpath (3.2.0) nokogiri (~> 1.8) ->>>>>>> d3d15580843b410b3595c83957606a1c414e7c9f PLATFORMS ruby @@ -256,6 +254,7 @@ DEPENDENCIES capybara chosen-rails devise + factory_bot_rails jbuilder (~> 2.0) jquery-rails loofah (~> 2.2.1) @@ -269,6 +268,7 @@ DEPENDENCIES rake (~> 11.1, >= 11.1.2) rspec-rails sass-rails (~> 5.0) + shoulda-matchers spring sprockets (~> 3.7.2) turbolinks @@ -279,8 +279,4 @@ RUBY VERSION ruby 2.6.3p62 BUNDLED WITH -<<<<<<< HEAD 2.1.4 -======= - 1.17.3 ->>>>>>> d3d15580843b410b3595c83957606a1c414e7c9f diff --git a/db/schema.rb b/db/schema.rb index da403e3..22fce58 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -86,4 +86,4 @@ add_foreign_key "mailboxer_conversation_opt_outs", "mailboxer_conversations", column: "conversation_id", name: "mb_opt_outs_on_conversations_id" add_foreign_key "mailboxer_notifications", "mailboxer_conversations", column: "conversation_id", name: "notifications_on_conversation_id" add_foreign_key "mailboxer_receipts", "mailboxer_notifications", column: "notification_id", name: "receipts_on_notification_id" -end \ No newline at end of file +end diff --git a/spec/factories/user.rb b/spec/factories/user.rb new file mode 100644 index 0000000..7592e7e --- /dev/null +++ b/spec/factories/user.rb @@ -0,0 +1,7 @@ +FactoryBot.define do + factory :user do + email {'user@mail.com'} + password { 'password'} + name { 'Name'} + end +end \ No newline at end of file diff --git a/spec/feature/user_can_log_in_feature_spec.rb b/spec/feature/user_can_log_in_feature_spec.rb index 5a09128..61f30ea 100644 --- a/spec/feature/user_can_log_in_feature_spec.rb +++ b/spec/feature/user_can_log_in_feature_spec.rb @@ -3,6 +3,7 @@ feature 'User can log in' do context 'Sign in to account' before do + create(:user, email: 'user@mail.com', password: '1234') visit user_session_path end @@ -21,8 +22,12 @@ click_on "Log in" end -it 'redirect user to ladning page' do - expect(page).to have_content 'Signed in successfully.' + end -end \ No newline at end of file +# it 'redirect user to ladning page' do +# expect(page).to have_content 'Signed in successfully.' +# end + +# end + diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb new file mode 100644 index 0000000..7468523 --- /dev/null +++ b/spec/models/user_spec.rb @@ -0,0 +1,20 @@ +require 'rails_helper' + +RSpec.describe User, type: :model do + describe 'db table' do + it {is_expected.to have_db_column :email} + it {is_expected.to have_db_column :encrypted_password} + it {is_expected.to have_db_column :name} + end + + describe 'validations' do + it {is_expected.to validate_presence_of :email} + it {is_expected.to validate_presence_of :password} + end + + describe 'Factory' do + it 'should have valid factory' do + expect(FactoryBot.create(:user)).to be_valid + end + end +end \ No newline at end of file diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 00345af..600937f 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -1,29 +1,9 @@ -# This file is copied to spec/ when you run 'rails generate rspec:install' require 'spec_helper' ENV['RAILS_ENV'] ||= 'test' require File.expand_path('../config/environment', __dir__) -# Prevent database truncation if the environment is production + abort("The Rails environment is running in production mode!") if Rails.env.production? require 'rspec/rails' -# Add additional requires below this line. Rails is not loaded until this point! - -# Requires supporting ruby files with custom matchers and macros, etc, in -# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are -# run as spec files by default. This means that files in spec/support that end -# in _spec.rb will both be required and run as specs, causing the specs to be -# run twice. It is recommended that you do not name files matching this glob to -# end with _spec.rb. You can configure this pattern with the --pattern -# option on the command line or in ~/.rspec, .rspec or `.rspec-local`. -# -# The following line is provided for convenience purposes. It has the downside -# of increasing the boot-up time by auto-requiring all files in the support -# directory. Alternatively, in the individual `*_spec.rb` files, manually -# require only the support files necessary. -# -# Dir[Rails.root.join('spec', 'support', '**', '*.rb')].sort.each { |f| require f } - -# Checks for pending migrations and applies them before tests are run. -# If you are not using ActiveRecord, you can remove these lines. begin ActiveRecord::Migration.maintain_test_schema! rescue ActiveRecord::PendingMigrationError => e @@ -31,34 +11,16 @@ exit 1 end RSpec.configure do |config| - # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures config.fixture_path = "#{::Rails.root}/spec/fixtures" - - # If you're not using ActiveRecord, or you'd prefer not to run each of your - # examples within a transaction, remove the following line or assign false - # instead of true. config.use_transactional_fixtures = true - - # You can uncomment this line to turn off ActiveRecord support entirely. - # config.use_active_record = false - - # RSpec Rails can automatically mix in different behaviours to your tests - # based on their file location, for example enabling you to call `get` and - # `post` in specs under `spec/controllers`. - # - # You can disable this behaviour by removing the line below, and instead - # explicitly tag your specs with their type, e.g.: - # - # RSpec.describe UsersController, type: :controller do - # # ... - # end - # - # The different available types are documented in the features, such as in - # https://relishapp.com/rspec/rspec-rails/docs config.infer_spec_type_from_file_location! - - # Filter lines from Rails gems in backtraces. config.filter_rails_from_backtrace! - # arbitrary gems may also be filtered via: - # config.filter_gems_from_backtrace("gem name") + config.include FactoryBot::Syntax::Methods + + Shoulda::Matchers.configure do |config| + config.integrate do |with| + with.test_framework :rspec + with.library :rails + end +end end From e637ffb2484b5de5baefdf7a92da2bb94170a613 Mon Sep 17 00:00:00 2001 From: Alex_Bellamy Date: Thu, 25 Jun 2020 13:07:36 +0200 Subject: [PATCH 09/15] amending Factorybot password to enable tests to pass --- spec/feature/user_can_log_in_feature_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/feature/user_can_log_in_feature_spec.rb b/spec/feature/user_can_log_in_feature_spec.rb index 61f30ea..41c6e42 100644 --- a/spec/feature/user_can_log_in_feature_spec.rb +++ b/spec/feature/user_can_log_in_feature_spec.rb @@ -3,7 +3,7 @@ feature 'User can log in' do context 'Sign in to account' before do - create(:user, email: 'user@mail.com', password: '1234') + create(:user, email: 'user@mail.com', password: '12345678') visit user_session_path end From a38bda37f05d339f7f7728c75f6922f92aea7730 Mon Sep 17 00:00:00 2001 From: felixoppongwillborg Date: Thu, 25 Jun 2020 13:36:25 +0200 Subject: [PATCH 10/15] rewrote test to actually display that the login was succsessful --- Gemfile | 3 +-- spec/feature/user_can_log_in_feature_spec.rb | 5 +++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Gemfile b/Gemfile index 75d1201..a3acee2 100644 --- a/Gemfile +++ b/Gemfile @@ -17,10 +17,8 @@ gem 'turbolinks' gem 'uglifier', '>= 1.3.0' group :development do - gem 'pry-byebug' gem 'spring' gem 'web-console', '~> 2.0' - gem 'capybara' end group :development, :test do @@ -28,6 +26,7 @@ group :development, :test do gem 'shoulda-matchers' gem 'capybara' gem 'factory_bot_rails' + gem 'pry-byebug' end group :production do diff --git a/spec/feature/user_can_log_in_feature_spec.rb b/spec/feature/user_can_log_in_feature_spec.rb index 41c6e42..b57ca7d 100644 --- a/spec/feature/user_can_log_in_feature_spec.rb +++ b/spec/feature/user_can_log_in_feature_spec.rb @@ -17,9 +17,10 @@ end it 'fills in email and password' do - fill_in "Email", :with => "admin@admin.com" - fill_in "Password", :with => "password" + fill_in "Email", :with => 'user@mail.com' + fill_in "Password", :with => '12345678' click_on "Log in" + expect(page).to have_content 'Signed in successfully.' end From 4dab8aef1fe6d751ccef474ac7a28dcde59d1f72 Mon Sep 17 00:00:00 2001 From: odeane_croney Date: Thu, 25 Jun 2020 14:11:27 +0200 Subject: [PATCH 11/15] sad path for not entering or entering incorrect password --- spec/feature/user_can_log_in_feature_spec.rb | 42 ++++++++++---------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/spec/feature/user_can_log_in_feature_spec.rb b/spec/feature/user_can_log_in_feature_spec.rb index b57ca7d..503f303 100644 --- a/spec/feature/user_can_log_in_feature_spec.rb +++ b/spec/feature/user_can_log_in_feature_spec.rb @@ -7,28 +7,30 @@ visit user_session_path end -it 'displays a log in button' do - expect(page).to have_content 'Login' - click_on 'Login' -end - -it 'displays a email form' do - expect(page).to have_content 'Email' -end - -it 'fills in email and password' do - fill_in "Email", :with => 'user@mail.com' - fill_in "Password", :with => '12345678' - click_on "Log in" - expect(page).to have_content 'Signed in successfully.' -end + it 'displays a log in button' do + expect(page).to have_content 'Login' + click_on 'Login' + end + + it 'displays a email form' do + expect(page).to have_content 'Email' + end + + it 'fills in email and password' do + fill_in "Email", :with => 'user@mail.com' + fill_in "Password", :with => '12345678' + click_on "Log in" + expect(page).to have_content 'Signed in successfully.' + end + + it 'If no email or password is entered' do + fill_in 'Email', :with => '' + fill_in 'Password', :with => '' + click_on 'Log in' + expect(page).to have_content 'Invalid Email or password.' + end end -# it 'redirect user to ladning page' do -# expect(page).to have_content 'Signed in successfully.' -# end - -# end From b2da6c7c1508bd22ff72d79cf00530bcf34c445e Mon Sep 17 00:00:00 2001 From: odeane_croney Date: Thu, 25 Jun 2020 14:38:50 +0200 Subject: [PATCH 12/15] adding coveralls --- .gitignore | 2 +- Gemfile | 1 + Gemfile.lock | 19 ++++ coverage/.last_run.json | 5 ++ coverage/.resultset.json | 159 ++++++++++++++++++++++++++++++++++ coverage/.resultset.json.lock | 0 lib/tasks/ci.rake | 9 ++ spec/rails_helper.rb | 2 + 8 files changed, 196 insertions(+), 1 deletion(-) create mode 100644 coverage/.last_run.json create mode 100644 coverage/.resultset.json create mode 100644 coverage/.resultset.json.lock create mode 100644 lib/tasks/ci.rake diff --git a/.gitignore b/.gitignore index fc2396d..d5880d0 100644 --- a/.gitignore +++ b/.gitignore @@ -12,7 +12,7 @@ !/log/.keep /tmp .byebug_history - +.coverage/ # OSX files .DS_Store diff --git a/Gemfile b/Gemfile index a3acee2..5c9cb7f 100644 --- a/Gemfile +++ b/Gemfile @@ -27,6 +27,7 @@ group :development, :test do gem 'capybara' gem 'factory_bot_rails' gem 'pry-byebug' + gem 'coveralls', require: false end group :production do diff --git a/Gemfile.lock b/Gemfile.lock index 262a37c..c3f01ff 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -79,6 +79,12 @@ GEM execjs coffee-script-source (1.12.2) concurrent-ruby (1.1.6) + coveralls (0.8.23) + json (>= 1.8, < 3) + simplecov (~> 0.16.1) + term-ansicolor (~> 1.3) + thor (>= 0.19.4, < 2.0) + tins (~> 1.6) crass (1.0.6) debug_inspector (0.0.3) devise (4.7.2) @@ -88,6 +94,7 @@ GEM responders warden (~> 1.2.3) diff-lcs (1.4.2) + docile (1.3.2) erubi (1.9.0) execjs (2.7.0) factory_bot (6.0.2) @@ -109,6 +116,7 @@ GEM rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) + json (2.3.0) loofah (2.2.3) crass (~> 1.0.2) nokogiri (>= 1.5.9) @@ -215,6 +223,11 @@ GEM tilt shoulda-matchers (4.3.0) activesupport (>= 4.2.0) + simplecov (0.16.1) + docile (~> 1.1) + json (>= 1.8, < 3) + simplecov-html (~> 0.10.0) + simplecov-html (0.10.2) spring (2.1.0) sprockets (3.7.2) concurrent-ruby (~> 1.0) @@ -223,9 +236,14 @@ GEM actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) + sync (0.5.0) + term-ansicolor (1.7.1) + tins (~> 1.0) thor (1.0.1) thread_safe (0.3.6) tilt (2.0.10) + tins (1.25.0) + sync turbolinks (5.2.1) turbolinks-source (~> 5.2) turbolinks-source (5.2.0) @@ -253,6 +271,7 @@ DEPENDENCIES bootstrap-sass capybara chosen-rails + coveralls devise factory_bot_rails jbuilder (~> 2.0) diff --git a/coverage/.last_run.json b/coverage/.last_run.json new file mode 100644 index 0000000..8d60cae --- /dev/null +++ b/coverage/.last_run.json @@ -0,0 +1,5 @@ +{ + "result": { + "covered_percent": 34.09 + } +} diff --git a/coverage/.resultset.json b/coverage/.resultset.json new file mode 100644 index 0000000..cefc159 --- /dev/null +++ b/coverage/.resultset.json @@ -0,0 +1,159 @@ +{ + "RSpec": { + "coverage": { + "/Users/odeanecroney/Documents/craft_academy/legacy_code_june_2020/app/models/user.rb": [ + 1, + null, + null, + 1, + null, + null, + 1, + 1, + 1, + null, + 1, + null, + 1, + 0, + null, + null, + 1, + 0, + null, + null + ], + "/Users/odeanecroney/Documents/craft_academy/legacy_code_june_2020/app/models/application_record.rb": [ + 1, + 1, + null + ], + "/Users/odeanecroney/Documents/craft_academy/legacy_code_june_2020/app/helpers/application_helper.rb": [ + 1, + 1, + 2, + 1, + 0, + 1, + 0, + null, + null, + 1, + 0, + null, + null + ], + "/Users/odeanecroney/Documents/craft_academy/legacy_code_june_2020/app/helpers/mailbox_helper.rb": [ + 1, + 1, + null, + null, + 0, + null, + null + ], + "/Users/odeanecroney/Documents/craft_academy/legacy_code_june_2020/app/controllers/application_controller.rb": [ + 1, + null, + null, + 1, + null, + 1, + null, + 1, + null, + 1, + null, + 1, + 0, + null, + null, + 1, + 0, + null, + null, + 1, + null, + 1, + 9, + null, + null + ], + "/Users/odeanecroney/Documents/craft_academy/legacy_code_june_2020/app/controllers/welcome_controller.rb": [ + 1, + 1, + null, + null + ], + "/Users/odeanecroney/Documents/craft_academy/legacy_code_june_2020/app/controllers/mailbox_controller.rb": [ + 0, + 0, + null, + 0, + 0, + 0, + 0, + null, + 0, + 0, + 0, + 0, + null, + 0, + 0, + 0, + 0, + 0 + ], + "/Users/odeanecroney/Documents/craft_academy/legacy_code_june_2020/app/controllers/conversations_controller.rb": [ + 0, + 0, + null, + 0, + 0, + null, + 0, + 0, + 0, + 0, + 0, + 0, + null, + 0, + 0, + null, + 0, + 0, + null, + 0, + 0, + 0, + 0, + 0, + null, + 0, + 0, + 0, + 0, + null, + 0, + 0, + 0, + 0, + null, + 0, + null, + 0, + 0, + 0, + null, + 0, + 0, + 0, + null, + 0 + ] + }, + "timestamp": 1593088411 + } +} diff --git a/coverage/.resultset.json.lock b/coverage/.resultset.json.lock new file mode 100644 index 0000000..e69de29 diff --git a/lib/tasks/ci.rake b/lib/tasks/ci.rake new file mode 100644 index 0000000..070980c --- /dev/null +++ b/lib/tasks/ci.rake @@ -0,0 +1,9 @@ +unless Rails.env.production? + require 'rspec/core/rake_task' + require 'coveralls/rake/task' + Coveralls::RakeTask.new + namespace :ci do + desc 'Run all tests and generate a merged coverage report' + task tests: [:spec, 'coveralls:push'] + end + end \ No newline at end of file diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 600937f..c1b803d 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -1,4 +1,6 @@ require 'spec_helper' +require 'coveralls' +Coveralls.wear_merged!('rails') ENV['RAILS_ENV'] ||= 'test' require File.expand_path('../config/environment', __dir__) From 8abaa3fa7de198399fcf16c356acc66a69a56b5b Mon Sep 17 00:00:00 2001 From: odeane_croney Date: Fri, 26 Jun 2020 00:30:43 +0200 Subject: [PATCH 13/15] resolving text formatting and writing a more realistic sad path --- .rspec | 4 -- Gemfile | 2 +- Gemfile.lock | 4 +- README.md | 44 -------------------- spec/factories/user.rb | 10 ++--- spec/feature/user_can_log_in_feature_spec.rb | 22 +++++----- spec/models/user_spec.rb | 26 ++++++------ 7 files changed, 31 insertions(+), 81 deletions(-) diff --git a/.rspec b/.rspec index 16d8a25..4e33a32 100644 --- a/.rspec +++ b/.rspec @@ -1,7 +1,3 @@ --require spec_helper - ---format documentation ---color - --color --format documentation diff --git a/Gemfile b/Gemfile index 5c9cb7f..9cabbbf 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,5 @@ source 'https://rubygems.org' -ruby '2.6.3' +ruby '2.5.1' gem 'rails', '5.1.5' diff --git a/Gemfile.lock b/Gemfile.lock index c3f01ff..7191da8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -295,7 +295,7 @@ DEPENDENCIES web-console (~> 2.0) RUBY VERSION - ruby 2.6.3p62 + ruby 2.5.1p57 BUNDLED WITH - 2.1.4 + 1.17.3 diff --git a/README.md b/README.md index f6bc3fd..61ebc1b 100644 --- a/README.md +++ b/README.md @@ -1,47 +1,3 @@ ## CA Mailboxer 2018 -<<<<<<< HEAD -Code base for week 5 challenge - Working with legacy code - - - - -User Stories - -As a message sender -I want an application that allows me to compose messages, -So that I can send to my friends and family. - -As a message sender -I want to have a confirmation prompt after sending a message -So that i know the message was sucessfully sent. - - -As a user -I want to have an account with a password that I can login into, -So that I can can keep my messages private. - - -As a message sender -I want to have an inbox -So that I can store my messages - - -As a user -In order to see my sent message -i - - - -As a message sender -I want to be able to delete messages from my inbox and sent -So that I can remove unwanted messages. - - - -As a message sender -I want to store my recipients -So that I do not need to re-enter their information when I want to message them. -======= Code base for week 5 challenge - Working with legacy code... ->>>>>>> d3d15580843b410b3595c83957606a1c414e7c9f diff --git a/spec/factories/user.rb b/spec/factories/user.rb index 7592e7e..147a39f 100644 --- a/spec/factories/user.rb +++ b/spec/factories/user.rb @@ -1,7 +1,7 @@ FactoryBot.define do - factory :user do - email {'user@mail.com'} - password { 'password'} - name { 'Name'} - end + factory :user do + email {'user@mail.com'} + password { 'password'} + name { 'Name'} + end end \ No newline at end of file diff --git a/spec/feature/user_can_log_in_feature_spec.rb b/spec/feature/user_can_log_in_feature_spec.rb index 503f303..1299bb3 100644 --- a/spec/feature/user_can_log_in_feature_spec.rb +++ b/spec/feature/user_can_log_in_feature_spec.rb @@ -4,33 +4,31 @@ context 'Sign in to account' before do create(:user, email: 'user@mail.com', password: '12345678') - visit user_session_path -end + visit user_session_path + end it 'displays a log in button' do - expect(page).to have_content 'Login' - click_on 'Login' + expect(page).to have_content 'Login' + click_on 'Login' end it 'displays a email form' do - expect(page).to have_content 'Email' + expect(page).to have_content 'Email' end it 'fills in email and password' do fill_in "Email", :with => 'user@mail.com' fill_in "Password", :with => '12345678' click_on "Log in" - expect(page).to have_content 'Signed in successfully.' + expect(page).to have_content 'Signed in successfully.' end - it 'If no email or password is entered' do - fill_in 'Email', :with => '' - fill_in 'Password', :with => '' + it 'If the email format is incorrect or the password is too short' do + fill_in 'Email', :with => '&5aygde' + fill_in 'Password', :with => '22' click_on 'Log in' - expect(page).to have_content 'Invalid Email or password.' + expect(page).to have_content 'Invalid Email or password.' end - - end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 7468523..35f019f 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -1,20 +1,20 @@ require 'rails_helper' RSpec.describe User, type: :model do - describe 'db table' do - it {is_expected.to have_db_column :email} - it {is_expected.to have_db_column :encrypted_password} - it {is_expected.to have_db_column :name} - end + describe 'db table' do + it {is_expected.to have_db_column :email} + it {is_expected.to have_db_column :encrypted_password} + it {is_expected.to have_db_column :name} + end - describe 'validations' do - it {is_expected.to validate_presence_of :email} - it {is_expected.to validate_presence_of :password} - end + describe 'validations' do + it {is_expected.to validate_presence_of :email} + it {is_expected.to validate_presence_of :password} + end - describe 'Factory' do - it 'should have valid factory' do - expect(FactoryBot.create(:user)).to be_valid - end + describe 'Factory' do + it 'should have valid factory' do + expect(FactoryBot.create(:user)).to be_valid end + end end \ No newline at end of file From 3e8ec4ad0cab69788cd78e5b9d352232dbf6e0f9 Mon Sep 17 00:00:00 2001 From: odeane_croney Date: Fri, 26 Jun 2020 13:26:16 +0200 Subject: [PATCH 14/15] testing sad path seperately --- coverage/.resultset.json | 8 ++++---- spec/feature/user_can_log_in_feature_spec.rb | 20 ++++++++++++++++++-- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/coverage/.resultset.json b/coverage/.resultset.json index cefc159..317dd32 100644 --- a/coverage/.resultset.json +++ b/coverage/.resultset.json @@ -31,10 +31,10 @@ "/Users/odeanecroney/Documents/craft_academy/legacy_code_june_2020/app/helpers/application_helper.rb": [ 1, 1, - 2, + 3, 1, 0, - 1, + 2, 0, null, null, @@ -75,7 +75,7 @@ 1, null, 1, - 9, + 12, null, null ], @@ -154,6 +154,6 @@ 0 ] }, - "timestamp": 1593088411 + "timestamp": 1593170383 } } diff --git a/spec/feature/user_can_log_in_feature_spec.rb b/spec/feature/user_can_log_in_feature_spec.rb index 1299bb3..17b8e15 100644 --- a/spec/feature/user_can_log_in_feature_spec.rb +++ b/spec/feature/user_can_log_in_feature_spec.rb @@ -23,12 +23,28 @@ expect(page).to have_content 'Signed in successfully.' end - it 'If the email format is incorrect or the password is too short' do + it 'If the email format is incorrect' do fill_in 'Email', :with => '&5aygde' - fill_in 'Password', :with => '22' + fill_in 'Password', :with => '12345678' click_on 'Log in' expect(page).to have_content 'Invalid Email or password.' end + + + it 'If the password is incorrect' do + fill_in 'Email', :with => 'user@mail.com' + fill_in 'Password', :with => '2234' + click_on 'Log in' + expect(page).to have_content 'Invalid Email or password.' + end + + + it 'If the password is too short' do + fill_in 'Email', :with => '&5aygde' + fill_in 'Password', :with => '11' + click_on 'Log in' + expect(page).to have_content 'Invalid Email or password.' + end end From 22bcf6724633a8e7528f41744d7ba83c5434d8ae Mon Sep 17 00:00:00 2001 From: odeane_croney Date: Sun, 28 Jun 2020 09:59:16 +0200 Subject: [PATCH 15/15] formatting --- .solargraph.yml | 16 ++++ Gemfile | 1 + Gemfile.lock | 42 +++++++++ config/application.rb | 16 ---- config/routes.rb | 4 +- coverage/.resultset.json | 8 +- .../20160322070219_devise_create_users.rb | 24 +---- ...34145_create_mailboxer.mailboxer_engine.rb | 23 ++--- ...dd_conversation_optout.mailboxer_engine.rb | 1 - ...47_add_missing_indices.mailboxer_engine.rb | 8 -- spec/factories/user.rb | 6 +- spec/feature/user_can_log_in_feature_spec.rb | 22 ++--- spec/models/user_spec.rb | 2 +- spec/spec_helper.rb | 87 ------------------- spec/user_can_log_in_spec.rb | 14 +-- 15 files changed, 93 insertions(+), 181 deletions(-) create mode 100644 .solargraph.yml diff --git a/.solargraph.yml b/.solargraph.yml new file mode 100644 index 0000000..de93f6a --- /dev/null +++ b/.solargraph.yml @@ -0,0 +1,16 @@ +--- +include: +- "**/*.rb" +exclude: +- spec/**/* +- test/**/* +- vendor/**/* +- ".bundle/**/*" +require: [] +domains: [] +reporters: +- rubocop +- require_not_found +require_paths: [] +plugins: [] +max_files: 5000 diff --git a/Gemfile b/Gemfile index 9cabbbf..f357ff4 100644 --- a/Gemfile +++ b/Gemfile @@ -19,6 +19,7 @@ gem 'uglifier', '>= 1.3.0' group :development do gem 'spring' gem 'web-console', '~> 2.0' + gem 'solargraph' end group :development, :test do diff --git a/Gemfile.lock b/Gemfile.lock index 7191da8..dbc8836 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -41,9 +41,12 @@ GEM addressable (2.7.0) public_suffix (>= 2.0.2, < 5.0) arel (8.0.0) + ast (2.4.1) autoprefixer-rails (9.8.4) execjs + backport (1.1.2) bcrypt (3.1.13) + benchmark (0.1.0) binding_of_caller (0.8.0) debug_inspector (>= 0.0.1) bootstrap-sass (3.4.1) @@ -95,6 +98,7 @@ GEM warden (~> 1.2.3) diff-lcs (1.4.2) docile (1.3.2) + e2mmap (0.1.0) erubi (1.9.0) execjs (2.7.0) factory_bot (6.0.2) @@ -110,6 +114,7 @@ GEM image_processing (1.11.0) mini_magick (>= 4.9.5, < 5) ruby-vips (>= 2.0.17, < 3) + jaro_winkler (1.5.4) jbuilder (2.10.0) activesupport (>= 5.0.0) jquery-rails (4.4.0) @@ -125,6 +130,7 @@ GEM mailboxer (0.15.1) carrierwave (>= 0.5.8) rails (>= 5.0.0) + maruku (0.7.3) method_source (1.0.0) mimemagic (0.3.5) mini_magick (4.10.1) @@ -135,6 +141,9 @@ GEM nokogiri (1.10.9) mini_portile2 (~> 2.4.0) orm_adapter (0.5.0) + parallel (1.19.2) + parser (2.7.1.4) + ast (~> 2.4.1) pg (0.21.0) pry (0.13.1) coderay (~> 1.1) @@ -175,6 +184,7 @@ GEM method_source rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) + rainbow (3.0.0) rake (11.3.0) rb-fsevent (0.10.4) rb-inotify (0.10.1) @@ -183,6 +193,9 @@ GEM responders (3.0.1) actionpack (>= 5.0) railties (>= 5.0) + reverse_markdown (2.0.0) + nokogiri + rexml (3.2.4) rspec-core (3.9.2) rspec-support (~> 3.9.3) rspec-expectations (3.9.2) @@ -200,6 +213,18 @@ GEM rspec-mocks (~> 3.9) rspec-support (~> 3.9) rspec-support (3.9.3) + rubocop (0.86.0) + parallel (~> 1.10) + parser (>= 2.7.0.1) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.7) + rexml + rubocop-ast (>= 0.0.3, < 1.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 1.4.0, < 2.0) + rubocop-ast (0.1.0) + parser (>= 2.7.0.1) + ruby-progressbar (1.10.1) ruby-vips (2.0.17) ffi (~> 1.9) sass (3.7.4) @@ -228,6 +253,20 @@ GEM json (>= 1.8, < 3) simplecov-html (~> 0.10.0) simplecov-html (0.10.2) + solargraph (0.39.8) + backport (~> 1.1) + benchmark + bundler (>= 1.17.2) + e2mmap + jaro_winkler (~> 1.5) + maruku (~> 0.7, >= 0.7.3) + nokogiri (~> 1.9, >= 1.9.1) + parser (~> 2.3) + reverse_markdown (>= 1.0.5, < 3) + rubocop (~> 0.52) + thor (~> 1.0) + tilt (~> 2.0) + yard (~> 0.9, >= 0.9.24) spring (2.1.0) sprockets (3.7.2) concurrent-ruby (~> 1.0) @@ -251,6 +290,7 @@ GEM thread_safe (~> 0.1) uglifier (4.2.0) execjs (>= 0.3.0, < 3) + unicode-display_width (1.7.0) warden (1.2.8) rack (>= 2.0.6) web-console (2.3.0) @@ -263,6 +303,7 @@ GEM websocket-extensions (0.1.5) xpath (3.2.0) nokogiri (~> 1.8) + yard (0.9.25) PLATFORMS ruby @@ -288,6 +329,7 @@ DEPENDENCIES rspec-rails sass-rails (~> 5.0) shoulda-matchers + solargraph spring sprockets (~> 3.7.2) turbolinks diff --git a/config/application.rb b/config/application.rb index 66d7296..6fe32f3 100644 --- a/config/application.rb +++ b/config/application.rb @@ -1,7 +1,6 @@ require File.expand_path('../boot', __FILE__) require "rails" -# Pick the frameworks you want: require "active_model/railtie" require "active_job/railtie" require "active_record/railtie" @@ -9,26 +8,11 @@ require "action_mailer/railtie" require "action_view/railtie" require "sprockets/railtie" -# require "rails/test_unit/railtie" -# Require the gems listed in Gemfile, including any gems -# you've limited to :test, :development, or :production. Bundler.require(*Rails.groups) module Mailboxer class Application < Rails::Application - # Settings in config/environments/* take precedence over those specified here. - # Application configuration should go into files in config/initializers - # -- all .rb files in that directory are automatically loaded. - - # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. - # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. - # config.time_zone = 'Central Time (US & Canada)' - - # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. - # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] - # config.i18n.default_locale = :de - config.action_mailer.default_url_options = { host: 'ca-mailboxer.herokuapp.com' } config.generators do |generate| diff --git a/config/routes.rb b/config/routes.rb index 1abf899..5aa915e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -5,13 +5,13 @@ root 'welcome#index' - # mailbox folder routes + get "mailbox/inbox" => "mailbox#inbox", as: :mailbox_inbox get "mailbox/sent" => "mailbox#sent", as: :mailbox_sent get "mailbox/trash" => "mailbox#trash", as: :mailbox_trash - # conversations + resources :conversations do member do post :reply diff --git a/coverage/.resultset.json b/coverage/.resultset.json index 317dd32..1a06152 100644 --- a/coverage/.resultset.json +++ b/coverage/.resultset.json @@ -31,10 +31,10 @@ "/Users/odeanecroney/Documents/craft_academy/legacy_code_june_2020/app/helpers/application_helper.rb": [ 1, 1, - 3, + 4, 1, 0, - 2, + 3, 0, null, null, @@ -75,7 +75,7 @@ 1, null, 1, - 12, + 15, null, null ], @@ -154,6 +154,6 @@ 0 ] }, - "timestamp": 1593170383 + "timestamp": 1593330894 } } diff --git a/db/migrate/20160322070219_devise_create_users.rb b/db/migrate/20160322070219_devise_create_users.rb index b79efdb..1593436 100644 --- a/db/migrate/20160322070219_devise_create_users.rb +++ b/db/migrate/20160322070219_devise_create_users.rb @@ -1,42 +1,20 @@ class DeviseCreateUsers < ActiveRecord::Migration[4.2] def change create_table(:users) do |t| - ## Database authenticatable t.string :email, null: false, default: "" t.string :encrypted_password, null: false, default: "" - - ## Recoverable t.string :reset_password_token t.datetime :reset_password_sent_at - - ## Rememberable - t.datetime :remember_created_at - - ## Trackable + t.datetime :remember_created_at t.integer :sign_in_count, default: 0, null: false t.datetime :current_sign_in_at t.datetime :last_sign_in_at t.inet :current_sign_in_ip t.inet :last_sign_in_ip - - ## Confirmable - # t.string :confirmation_token - # t.datetime :confirmed_at - # t.datetime :confirmation_sent_at - # t.string :unconfirmed_email # Only if using reconfirmable - - ## Lockable - # t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts - # t.string :unlock_token # Only if unlock strategy is :email or :both - # t.datetime :locked_at - - t.timestamps null: false end add_index :users, :email, unique: true add_index :users, :reset_password_token, unique: true - # add_index :users, :confirmation_token, unique: true - # add_index :users, :unlock_token, unique: true end end diff --git a/db/migrate/20160322134145_create_mailboxer.mailboxer_engine.rb b/db/migrate/20160322134145_create_mailboxer.mailboxer_engine.rb index 8985ef8..6fb777d 100644 --- a/db/migrate/20160322134145_create_mailboxer.mailboxer_engine.rb +++ b/db/migrate/20160322134145_create_mailboxer.mailboxer_engine.rb @@ -1,14 +1,12 @@ -# This migration comes from mailboxer_engine (originally 20110511145103) class CreateMailboxer < ActiveRecord::Migration[4.2] def self.up - #Tables - #Conversations + create_table :mailboxer_conversations do |t| t.column :subject, :string, :default => "" t.column :created_at, :datetime, :null => false t.column :updated_at, :datetime, :null => false end - #Receipts + create_table :mailboxer_receipts do |t| t.references :receiver, :polymorphic => true t.column :notification_id, :integer, :null => false @@ -19,7 +17,7 @@ def self.up t.column :created_at, :datetime, :null => false t.column :updated_at, :datetime, :null => false end - #Notifications and Messages + create_table :mailboxer_notifications do |t| t.column :type, :string t.column :body, :text @@ -37,28 +35,17 @@ def self.up end - #Indexes - #Conversations - #Receipts - add_index "mailboxer_receipts","notification_id" - #Messages + add_index "mailboxer_receipts","notification_id" add_index "mailboxer_notifications","conversation_id" - - #Foreign keys - #Conversations - #Receipts add_foreign_key "mailboxer_receipts", "mailboxer_notifications", :name => "receipts_on_notification_id", :column => "notification_id" - #Messages add_foreign_key "mailboxer_notifications", "mailboxer_conversations", :name => "notifications_on_conversation_id", :column => "conversation_id" end def self.down - #Tables + remove_foreign_key "mailboxer_receipts", :name => "receipts_on_notification_id" remove_foreign_key "mailboxer_notifications", :name => "notifications_on_conversation_id" - - #Indexes drop_table :mailboxer_receipts drop_table :mailboxer_conversations drop_table :mailboxer_notifications diff --git a/db/migrate/20160322134146_add_conversation_optout.mailboxer_engine.rb b/db/migrate/20160322134146_add_conversation_optout.mailboxer_engine.rb index a9860bd..90c1dc3 100644 --- a/db/migrate/20160322134146_add_conversation_optout.mailboxer_engine.rb +++ b/db/migrate/20160322134146_add_conversation_optout.mailboxer_engine.rb @@ -1,4 +1,3 @@ -# This migration comes from mailboxer_engine (originally 20131206080416) class AddConversationOptout < ActiveRecord::Migration[4.2] def self.up create_table :mailboxer_conversation_opt_outs do |t| diff --git a/db/migrate/20160322134147_add_missing_indices.mailboxer_engine.rb b/db/migrate/20160322134147_add_missing_indices.mailboxer_engine.rb index 4ee0c7e..9a3a7b4 100644 --- a/db/migrate/20160322134147_add_missing_indices.mailboxer_engine.rb +++ b/db/migrate/20160322134147_add_missing_indices.mailboxer_engine.rb @@ -1,20 +1,12 @@ -# This migration comes from mailboxer_engine (originally 20131206080417) class AddMissingIndices < ActiveRecord::Migration[4.2] def change - # We'll explicitly specify its name, as the auto-generated name is too long and exceeds 63 - # characters limitation. add_index :mailboxer_conversation_opt_outs, [:unsubscriber_id, :unsubscriber_type], name: 'index_mailboxer_conversation_opt_outs_on_unsubscriber_id_type' add_index :mailboxer_conversation_opt_outs, :conversation_id - add_index :mailboxer_notifications, :type add_index :mailboxer_notifications, [:sender_id, :sender_type] - - # We'll explicitly specify its name, as the auto-generated name is too long and exceeds 63 - # characters limitation. add_index :mailboxer_notifications, [:notified_object_id, :notified_object_type], name: 'index_mailboxer_notifications_on_notified_object_id_and_type' - add_index :mailboxer_receipts, [:receiver_id, :receiver_type] end end diff --git a/spec/factories/user.rb b/spec/factories/user.rb index 147a39f..ea4f17c 100644 --- a/spec/factories/user.rb +++ b/spec/factories/user.rb @@ -1,7 +1,7 @@ FactoryBot.define do factory :user do - email {'user@mail.com'} - password { 'password'} - name { 'Name'} + email {'user@mail.com'} + password { 'password'} + name { 'Name'} end end \ No newline at end of file diff --git a/spec/feature/user_can_log_in_feature_spec.rb b/spec/feature/user_can_log_in_feature_spec.rb index 17b8e15..37b7367 100644 --- a/spec/feature/user_can_log_in_feature_spec.rb +++ b/spec/feature/user_can_log_in_feature_spec.rb @@ -1,7 +1,7 @@ require "rails_helper" feature 'User can log in' do - context 'Sign in to account' + context 'Sign in to account' before do create(:user, email: 'user@mail.com', password: '12345678') visit user_session_path @@ -17,16 +17,16 @@ end it 'fills in email and password' do - fill_in "Email", :with => 'user@mail.com' - fill_in "Password", :with => '12345678' - click_on "Log in" - expect(page).to have_content 'Signed in successfully.' + fill_in "Email", :with => 'user@mail.com' + fill_in "Password", :with => '12345678' + click_on "Log in" + expect(page).to have_content 'Signed in successfully.' end it 'If the email format is incorrect' do - fill_in 'Email', :with => '&5aygde' - fill_in 'Password', :with => '12345678' - click_on 'Log in' + fill_in 'Email', :with => '&5aygde' + fill_in 'Password', :with => '12345678' + click_on 'Log in' expect(page).to have_content 'Invalid Email or password.' end @@ -35,15 +35,15 @@ fill_in 'Email', :with => 'user@mail.com' fill_in 'Password', :with => '2234' click_on 'Log in' - expect(page).to have_content 'Invalid Email or password.' + expect(page).to have_content 'Invalid Email or password.' end it 'If the password is too short' do fill_in 'Email', :with => '&5aygde' - fill_in 'Password', :with => '11' + fill_in 'Password', :with => '123' click_on 'Log in' - expect(page).to have_content 'Invalid Email or password.' + expect(page).to have_content 'Invalid Email or password.' end end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 35f019f..726eaf4 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -14,7 +14,7 @@ describe 'Factory' do it 'should have valid factory' do - expect(FactoryBot.create(:user)).to be_valid + expect(FactoryBot.create(:user)).to be_valid end end end \ No newline at end of file diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index ce33d66..aaa615e 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,96 +1,9 @@ -# This file was generated by the `rails generate rspec:install` command. Conventionally, all -# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. -# The generated `.rspec` file contains `--require spec_helper` which will cause -# this file to always be loaded, without a need to explicitly require it in any -# files. -# -# Given that it is always loaded, you are encouraged to keep this file as -# light-weight as possible. Requiring heavyweight dependencies from this file -# will add to the boot time of your test suite on EVERY test run, even for an -# individual file that may not need all of that loaded. Instead, consider making -# a separate helper file that requires the additional dependencies and performs -# the additional setup, and require it from the spec files that actually need -# it. -# -# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration RSpec.configure do |config| - # rspec-expectations config goes here. You can use an alternate - # assertion/expectation library such as wrong or the stdlib/minitest - # assertions if you prefer. config.expect_with :rspec do |expectations| - # This option will default to `true` in RSpec 4. It makes the `description` - # and `failure_message` of custom matchers include text for helper methods - # defined using `chain`, e.g.: - # be_bigger_than(2).and_smaller_than(4).description - # # => "be bigger than 2 and smaller than 4" - # ...rather than: - # # => "be bigger than 2" expectations.include_chain_clauses_in_custom_matcher_descriptions = true end - - # rspec-mocks config goes here. You can use an alternate test double - # library (such as bogus or mocha) by changing the `mock_with` option here. config.mock_with :rspec do |mocks| - # Prevents you from mocking or stubbing a method that does not exist on - # a real object. This is generally recommended, and will default to - # `true` in RSpec 4. mocks.verify_partial_doubles = true end - - # 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 - -# The settings below are suggested to provide a good initial experience -# with RSpec, but feel free to customize to your heart's content. -=begin - # 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 - # file, and it's useful to allow more verbose output when running an - # individual spec file. - if config.files_to_run.one? - # Use the documentation formatter for detailed output, - # unless a formatter has already been configured - # (e.g. via a command-line flag). - config.default_formatter = "doc" - end - - # 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 - - # 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 - # the seed, which is printed after each run. - # --seed 1234 - config.order = :random - - # Seed global randomization in this process using the `--seed` CLI option. - # Setting this allows you to use `--seed` to deterministically reproduce - # test failures related to randomization by passing the same `--seed` value - # as the one that triggered the failure. - Kernel.srand config.seed -=end end diff --git a/spec/user_can_log_in_spec.rb b/spec/user_can_log_in_spec.rb index 649fb62..107e02f 100644 --- a/spec/user_can_log_in_spec.rb +++ b/spec/user_can_log_in_spec.rb @@ -1,15 +1,15 @@ require "rails_helper" feature 'User can log in' do - context 'Sign in to account' - before do - visit root_path + context 'Sign in to account' + before do + visit root_path end -it 'displays a log in button' do - expect(page).to have_content 'Login' - click_on 'Login' -end + it 'displays a log in button' do + expect(page).to have_content 'Login' + click_on 'Login' + end end