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 9ad08ff..587ab06 100644 --- a/Gemfile +++ b/Gemfile @@ -28,22 +28,24 @@ gem 'jbuilder', '~> 2.7' # Reduces boot times through caching; required in config/boot.rb gem 'bootsnap', '>= 1.4.2', require: false # Font-awesome gem -gem "font-awesome-rails" +gem 'font-awesome-rails' # Devise log in and sign up gem 'devise' group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console - gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] + gem 'byebug', platforms: %i[mri mingw x64_mingw] + gem 'rspec-rails', '~> 4.0.0' end group :development do # Access an interactive console on exception pages or by calling 'console' anywhere in the code. - gem 'web-console', '>= 3.3.0' gem 'listen', '~> 3.2' + gem 'web-console', '>= 3.3.0' # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem 'spring' gem 'spring-watcher-listen', '~> 2.0.0' + gem "bullet" end group :test do @@ -55,4 +57,4 @@ group :test do end # Windows does not include zoneinfo files, so bundle the tzinfo-data gem -gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] +gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby] diff --git a/Gemfile.lock b/Gemfile.lock index 2e70fc6..233c722 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -63,6 +63,9 @@ GEM bootsnap (1.4.6) msgpack (~> 1.0) builder (3.2.4) + bullet (6.1.0) + activesupport (>= 3.0.0) + uniform_notifier (~> 1.11) byebug (11.1.3) capybara (3.32.2) addressable @@ -81,6 +84,7 @@ GEM railties (>= 4.1.0) responders warden (~> 1.2.3) + diff-lcs (1.4.2) erubi (1.9.0) ffi (1.13.1) font-awesome-rails (4.7.0.5) @@ -153,6 +157,23 @@ GEM 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) rubyzip (2.3.0) sass-rails (6.0.0) sassc-rails (~> 2.1, >= 2.1.1) @@ -187,6 +208,7 @@ GEM turbolinks-source (5.2.0) tzinfo (1.2.7) thread_safe (~> 0.1) + uniform_notifier (1.13.0) warden (1.2.8) rack (>= 2.0.6) web-console (4.0.3) @@ -214,6 +236,7 @@ PLATFORMS DEPENDENCIES bootsnap (>= 1.4.2) + bullet byebug capybara (>= 2.15) devise @@ -222,6 +245,7 @@ DEPENDENCIES listen (~> 3.2) puma (~> 4.1) rails (~> 6.0.3, >= 6.0.3.1) + rspec-rails (~> 4.0.0) sass-rails (>= 6) selenium-webdriver spring diff --git a/app/assets/images/header image fill.jpg b/app/assets/images/header image fill.jpg new file mode 100644 index 0000000..470874b Binary files /dev/null and b/app/assets/images/header image fill.jpg differ diff --git a/app/assets/images/menu bar.jpg b/app/assets/images/menu bar.jpg new file mode 100644 index 0000000..57ea98b Binary files /dev/null and b/app/assets/images/menu bar.jpg differ diff --git a/app/assets/images/validator error.jpg b/app/assets/images/validator error.jpg new file mode 100644 index 0000000..0659bbc Binary files /dev/null and b/app/assets/images/validator error.jpg differ diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index f877bd2..ea09ce8 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,9 +1,9 @@ class ApplicationController < ActionController::Base - before_action :configure_permitted_parameters, if: :devise_controller? + before_action :configure_permitted_parameters, if: :devise_controller? - protected - - def configure_permitted_parameters - devise_parameter_sanitizer.permit(:sign_up, keys: [:name]) - end + protected + + def configure_permitted_parameters + devise_parameter_sanitizer.permit(:sign_up, keys: [:name]) + end end diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index d97ab50..4954fdc 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -1,58 +1,57 @@ class GroupsController < ApplicationController - before_action :authenticate_user! - - def index - @groups = Group.all - end + before_action :authenticate_user! - def new - @group = Group.new - end + def index + @groups = Group.all + end - def show - @group = current_user.groups.find(params[:id]) - @transaction = @group.transactions - @total = @transaction.sum(:amount) - end + def new + @group = Group.new + end - def create - @group = current_user.groups.new(fields_arr) + def show + @group = current_user.groups.find(params[:id]) + @transaction = @group.transactions + @total = @transaction.sum(:amount) + end - if @group.save + def create + @group = current_user.groups.new(fields_arr) - redirect_to groups_path - else - render :new + if @group.save - end - end + redirect_to groups_path + else + render :new - def edit - @group = current_user.groups.find(params[:id]) end + end - def update - @group = current_user.groups.find(params[:id]) - if @group.update(fields_arr) + def edit + @group = current_user.groups.find(params[:id]) + end + + def update + @group = current_user.groups.find(params[:id]) + if @group.update(fields_arr) - redirect_to groups_path, notice: 'Group was successfully updated.' - else - render :edit - end + redirect_to groups_path, notice: 'Group was successfully updated.' + else + render :edit end - + end - # DELETE /groups/1.json + # DELETE /groups/1.json def destroy @group = current_user.groups.find(params[:id]) @group.destroy - - redirect_back(fallback_location: root_path) + + redirect_back(fallback_location: root_path) end - private + private - def fields_arr - params.require(:group).permit(:name, :icon) - end + def fields_arr + params.require(:group).permit(:name, :icon) + end end diff --git a/app/controllers/static_pages_controller.rb b/app/controllers/static_pages_controller.rb index cf21e40..19c2485 100644 --- a/app/controllers/static_pages_controller.rb +++ b/app/controllers/static_pages_controller.rb @@ -1,17 +1,16 @@ class StaticPagesController < ApplicationController - before_action :authenticate_user! - - def home - end + before_action :authenticate_user! - def external - user = User.find_by(id: current_user.id) - @external_user_transactions = user.transactions.where(group_id: nil).order(created_at: :desc) - @external_total = @external_user_transactions.sum(:amount) - end - - def friends - @users = User.where.not(id: current_user.id) - @expenses = Transaction.where.not(user_id: current_user.id).all - end + def home; end + + def external + user = User.find_by(id: current_user.id) + @external_user_transactions = user.transactions.where(group_id: nil).order(created_at: :desc) + @external_total = @external_user_transactions.sum(:amount) + end + + def friends + @users = User.where.not(id: current_user.id) + @expenses = Transaction.where.not(user_id: current_user.id).all + end end diff --git a/app/controllers/transactions_controller.rb b/app/controllers/transactions_controller.rb index 3feb183..f0dfd88 100644 --- a/app/controllers/transactions_controller.rb +++ b/app/controllers/transactions_controller.rb @@ -1,82 +1,73 @@ class TransactionsController < ApplicationController - before_action :authenticate_user! - - def index - @transaction = current_user.transactions.all - @other_transaction = @transaction.where.not(group_id: nil) - @other_transaction_sorted = @other_transaction.sort_by(&:created_at).reverse - - @total = @other_transaction.sum(:amount) - - end + before_action :authenticate_user! - def new - @transaction = Transaction.new - end + def index + @transaction = current_user.transactions.all + @other_transaction = @transaction.where.not(group_id: nil) + @other_transaction_sorted = @other_transaction.includes([:group]).sort_by(&:created_at).reverse - def create + @total = @other_transaction.sum(:amount) + end - @transaction = current_user.transactions.new(transaction_params) + def new + @transaction = Transaction.new + end - if @transaction.save - - if @transaction.group_id.nil? + def create + @transaction = current_user.transactions.new(transaction_params) - redirect_to external_path, notice: 'Transaction expense was successfully created.' + if @transaction.save - else + if @transaction.group_id.nil? - redirect_to transactions_path, notice: 'Transaction was successfully created.' + redirect_to external_path, notice: 'Transaction expense was successfully created.' + + else - end + redirect_to transactions_path, notice: 'Transaction was successfully created.' - else + end - render :new + else - end - end + render :new - def show - @transaction = Transaction.find(params[:id]) end + end - def edit + def show + @transaction = Transaction.find(params[:id]) + end - @transaction = current_user.transactions.find(params[:id]) - - end + def edit + @transaction = current_user.transactions.find(params[:id]) + end - def update - @transaction = current_user.transactions.find(params[:id]) - if @transaction.update(transaction_params) - - if @transaction.group_id.nil? - - redirect_to external_path, notice: 'external transaction was successfully updated.' - else - redirect_to transactions_path, notice: 'transaction was successfully updated.' - end - - + def update + @transaction = current_user.transactions.find(params[:id]) + if @transaction.update(transaction_params) + + if @transaction.group_id.nil? + + redirect_to external_path, notice: 'external transaction was successfully updated.' else - render :edit + redirect_to transactions_path, notice: 'transaction was successfully updated.' end - end - - def destroy + else + render :edit + end + end + + def destroy @transaction = current_user.transactions.find(params[:id]) @transaction.destroy - redirect_back(fallback_location: root_path) + redirect_back(fallback_location: root_path) + end - - end - - private + private - def transaction_params - params.require(:transaction).permit(:name, :amount, :group_id) - end - + def transaction_params + params.require(:transaction).permit(:name, :amount, :group_id) + end end diff --git a/app/helpers/groups_helper.rb b/app/helpers/groups_helper.rb index 9984171..26162b3 100644 --- a/app/helpers/groups_helper.rb +++ b/app/helpers/groups_helper.rb @@ -1,15 +1,13 @@ module GroupsHelper - def edit_delete_btn(user, group) - + def edit_delete_btn(user, group) if group.user_id == user.id - links = [link_to("edit", edit_group_path(group), class: "btn btn-primary edit_btn"), link_to("delete", group_path(group), class: "btn btn-danger delete_grp_btn", data: {confirm: "Are you sure?"}, method: :delete)] - - content_tag (:span) do - links.collect{ - |l| concat content_tag(:span, l) - } - end - end + links = [link_to('edit', edit_group_path(group), class: 'btn btn-primary edit_btn'), link_to('delete', group_path(group), class: 'btn btn-danger delete_grp_btn', data: { confirm: 'Are you sure?' }, method: :delete)] - end + content_tag(:span) do + links.collect do |l| + concat content_tag(:span, l) + end + end + end + end end diff --git a/app/helpers/transactions_helper.rb b/app/helpers/transactions_helper.rb index 2436500..36098d1 100644 --- a/app/helpers/transactions_helper.rb +++ b/app/helpers/transactions_helper.rb @@ -1,3 +1,2 @@ module TransactionsHelper - end diff --git a/app/models/group.rb b/app/models/group.rb index b4bb4cc..fa97ca8 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -1,7 +1,7 @@ class Group < ApplicationRecord - belongs_to :user - has_many :transactions + belongs_to :user + has_many :transactions - validates :name, presence: true, length: { maximum: 20 } - validates :icon, presence: true -end \ No newline at end of file + validates :name, presence: true, length: { maximum: 20 } + validates :icon, presence: true +end diff --git a/app/models/transaction.rb b/app/models/transaction.rb index 06c58b1..a8927a5 100644 --- a/app/models/transaction.rb +++ b/app/models/transaction.rb @@ -1,12 +1,7 @@ class Transaction < ApplicationRecord - belongs_to :user - belongs_to :group, optional: true + belongs_to :user + belongs_to :group, optional: true - validates :name, presence: true, length: { maximum: 20 } - validates :amount, presence: true, numericality: { less_than_or_equal_to: 100_000, greater_than: 1 } - - - - - -end \ No newline at end of file + validates :name, presence: true, length: { maximum: 20 } + validates :amount, presence: true, numericality: { less_than_or_equal_to: 100_000, greater_than: 1 } +end diff --git a/app/models/user.rb b/app/models/user.rb index de44f3d..f1dad6d 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -2,11 +2,10 @@ class User < ApplicationRecord # Include default devise modules. Others available are: # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable validates :name, presence: true - + devise :database_authenticatable, :registerable, :recoverable, :rememberable, :validatable has_many :transactions has_many :groups - end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 227f466..4cccf34 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -15,6 +15,12 @@
+ <% if flash[:notice] %> +<%= notice %>
+ <% end %> + <% if flash[:alert] %> +<%= alert %>
+ <% end %> <%= yield %> diff --git a/bin/bundle b/bin/bundle index a71368e..b9a7b0f 100755 --- a/bin/bundle +++ b/bin/bundle @@ -8,7 +8,7 @@ # this file is here to facilitate running it. # -require "rubygems" +require 'rubygems' m = Module.new do module_function @@ -18,36 +18,36 @@ m = Module.new do end def env_var_version - ENV["BUNDLER_VERSION"] + ENV['BUNDLER_VERSION'] end def cli_arg_version return unless invoked_as_script? # don't want to hijack other binstubs - return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update` + return unless 'update'.start_with?(ARGV.first || ' ') # must be running `bundle update` + bundler_version = nil update_index = nil ARGV.each_with_index do |a, i| - if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN - bundler_version = a - end + bundler_version = a if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/ - bundler_version = $1 + + bundler_version = Regexp.last_match(1) update_index = i end bundler_version end def gemfile - gemfile = ENV["BUNDLE_GEMFILE"] + gemfile = ENV['BUNDLE_GEMFILE'] return gemfile if gemfile && !gemfile.empty? - File.expand_path("../../Gemfile", __FILE__) + File.expand_path('../Gemfile', __dir__) end def lockfile lockfile = case File.basename(gemfile) - when "gems.rb" then gemfile.sub(/\.rb$/, gemfile) + when 'gems.rb' then gemfile.sub(/\.rb$/, gemfile) else "#{gemfile}.lock" end File.expand_path(lockfile) @@ -55,15 +55,17 @@ m = Module.new do def lockfile_version return unless File.file?(lockfile) + lockfile_contents = File.read(lockfile) return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/ + Regexp.last_match(1) end def bundler_version @bundler_version ||= env_var_version || cli_arg_version || - lockfile_version + lockfile_version end def bundler_requirement @@ -73,28 +75,32 @@ m = Module.new do requirement = bundler_gem_version.approximate_recommendation - return requirement unless Gem::Version.new(Gem::VERSION) < Gem::Version.new("2.7.0") + return requirement unless Gem::Version.new(Gem::VERSION) < Gem::Version.new('2.7.0') - requirement += ".a" if bundler_gem_version.prerelease? + requirement += '.a' if bundler_gem_version.prerelease? requirement end def load_bundler! - ENV["BUNDLE_GEMFILE"] ||= gemfile + ENV['BUNDLE_GEMFILE'] ||= gemfile activate_bundler end def activate_bundler gem_error = activation_error_handling do - gem "bundler", bundler_requirement + gem 'bundler', bundler_requirement end return if gem_error.nil? + require_error = activation_error_handling do - require "bundler/version" + require 'bundler/version' + end + if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION)) + return end - return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION)) + warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`" exit 42 end @@ -109,6 +115,4 @@ end m.load_bundler! -if m.invoked_as_script? - load Gem.bin_path("bundler", "bundle") -end +load Gem.bin_path('bundler', 'bundle') if m.invoked_as_script? diff --git a/bin/rails b/bin/rails index 5badb2f..7a8ff81 100755 --- a/bin/rails +++ b/bin/rails @@ -1,6 +1,6 @@ #!/usr/bin/env ruby begin - load File.expand_path('../spring', __FILE__) + load File.expand_path('spring', __dir__) rescue LoadError => e raise unless e.message.include?('spring') end diff --git a/bin/rake b/bin/rake index d87d5f5..0ba8c48 100755 --- a/bin/rake +++ b/bin/rake @@ -1,6 +1,6 @@ #!/usr/bin/env ruby begin - load File.expand_path('../spring', __FILE__) + load File.expand_path('spring', __dir__) rescue LoadError => e raise unless e.message.include?('spring') end diff --git a/bin/webpack b/bin/webpack index 1031168..d922a7d 100755 --- a/bin/webpack +++ b/bin/webpack @@ -1,18 +1,18 @@ #!/usr/bin/env ruby -ENV["RAILS_ENV"] ||= ENV["RACK_ENV"] || "development" -ENV["NODE_ENV"] ||= "development" +ENV['RAILS_ENV'] ||= ENV['RACK_ENV'] || 'development' +ENV['NODE_ENV'] ||= 'development' -require "pathname" -ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", - Pathname.new(__FILE__).realpath) +require 'pathname' +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', + Pathname.new(__FILE__).realpath) -require "bundler/setup" +require 'bundler/setup' -require "webpacker" -require "webpacker/webpack_runner" +require 'webpacker' +require 'webpacker/webpack_runner' -APP_ROOT = File.expand_path("..", __dir__) +APP_ROOT = File.expand_path('..', __dir__) Dir.chdir(APP_ROOT) do Webpacker::WebpackRunner.run(ARGV) end diff --git a/bin/webpack-dev-server b/bin/webpack-dev-server index dd96627..4e5f40d 100755 --- a/bin/webpack-dev-server +++ b/bin/webpack-dev-server @@ -1,18 +1,18 @@ #!/usr/bin/env ruby -ENV["RAILS_ENV"] ||= ENV["RACK_ENV"] || "development" -ENV["NODE_ENV"] ||= "development" +ENV['RAILS_ENV'] ||= ENV['RACK_ENV'] || 'development' +ENV['NODE_ENV'] ||= 'development' -require "pathname" -ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", - Pathname.new(__FILE__).realpath) +require 'pathname' +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', + Pathname.new(__FILE__).realpath) -require "bundler/setup" +require 'bundler/setup' -require "webpacker" -require "webpacker/dev_server_runner" +require 'webpacker' +require 'webpacker/dev_server_runner' -APP_ROOT = File.expand_path("..", __dir__) +APP_ROOT = File.expand_path('..', __dir__) Dir.chdir(APP_ROOT) do Webpacker::DevServerRunner.run(ARGV) end diff --git a/bin/yarn b/bin/yarn index 460dd56..d3627c3 100755 --- a/bin/yarn +++ b/bin/yarn @@ -1,11 +1,9 @@ #!/usr/bin/env ruby APP_ROOT = File.expand_path('..', __dir__) Dir.chdir(APP_ROOT) do - begin - exec "yarnpkg", *ARGV - rescue Errno::ENOENT - $stderr.puts "Yarn executable was not detected in the system." - $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install" - exit 1 - end + exec 'yarnpkg', *ARGV +rescue Errno::ENOENT + warn 'Yarn executable was not detected in the system.' + warn 'Download Yarn at https://yarnpkg.com/en/docs/install' + exit 1 end diff --git a/config/environments/development.rb b/config/environments/development.rb index ac1a0f3..4d82ff6 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -1,5 +1,13 @@ Rails.application.configure do - # Settings specified here will take precedence over those in config/application.rb. + config.after_initialize do + Bullet.enable = true + Bullet.alert = true + Bullet.bullet_logger = true + Bullet.console = true + # Bullet.growl = true + Bullet.rails_logger = true + Bullet.add_footer = true + end # Settings specified here will take precedence over those in config/application.rb. # devise configuration config.action_mailer.default_url_options = { host: 'localhost', port: 3000 } diff --git a/config/environments/production.rb b/config/environments/production.rb index 9acc507..0e54586 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -51,7 +51,7 @@ config.log_level = :debug # Prepend all log lines with the following tags. - config.log_tags = [ :request_id ] + config.log_tags = [:request_id] # Use a different cache store in production. # config.cache_store = :mem_cache_store @@ -80,7 +80,7 @@ # require 'syslog/logger' # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') - if ENV["RAILS_LOG_TO_STDOUT"].present? + if ENV['RAILS_LOG_TO_STDOUT'].present? logger = ActiveSupport::Logger.new(STDOUT) logger.formatter = config.log_formatter config.logger = ActiveSupport::TaggedLogging.new(logger) diff --git a/config/puma.rb b/config/puma.rb index 5ed4437..fd02934 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -4,20 +4,20 @@ # the maximum value specified for Puma. Default is set to 5 threads for minimum # and maximum; this matches the default thread size of Active Record. # -max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } -min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count } +max_threads_count = ENV.fetch('RAILS_MAX_THREADS') { 5 } +min_threads_count = ENV.fetch('RAILS_MIN_THREADS') { max_threads_count } threads min_threads_count, max_threads_count # Specifies the `port` that Puma will listen on to receive requests; default is 3000. # -port ENV.fetch("PORT") { 3000 } +port ENV.fetch('PORT') { 3000 } # Specifies the `environment` that Puma will run in. # -environment ENV.fetch("RAILS_ENV") { "development" } +environment ENV.fetch('RAILS_ENV') { 'development' } # Specifies the `pidfile` that Puma will use. -pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" } +pidfile ENV.fetch('PIDFILE') { 'tmp/pids/server.pid' } # Specifies the number of `workers` to boot in clustered mode. # Workers are forked web server processes. If using threads and workers together diff --git a/config/routes.rb b/config/routes.rb index e763be9..c40d35d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,11 +1,11 @@ Rails.application.routes.draw do - root "static_pages#home" + root 'static_pages#home' devise_for :users resources :transactions resources :groups get '/external', to: 'static_pages#external' get '/friends', to: 'static_pages#friends' - + # For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html end diff --git a/config/spring.rb b/config/spring.rb index db5bf13..8f6432b 100644 --- a/config/spring.rb +++ b/config/spring.rb @@ -1,6 +1,6 @@ Spring.watch( - ".ruby-version", - ".rbenv-vars", - "tmp/restart.txt", - "tmp/caching-dev.txt" + '.ruby-version', + '.rbenv-vars', + 'tmp/restart.txt', + 'tmp/caching-dev.txt' ) diff --git a/db/migrate/20200617160222_devise_create_users.rb b/db/migrate/20200617160222_devise_create_users.rb index 9ef368e..8b4273e 100644 --- a/db/migrate/20200617160222_devise_create_users.rb +++ b/db/migrate/20200617160222_devise_create_users.rb @@ -4,8 +4,8 @@ class DeviseCreateUsers < ActiveRecord::Migration[6.0] def change create_table :users do |t| ## Database authenticatable - t.string :email, null: false, default: "" - t.string :encrypted_password, null: false, default: "" + t.string :email, null: false, default: '' + t.string :encrypted_password, null: false, default: '' ## Recoverable t.string :reset_password_token @@ -32,7 +32,6 @@ def change # t.string :unlock_token # Only if unlock strategy is :email or :both # t.datetime :locked_at - t.timestamps null: false end diff --git a/db/schema.rb b/db/schema.rb index 5999294..197d316 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,36 +10,34 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2020_06_22_082541) do - - create_table "groups", force: :cascade do |t| - t.string "name" - t.string "icon" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.integer "user_id" +ActiveRecord::Schema.define(version: 20_200_622_082_541) do + create_table 'groups', force: :cascade do |t| + t.string 'name' + t.string 'icon' + t.datetime 'created_at', precision: 6, null: false + t.datetime 'updated_at', precision: 6, null: false + t.integer 'user_id' end - create_table "transactions", force: :cascade do |t| - t.string "name" - t.integer "amount" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.integer "user_id" - t.integer "group_id" + create_table 'transactions', force: :cascade do |t| + t.string 'name' + t.integer 'amount' + t.datetime 'created_at', precision: 6, null: false + t.datetime 'updated_at', precision: 6, null: false + t.integer 'user_id' + t.integer 'group_id' 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" - t.datetime "reset_password_sent_at" - t.datetime "remember_created_at" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, 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 + 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' + t.datetime 'reset_password_sent_at' + t.datetime 'remember_created_at' + t.datetime 'created_at', precision: 6, null: false + t.datetime 'updated_at', precision: 6, 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 - end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb new file mode 100644 index 0000000..6646261 --- /dev/null +++ b/spec/models/user_spec.rb @@ -0,0 +1,19 @@ +RSpec.describe User, type: :model do + context 'validation tests' do + it 'ensures name presence' do + + end + + it 'ensures email presence' do + + end + + it 'ensures password presence' do + + end + + it 'ensures confirm password presence' do + + end + end + end \ No newline at end of file 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 diff --git a/test/application_system_test_case.rb b/test/application_system_test_case.rb index d19212a..23701b4 100644 --- a/test/application_system_test_case.rb +++ b/test/application_system_test_case.rb @@ -1,4 +1,4 @@ -require "test_helper" +require 'test_helper' class ApplicationSystemTestCase < ActionDispatch::SystemTestCase driven_by :selenium, using: :chrome, screen_size: [1400, 1400] diff --git a/test/channels/application_cable/connection_test.rb b/test/channels/application_cable/connection_test.rb index 800405f..d05dbd2 100644 --- a/test/channels/application_cable/connection_test.rb +++ b/test/channels/application_cable/connection_test.rb @@ -1,4 +1,4 @@ -require "test_helper" +require 'test_helper' class ApplicationCable::ConnectionTest < ActionCable::Connection::TestCase # test "connects with cookies" do