From 6913aac7816fe586cd4a9195b272346ef83316dc Mon Sep 17 00:00:00 2001 From: odeane_croney Date: Wed, 24 Jun 2020 15:27:06 +0200 Subject: [PATCH 01/14] 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/14] 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/14] 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/14] 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/14] 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/14] 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/14] 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/14] 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 dfc8403010963f1efb510edc2ffd806ddde7980a Mon Sep 17 00:00:00 2001 From: viktor_sommar Date: Thu, 25 Jun 2020 15:46:27 +0200 Subject: [PATCH 09/14] Adding coverage files to git ignore --- coverage/.last_run.json | 5 ++ coverage/.resultset.json | 168 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 173 insertions(+) create mode 100644 coverage/.last_run.json create mode 100644 coverage/.resultset.json diff --git a/coverage/.last_run.json b/coverage/.last_run.json new file mode 100644 index 0000000..6589a0e --- /dev/null +++ b/coverage/.last_run.json @@ -0,0 +1,5 @@ +{ + "result": { + "covered_percent": 33.71 + } +} diff --git a/coverage/.resultset.json b/coverage/.resultset.json new file mode 100644 index 0000000..40bb069 --- /dev/null +++ b/coverage/.resultset.json @@ -0,0 +1,168 @@ +{ + "RSpec": { + "coverage": { + "/Users/Viktor/CraftAcademy/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, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null + ], + "/Users/Viktor/CraftAcademy/legacy_code_june_2020/app/models/application_record.rb": [ + 1, + 1, + null + ], + "/Users/Viktor/CraftAcademy/legacy_code_june_2020/app/helpers/application_helper.rb": [ + 1, + 1, + 1, + 1, + 0, + 0, + 0, + null, + null, + 1, + 0, + null, + null + ], + "/Users/Viktor/CraftAcademy/legacy_code_june_2020/app/helpers/mailbox_helper.rb": [ + 1, + 1, + null, + null, + 0, + null, + null + ], + "/Users/Viktor/CraftAcademy/legacy_code_june_2020/app/controllers/welcome_controller.rb": [ + 1, + 1, + null, + null + ], + "/Users/Viktor/CraftAcademy/legacy_code_june_2020/app/controllers/application_controller.rb": [ + 1, + 1, + null, + 1, + null, + 1, + null, + 1, + null, + 1, + 0, + null, + null, + 1, + 0, + null, + null, + 1, + null, + 1, + 4, + 4, + null, + null + ], + "/Users/Viktor/CraftAcademy/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/Viktor/CraftAcademy/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": 1593086556 + } +} From 9fb149fe2ba069d7a44a08f92a3869118afb44ad Mon Sep 17 00:00:00 2001 From: Alex_Bellamy Date: Thu, 25 Jun 2020 15:54:39 +0200 Subject: [PATCH 10/14] adding branch sending_message_feature --- README.md | 45 +-------------------------------------------- 1 file changed, 1 insertion(+), 44 deletions(-) diff --git a/README.md b/README.md index f6bc3fd..355e8f5 100644 --- a/README.md +++ b/README.md @@ -1,47 +1,4 @@ ## 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 +... \ No newline at end of file From 434329eaa99c94962a3b808dc7c83b073031544c Mon Sep 17 00:00:00 2001 From: Sima Date: Thu, 25 Jun 2020 16:26:11 +0200 Subject: [PATCH 11/14] edits gemfile --- Gemfile | 2 +- Gemfile.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index 75d1201..37ef214 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 262a37c..125a789 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -276,7 +276,7 @@ DEPENDENCIES web-console (~> 2.0) RUBY VERSION - ruby 2.6.3p62 + ruby 2.5.1p57 BUNDLED WITH 2.1.4 From 55c2f82e8aa26a4e525d709eaa792f81a930a5fc Mon Sep 17 00:00:00 2001 From: viktor_sommar Date: Thu, 25 Jun 2020 16:51:11 +0200 Subject: [PATCH 12/14] Adding tests for happy path message sending. Switching programer in team. --- Gemfile | 2 +- Gemfile.lock | 33 +------- spec/factories/recipients.rb | 5 ++ spec/feature/sending_message_spec.rb | 24 ++++++ spec/feature/user_can_log_in_feature_spec.rb | 5 -- spec/spec_helper.rb | 88 +------------------- 6 files changed, 36 insertions(+), 121 deletions(-) create mode 100644 spec/factories/recipients.rb create mode 100644 spec/feature/sending_message_spec.rb diff --git a/Gemfile b/Gemfile index e6e7194..1ab8e38 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,5 @@ source 'https://rubygems.org' -ruby '2.6.3' +ruby '2.5.1' gem 'bootstrap-sass' gem 'chosen-rails' diff --git a/Gemfile.lock b/Gemfile.lock index 067a1fe..f933d25 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -44,11 +44,7 @@ GEM tzinfo (~> 1.1) addressable (2.7.0) public_suffix (>= 2.0.2, < 5.0) -<<<<<<< HEAD arel (9.0.0) -======= - arel (8.0.0) ->>>>>>> 9fb149fe2ba069d7a44a08f92a3869118afb44ad autoprefixer-rails (9.8.4) execjs bcrypt (3.1.13) @@ -79,11 +75,7 @@ GEM railties (>= 3.0) sassc-rails (>= 2.1.2) coderay (1.1.3) -<<<<<<< HEAD coffee-rails (5.0.0) -======= - coffee-rails (4.2.2) ->>>>>>> 9fb149fe2ba069d7a44a08f92a3869118afb44ad coffee-script (>= 2.2.0) railties (>= 5.2.0) coffee-script (2.4.1) @@ -91,15 +83,12 @@ GEM execjs coffee-script-source (1.12.2) concurrent-ruby (1.1.6) -<<<<<<< HEAD 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) -======= ->>>>>>> 9fb149fe2ba069d7a44a08f92a3869118afb44ad crass (1.0.6) debug_inspector (0.0.3) devise (4.7.2) @@ -109,10 +98,7 @@ GEM responders warden (~> 1.2.3) diff-lcs (1.4.2) -<<<<<<< HEAD docile (1.3.2) -======= ->>>>>>> 9fb149fe2ba069d7a44a08f92a3869118afb44ad erubi (1.9.0) execjs (2.7.0) factory_bot (6.0.2) @@ -134,10 +120,7 @@ GEM rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) -<<<<<<< HEAD json (2.3.0) -======= ->>>>>>> 9fb149fe2ba069d7a44a08f92a3869118afb44ad loofah (2.2.3) crass (~> 1.0.2) nokogiri (>= 1.5.9) @@ -146,11 +129,8 @@ GEM mailboxer (0.15.1) carrierwave (>= 0.5.8) rails (>= 5.0.0) -<<<<<<< HEAD marcel (0.3.3) mimemagic (~> 0.3.2) -======= ->>>>>>> 9fb149fe2ba069d7a44a08f92a3869118afb44ad method_source (1.0.0) mimemagic (0.3.5) mini_magick (4.10.1) @@ -250,14 +230,11 @@ GEM tilt shoulda-matchers (4.3.0) activesupport (>= 4.2.0) -<<<<<<< HEAD simplecov (0.16.1) docile (~> 1.1) json (>= 1.8, < 3) simplecov-html (~> 0.10.0) simplecov-html (0.10.2) -======= ->>>>>>> 9fb149fe2ba069d7a44a08f92a3869118afb44ad spring (2.1.0) sprockets (3.7.2) concurrent-ruby (~> 1.0) @@ -266,7 +243,6 @@ GEM actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) -<<<<<<< HEAD sync (0.5.0) term-ansicolor (1.7.1) tins (~> 1.0) @@ -275,11 +251,6 @@ GEM tilt (2.0.10) tins (1.25.0) sync -======= - thor (1.0.1) - thread_safe (0.3.6) - tilt (2.0.10) ->>>>>>> 9fb149fe2ba069d7a44a08f92a3869118afb44ad turbolinks (5.2.1) turbolinks-source (~> 5.2) turbolinks-source (5.2.0) @@ -330,7 +301,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/spec/factories/recipients.rb b/spec/factories/recipients.rb new file mode 100644 index 0000000..c2897ef --- /dev/null +++ b/spec/factories/recipients.rb @@ -0,0 +1,5 @@ +FactoryBot.define do + factory :recipients do + name { 'Name'} + end +end \ No newline at end of file diff --git a/spec/feature/sending_message_spec.rb b/spec/feature/sending_message_spec.rb new file mode 100644 index 0000000..b94732a --- /dev/null +++ b/spec/feature/sending_message_spec.rb @@ -0,0 +1,24 @@ +require "rails_helper" + +feature 'User can send a message' do + context 'Compose a message' + before do + create(:user, email: 'user@mail.com', password: '12345678') + visit root_path + click_on 'Login' + fill_in "Email", :with => "user@mail.com" + fill_in "Password", :with => "12345678" + click_on "Log in" + click_on "Inbox" + click_on "Compose" + create(:recipients, name: 'Alex') + select "Alex", :from => "Recipients" + fill_in "Subject", :with => "Test" + fill_in "Message", :with => "This is a test message." + click_on "Send Message" + end + + it 'user can send a message' do + expect(page).to have_content 'Your message was successfully sent!' + 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 61f30ea..d424f76 100644 --- a/spec/feature/user_can_log_in_feature_spec.rb +++ b/spec/feature/user_can_log_in_feature_spec.rb @@ -25,9 +25,4 @@ end -# it 'redirect user to ladning page' do -# expect(page).to have_content 'Signed in successfully.' -# end - -# end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index ce33d66..3cd93ed 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,96 +1,16 @@ -# 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 c8126fd2f89ce1b8f99e5a1aa8ac284f1ad0a000 Mon Sep 17 00:00:00 2001 From: Sima Date: Thu, 25 Jun 2020 18:21:50 +0200 Subject: [PATCH 13/14] writes test for sending message, add factory bot for recipient, makes model and controller for recipient --- Gemfile | 5 ----- Gemfile.lock | 2 +- app/controllers/recipients_controller.rb | 5 +++++ app/helpers/mailbox_helper.rb | 4 ++-- app/models/recipient.rb | 3 +++ app/views/recipients/index.html.erb | 2 ++ config/routes.rb | 1 + db/migrate/20200625153035_create_recipients.rb | 9 +++++++++ db/schema.rb | 8 +++++++- spec/factories/recipients.rb | 2 +- spec/feature/sending_message_spec.rb | 6 +++--- spec/models/recipient_spec.rb | 16 ++++++++++++++++ spec/requests/recipients_request_spec.rb | 12 ++++++++++++ 13 files changed, 62 insertions(+), 13 deletions(-) create mode 100644 app/controllers/recipients_controller.rb create mode 100644 app/models/recipient.rb create mode 100644 app/views/recipients/index.html.erb create mode 100644 db/migrate/20200625153035_create_recipients.rb create mode 100644 spec/models/recipient_spec.rb create mode 100644 spec/requests/recipients_request_spec.rb diff --git a/Gemfile b/Gemfile index 5582fb6..1ab8e38 100644 --- a/Gemfile +++ b/Gemfile @@ -1,10 +1,5 @@ source 'https://rubygems.org' ruby '2.5.1' -<<<<<<< HEAD - -gem 'rails', '5.1.5' -======= ->>>>>>> 55c2f82e8aa26a4e525d709eaa792f81a930a5fc gem 'bootstrap-sass' gem 'chosen-rails' diff --git a/Gemfile.lock b/Gemfile.lock index f933d25..24d124e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -304,4 +304,4 @@ RUBY VERSION ruby 2.5.1p57 BUNDLED WITH - 1.17.3 + 2.1.4 diff --git a/app/controllers/recipients_controller.rb b/app/controllers/recipients_controller.rb new file mode 100644 index 0000000..a516921 --- /dev/null +++ b/app/controllers/recipients_controller.rb @@ -0,0 +1,5 @@ +class RecipientsController < ApplicationController + def index + @recipient = Recipient.all + end +end diff --git a/app/helpers/mailbox_helper.rb b/app/helpers/mailbox_helper.rb index 6dedc7e..8a402ca 100644 --- a/app/helpers/mailbox_helper.rb +++ b/app/helpers/mailbox_helper.rb @@ -1,6 +1,6 @@ module MailboxHelper - def unread_messages_count - # how to get the number of unread messages for the current user + def unread_s_count + # how to get the number of unread s for the current user # using mailboxer mailbox.inbox(unread: true).count end diff --git a/app/models/recipient.rb b/app/models/recipient.rb new file mode 100644 index 0000000..cf2634e --- /dev/null +++ b/app/models/recipient.rb @@ -0,0 +1,3 @@ +class Recipient < ApplicationRecord + validates_presence_of :name +end diff --git a/app/views/recipients/index.html.erb b/app/views/recipients/index.html.erb new file mode 100644 index 0000000..73c2093 --- /dev/null +++ b/app/views/recipients/index.html.erb @@ -0,0 +1,2 @@ +

Recipients#index

+

Find me in app/views/recipients/index.html.erb

diff --git a/config/routes.rb b/config/routes.rb index 1abf899..939541b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,6 @@ Rails.application.routes.draw do + get 'recipients/index' devise_for :users get 'welcome/index' diff --git a/db/migrate/20200625153035_create_recipients.rb b/db/migrate/20200625153035_create_recipients.rb new file mode 100644 index 0000000..a7a3116 --- /dev/null +++ b/db/migrate/20200625153035_create_recipients.rb @@ -0,0 +1,9 @@ +class CreateRecipients < ActiveRecord::Migration[5.2] + def change + create_table :recipients do |t| + t.string :name + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 7b69782..4195b59 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2016_03_22_134147) do +ActiveRecord::Schema.define(version: 2020_06_25_153035) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -65,6 +65,12 @@ t.index ["receiver_id", "receiver_type"], name: "index_mailboxer_receipts_on_receiver_id_and_receiver_type" end + create_table "recipients", force: :cascade do |t| + t.string "name" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + create_table "users", id: :serial, force: :cascade do |t| t.string "email", default: "", null: false t.string "encrypted_password", default: "", null: false diff --git a/spec/factories/recipients.rb b/spec/factories/recipients.rb index c2897ef..8608a7f 100644 --- a/spec/factories/recipients.rb +++ b/spec/factories/recipients.rb @@ -1,5 +1,5 @@ FactoryBot.define do - factory :recipients do + factory :recipient do name { 'Name'} end end \ No newline at end of file diff --git a/spec/feature/sending_message_spec.rb b/spec/feature/sending_message_spec.rb index b94732a..da10d25 100644 --- a/spec/feature/sending_message_spec.rb +++ b/spec/feature/sending_message_spec.rb @@ -3,7 +3,7 @@ feature 'User can send a message' do context 'Compose a message' before do - create(:user, email: 'user@mail.com', password: '12345678') + create(:user, email: 'user@mail.com', password: '12345678', name: "Simon") visit root_path click_on 'Login' fill_in "Email", :with => "user@mail.com" @@ -11,8 +11,8 @@ click_on "Log in" click_on "Inbox" click_on "Compose" - create(:recipients, name: 'Alex') - select "Alex", :from => "Recipients" + #create(:user, name: 'Simon') + select "Simon", :from => "Recipients" fill_in "Subject", :with => "Test" fill_in "Message", :with => "This is a test message." click_on "Send Message" diff --git a/spec/models/recipient_spec.rb b/spec/models/recipient_spec.rb new file mode 100644 index 0000000..3fc1d1a --- /dev/null +++ b/spec/models/recipient_spec.rb @@ -0,0 +1,16 @@ + +RSpec.describe Recipient, type: :model do + describe 'db table' do + it {is_expected.to have_db_column :name} + end + + describe 'validations' do + it {is_expected.to validate_presence_of :name} + end + + describe 'Factory' do + it 'should have valid factory' do + expect(FactoryBot.create(:recipient)).to be_valid + end + end +end diff --git a/spec/requests/recipients_request_spec.rb b/spec/requests/recipients_request_spec.rb new file mode 100644 index 0000000..4d3f27b --- /dev/null +++ b/spec/requests/recipients_request_spec.rb @@ -0,0 +1,12 @@ +require 'rails_helper' + +RSpec.describe "Recipients", type: :request do + + describe "GET /index" do + it "returns http success" do + get "/recipients/index" + expect(response).to have_http_status(:success) + end + end + +end From 93d66f337fbceb6f3221ffd5b2246a2354078972 Mon Sep 17 00:00:00 2001 From: Alex_Bellamy Date: Sat, 27 Jun 2020 17:51:13 +0200 Subject: [PATCH 14/14] adding user can log out spec, tests successfully passes --- admin@admin.com | 0 password | 0 spec/feature/user_can_log_out_spec.rb | 16 ++++++++++++++++ spec/rails_helper.rb | 1 + 4 files changed, 17 insertions(+) create mode 100644 admin@admin.com create mode 100644 password create mode 100644 spec/feature/user_can_log_out_spec.rb diff --git a/admin@admin.com b/admin@admin.com new file mode 100644 index 0000000..e69de29 diff --git a/password b/password new file mode 100644 index 0000000..e69de29 diff --git a/spec/feature/user_can_log_out_spec.rb b/spec/feature/user_can_log_out_spec.rb new file mode 100644 index 0000000..e7d4fc0 --- /dev/null +++ b/spec/feature/user_can_log_out_spec.rb @@ -0,0 +1,16 @@ +require "rails_helper" + +feature 'User can log out' do + context 'Sign out of account' do + let(:user) { create(:user, name: 'Peter', password: '23456789', email: 'abc@mail.com') } + before do + login_as(user, scope: :user) + visit root_path + click_on 'Logout' + end + + it 'Displays a successful signout message' do + expect(page).to have_content 'Signed out successfully.' + end +end +end \ No newline at end of file diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 600937f..a3980bf 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -16,6 +16,7 @@ config.infer_spec_type_from_file_location! config.filter_rails_from_backtrace! config.include FactoryBot::Syntax::Methods + config.include Warden::Test::Helpers Shoulda::Matchers.configure do |config| config.integrate do |with|