From 425718d34ffe5ff8ace6fef5066dd4e1eac065b9 Mon Sep 17 00:00:00 2001 From: Anthony Bronkema Date: Sun, 13 Oct 2019 14:55:21 -0400 Subject: [PATCH 1/2] adds codeclimate badges --- README.md | 46 +++++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 092b5ac..ec5db61 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ # README + [![Build Status](https://travis-ci.org/rubyforgood/babywearing.svg?branch=master)](https://travis-ci.org/rubyforgood/babywearing) +[![Maintainability](https://api.codeclimate.com/v1/badges/ac4e12c6fda4398c9dd2/maintainability)](https://codeclimate.com/github/rubyforgood/babywearing/maintainability) +[![Test Coverage](https://api.codeclimate.com/v1/badges/ac4e12c6fda4398c9dd2/test_coverage)](https://codeclimate.com/github/rubyforgood/babywearing/test_coverage) # Babywearing @@ -34,38 +37,38 @@ effective and provides the same capabilities as their existing system with an emphasis on tailoring the experience to better suit the needs of this organization. The primary set of features this project will focus on includes: -* Managing inventory of hundreds of carriers across multiple locations +- Managing inventory of hundreds of carriers across multiple locations -* Allowing Members to create or update their account information +- Allowing Members to create or update their account information -* Using volunteers to check in and check out carriers from inventory +- Using volunteers to check in and check out carriers from inventory -* Recording (not processing) financial transactions such as late fees and +- Recording (not processing) financial transactions such as late fees and membership dues - * Simplifying the process to waive late fees + - Simplifying the process to waive late fees -* Improved notification of activities to members including: +- Improved notification of activities to members including: - * Due date reminders for checked out items + - Due date reminders for checked out items - * Updates or changes to events and item due dates + - Updates or changes to events and item due dates -* Signing agreements and waivers to participate in the organization +- Signing agreements and waivers to participate in the organization Some additional stretch goals include: -* Transferring inventory between locations (and tracking that history) +- Transferring inventory between locations (and tracking that history) -* Event attendance sign in +- Event attendance sign in - * Fast sign in for existing Members + - Fast sign in for existing Members - * Easy transition to create new accounts for new Members + - Easy transition to create new accounts for new Members -* Assign location preferences to Members +- Assign location preferences to Members -* Opt-in text message for meeting and check out reminders using Twilio +- Opt-in text message for meeting and check out reminders using Twilio ### Technical considerations @@ -79,22 +82,27 @@ device available in those moments. ## Development ### Ruby Version + This app uses Ruby version 2.6.3 and Rails version 5.2.3 ### Setup -* Clone the repo -* run `bundle install` -* run `rails db:create` -* run `rake:db:migrate` + +- Clone the repo +- run `bundle install` +- run `rails db:create` +- run `rake:db:migrate` ### Seed the database + From the root of the app, run bundle exec rails `db:seed`. This will create some initial data to use while testing the app and developing new features. ### Install ImageMagick + ImageMagick is needed for the pages with images of carriers run`brew install imagemagick` ### Start the app + Run `rails s` and browse to http://localhost:3000/ ## How to Contribute From 34716b2f0936d72f83285a02c4efa4c005c9ad59 Mon Sep 17 00:00:00 2001 From: Anthony Bronkema Date: Sun, 13 Oct 2019 15:09:04 -0400 Subject: [PATCH 2/2] resolve conflicts --- .github/CODEOWNERS | 2 +- Gemfile | 2 +- Gemfile.lock | 5 +- README.md | 12 +- app/assets/stylesheets/application.scss | 85 ++++++++---- app/channels/application_cable/channel.rb | 2 + app/channels/application_cable/connection.rb | 2 + app/controllers/agreements_controller.rb | 2 + app/controllers/application_controller.rb | 2 + app/controllers/carriers_controller.rb | 2 + app/controllers/categories_controller.rb | 4 +- app/controllers/fee_types_controller.rb | 2 + app/controllers/home_controller.rb | 2 + app/controllers/locations_controller.rb | 2 + .../membership_types_controller.rb | 2 + app/controllers/organizations_controller.rb | 2 + app/controllers/photos_controller.rb | 2 + .../signed_agreements_controller.rb | 2 + .../users/registrations_controller.rb | 2 + app/controllers/users_controller.rb | 2 + app/helpers/agreements_helper.rb | 2 + app/helpers/application_helper.rb | 10 +- app/helpers/fee_types_helper.rb | 2 + app/helpers/locations_helper.rb | 2 + app/helpers/membership_types_helper.rb | 2 + app/helpers/users_helper.rb | 2 + app/jobs/application_job.rb | 2 + app/mailers/application_mailer.rb | 2 + app/mailers/custom_mailer.rb | 4 +- app/mailers/welcome_mailer.rb | 4 +- app/models/agreement.rb | 2 + app/models/application_record.rb | 2 + app/models/carrier.rb | 2 + app/models/cart.rb | 2 + app/models/category.rb | 2 + app/models/fee_type.rb | 2 + app/models/loan.rb | 2 + app/models/location.rb | 2 + app/models/membership_type.rb | 2 + app/models/organization.rb | 2 + app/models/role.rb | 18 +-- app/models/signed_agreement.rb | 2 + app/models/user.rb | 2 + app/policies/application_policy.rb | 2 + app/policies/user_policy.rb | 4 +- app/views/agreements/_form.html.erb | 12 +- app/views/agreements/edit.html.erb | 14 +- app/views/agreements/index.html.erb | 58 +++++---- app/views/agreements/new.html.erb | 12 +- app/views/carriers/_carrier_form.html.erb | 122 +++++++++--------- app/views/carriers/edit.html.erb | 19 +-- app/views/carriers/index.html.erb | 27 +++- app/views/carriers/new.html.erb | 17 +-- app/views/categories/_form.html.erb | 16 +-- app/views/categories/edit.html.erb | 13 +- app/views/categories/index.html.erb | 59 ++++----- app/views/categories/new.html.erb | 12 +- app/views/categories/show.html.erb | 13 ++ app/views/fee_types/_form.html.erb | 12 +- app/views/fee_types/edit.html.erb | 13 +- app/views/fee_types/index.html.erb | 55 ++++---- app/views/fee_types/new.html.erb | 12 +- app/views/layouts/_header.html.erb | 33 +++++ app/views/layouts/_sidebar.html.erb | 28 ++++ app/views/layouts/application.html.erb | 87 ++----------- app/views/locations/_form.html.erb | 17 ++- app/views/locations/edit.html.erb | 8 +- app/views/locations/index.html.erb | 49 +++---- app/views/locations/new.html.erb | 9 +- app/views/membership_types/_form.html.erb | 24 ++-- app/views/membership_types/edit.html.erb | 14 +- app/views/membership_types/index.html.erb | 67 +++++----- app/views/membership_types/new.html.erb | 12 +- app/views/organizations/_form.html.erb | 12 +- app/views/organizations/edit.html.erb | 14 +- app/views/organizations/index.html.erb | 55 ++++---- app/views/organizations/new.html.erb | 12 +- app/views/organizations/show.html.erb | 20 --- app/views/shared/_flash.html.erb | 5 + bin/setup | 11 +- config/routes.rb | 2 +- spec/features/agreement_spec.rb | 10 +- spec/features/carrier_spec.rb | 2 + spec/features/category_spec.rb | 29 ++++- spec/features/fee_type_spec.rb | 10 +- spec/features/location_spec.rb | 20 +-- spec/features/membership_type_spec.rb | 8 +- spec/features/organization_spec.rb | 10 +- spec/features/signed_agreement_spec.rb | 4 +- spec/features/user_registration_spec.rb | 2 + spec/features/user_spec.rb | 2 + spec/fixtures/carriers.yml | 2 + spec/models/agreement_spec.rb | 4 +- spec/models/carrier_spec.rb | 2 + spec/models/cart_spec.rb | 2 + spec/models/category_spec.rb | 2 + spec/models/loan_spec.rb | 2 + spec/models/organization_spec.rb | 2 + spec/models/role_spec.rb | 4 +- spec/models/signed_agreement_spec.rb | 4 +- spec/models/user_spec.rb | 4 +- spec/policies/user_policy.spec.rb | 2 + spec/rails_helper.rb | 2 + spec/spec_helper.rb | 2 + spec/support/devise.rb | 4 +- spec/support/factory_bot.rb | 2 + spec/support/location.rb | 4 +- 107 files changed, 765 insertions(+), 559 deletions(-) create mode 100644 app/views/layouts/_header.html.erb create mode 100644 app/views/layouts/_sidebar.html.erb create mode 100644 app/views/shared/_flash.html.erb diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 8ddbd80..5e52af2 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1 +1 @@ -* @cattywampus @abronkema @yarmiganosca +* @cattywampus @abronkema @yarmiganosca @pollygee diff --git a/Gemfile b/Gemfile index db3b894..237c4be 100644 --- a/Gemfile +++ b/Gemfile @@ -8,7 +8,7 @@ gem 'rails', '~> 5.2.3' # Use postgresql as the database for Active Record gem 'pg', '>= 0.18', '< 2.0' # Use Puma as the app server -gem 'puma', '~> 3.11' +gem 'puma', '~> 4.1' # Use SCSS for stylesheets gem 'sassc-rails', '~> 2.1' # Use Uglifier as compressor for JavaScript assets diff --git a/Gemfile.lock b/Gemfile.lock index de057c0..3017d03 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -148,7 +148,8 @@ GEM byebug (~> 11.0) pry (~> 0.10) public_suffix (3.1.1) - puma (3.12.1) + puma (4.2.1) + nio4r (~> 2.0) pundit (2.0.1) activesupport (>= 3.0.0) rack (2.0.7) @@ -265,7 +266,7 @@ DEPENDENCIES mini_magick (~> 4.8) pg (>= 0.18, < 2.0) pry-byebug - puma (~> 3.11) + puma (~> 4.1) pundit rails (~> 5.2.3) rolify diff --git a/README.md b/README.md index ec5db61..f71b29c 100644 --- a/README.md +++ b/README.md @@ -83,23 +83,17 @@ device available in those moments. ### Ruby Version -This app uses Ruby version 2.6.3 and Rails version 5.2.3 +This app uses Ruby version 2.6.3, Rails version 5.2.3, and PostgreSQL 11.4 ### Setup - Clone the repo -- run `bundle install` -- run `rails db:create` -- run `rake:db:migrate` - -### Seed the database - -From the root of the app, run bundle exec rails `db:seed`. This will create some initial data to use while testing the app and developing new features. +- run `bin/setup` ### Install ImageMagick ImageMagick is needed for the pages with images of carriers -run`brew install imagemagick` +run `brew install imagemagick` ### Start the app diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 17cde93..3cc7435 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -21,10 +21,10 @@ # Then, remove all the *= require and *= require_tree statements from the Sass file. Instead, use @import to import Sass files. # Do not use *= require in Sass or your other stylesheets will not be able to access the Bootstrap mixins and variables. */ -$bw-color-purple: #A36EB9; -$bw-color-dark-purple: #7A7289; -$bw-color-slate: #84A5C6; -$bw-color-blue: #73C3FE; +$bw-color-purple: #a36eb9; +$bw-color-dark-purple: #7a7289; +$bw-color-slate: #84a5c6; +$bw-color-blue: #73c3fe; $bw-color-darkest-purple: #808808; // Custom bootstrap variables must be set or imported *before* bootstrap. @@ -33,31 +33,70 @@ $navbar-brand-padding-y: 8px; @import "bootstrap"; -.navbar-brand img {height: 84px} -.nav-icon img {width: 50px} -.nav-icon {height: 100px; width: 100px; font-size: 12px} -.nav-link {text-align: center} -.background-purple {background-color: $bw-color-purple} -.background-dark-purple {background-color: $bw-color-dark-purple} -.background-slate {background-color: $bw-color-slate} -.background-blue {background-color: $bw-color-blue} -.background-darkest-purple {background-color: $bw-color-darkest-purple} -.navbar-text .pull-right {position: fixed} +.navbar-brand img { + height: 84px; +} +.nav-icon { + height: 100px; + width: 100px; + font-size: 12px; +} +.nav-link { + text-align: center; +} +.background-purple { + background-color: $bw-color-purple; +} +.background-dark-purple { + background-color: $bw-color-dark-purple; +} +.background-slate { + background-color: $bw-color-slate; +} +.background-blue { + background-color: $bw-color-blue; +} +.background-darkest-purple { + background-color: $bw-color-darkest-purple; +} +.navbar-text .pull-right { + position: fixed; +} + +.nav-item { + display: flex; + align-items: center; +} +.nav-first img { + width: 6.4em; +} +.nav-second img { + width: 5.5em; +} +.nav-third { + width: 9em; + img { + width: 5.1em; + } +} +.nav-fourth img { + width: 6.2em; +} #outer-container { - display: table; - width: 100%; - height: 100%; + display: table; + width: 100%; + height: 100%; } #sidebar { - display: table-cell; - width: 15%; - vertical-align: top; + display: table-cell; + width: 15%; + vertical-align: top; } #content { - display: table-cell; - width: 85%; - vertical-align: top; + display: table-cell; + width: 85%; + vertical-align: top; } diff --git a/app/channels/application_cable/channel.rb b/app/channels/application_cable/channel.rb index d672697..9aec230 100644 --- a/app/channels/application_cable/channel.rb +++ b/app/channels/application_cable/channel.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module ApplicationCable class Channel < ActionCable::Channel::Base end diff --git a/app/channels/application_cable/connection.rb b/app/channels/application_cable/connection.rb index 0ff5442..8d6c2a1 100644 --- a/app/channels/application_cable/connection.rb +++ b/app/channels/application_cable/connection.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module ApplicationCable class Connection < ActionCable::Connection::Base end diff --git a/app/controllers/agreements_controller.rb b/app/controllers/agreements_controller.rb index df64471..570484f 100644 --- a/app/controllers/agreements_controller.rb +++ b/app/controllers/agreements_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AgreementsController < ApplicationController before_action :set_agreement, only: [:show, :edit, :update, :destroy] diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 0bc3ca9..d4c2c1e 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ApplicationController < ActionController::Base include Pundit rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized diff --git a/app/controllers/carriers_controller.rb b/app/controllers/carriers_controller.rb index 1ac6ade..f22c6fb 100644 --- a/app/controllers/carriers_controller.rb +++ b/app/controllers/carriers_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CarriersController < ApplicationController before_action :set_carrier, only: [:show, :edit, :update] diff --git a/app/controllers/categories_controller.rb b/app/controllers/categories_controller.rb index 6f8c4ec..ebf9def 100644 --- a/app/controllers/categories_controller.rb +++ b/app/controllers/categories_controller.rb @@ -1,10 +1,12 @@ +# frozen_string_literal: true + class CategoriesController < ApplicationController before_action :set_category, only: [:show, :edit, :update, :destroy] # GET /categories # GET /categories.json def index - @categories = Category.all + @categories = Category.includes(:parent) end # GET /categories/1 diff --git a/app/controllers/fee_types_controller.rb b/app/controllers/fee_types_controller.rb index 6761509..f676e8f 100644 --- a/app/controllers/fee_types_controller.rb +++ b/app/controllers/fee_types_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class FeeTypesController < ApplicationController before_action :set_fee_type, only: [:show, :edit, :update, :destroy] diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 95f2992..5463418 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class HomeController < ApplicationController def index end diff --git a/app/controllers/locations_controller.rb b/app/controllers/locations_controller.rb index 43069f2..ba2c800 100644 --- a/app/controllers/locations_controller.rb +++ b/app/controllers/locations_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class LocationsController < ApplicationController before_action :set_location, only: [:show, :edit, :update] diff --git a/app/controllers/membership_types_controller.rb b/app/controllers/membership_types_controller.rb index d599835..62bff48 100644 --- a/app/controllers/membership_types_controller.rb +++ b/app/controllers/membership_types_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class MembershipTypesController < ApplicationController before_action :set_membership_type, only: [:show, :edit, :update, :destroy] diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index 7ff2619..76c5c6e 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class OrganizationsController < ApplicationController before_action :set_organization, only: [:edit, :update, :destroy] diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index 4c7cdca..9837928 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class PhotosController < ApplicationController def destroy @photo = ActiveStorage::Attachment.find(params[:id]) diff --git a/app/controllers/signed_agreements_controller.rb b/app/controllers/signed_agreements_controller.rb index 9de8b81..ef12333 100644 --- a/app/controllers/signed_agreements_controller.rb +++ b/app/controllers/signed_agreements_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class SignedAgreementsController < ApplicationController before_action :set_agreement, only: [:new, :show] diff --git a/app/controllers/users/registrations_controller.rb b/app/controllers/users/registrations_controller.rb index cb994ff..24c7b9a 100644 --- a/app/controllers/users/registrations_controller.rb +++ b/app/controllers/users/registrations_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Users::RegistrationsController < Devise::RegistrationsController private diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 1d42659..e6c3354 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class UsersController < ApplicationController attr_reader :user diff --git a/app/helpers/agreements_helper.rb b/app/helpers/agreements_helper.rb index 57a531e..4defdc9 100644 --- a/app/helpers/agreements_helper.rb +++ b/app/helpers/agreements_helper.rb @@ -1,2 +1,4 @@ +# frozen_string_literal: true + module AgreementsHelper end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 51e35c4..a38576e 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,10 +1,12 @@ +# frozen_string_literal: true + module ApplicationHelper def flash_class(level) case level.to_sym - when :notice then "alert alert-info" - when :success then "alert alert-success" - when :error then "alert alert-error" - when :alert then "alert alert-error" + when :notice then "alert alert-info" + when :success then "alert alert-success" + when :error then "alert alert-error" + when :alert then "alert alert-error" end end end diff --git a/app/helpers/fee_types_helper.rb b/app/helpers/fee_types_helper.rb index 471c545..2f57d15 100644 --- a/app/helpers/fee_types_helper.rb +++ b/app/helpers/fee_types_helper.rb @@ -1,2 +1,4 @@ +# frozen_string_literal: true + module FeeTypesHelper end diff --git a/app/helpers/locations_helper.rb b/app/helpers/locations_helper.rb index 46f9428..2dbfb0f 100644 --- a/app/helpers/locations_helper.rb +++ b/app/helpers/locations_helper.rb @@ -1,2 +1,4 @@ +# frozen_string_literal: true + module LocationsHelper end diff --git a/app/helpers/membership_types_helper.rb b/app/helpers/membership_types_helper.rb index 0ee3357..867db3b 100644 --- a/app/helpers/membership_types_helper.rb +++ b/app/helpers/membership_types_helper.rb @@ -1,2 +1,4 @@ +# frozen_string_literal: true + module MembershipTypesHelper end diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index 2310a24..4dc909e 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -1,2 +1,4 @@ +# frozen_string_literal: true + module UsersHelper end diff --git a/app/jobs/application_job.rb b/app/jobs/application_job.rb index a009ace..d92ffdd 100644 --- a/app/jobs/application_job.rb +++ b/app/jobs/application_job.rb @@ -1,2 +1,4 @@ +# frozen_string_literal: true + class ApplicationJob < ActiveJob::Base end diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb index 286b223..d84cb6e 100644 --- a/app/mailers/application_mailer.rb +++ b/app/mailers/application_mailer.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ApplicationMailer < ActionMailer::Base default from: 'from@example.com' layout 'mailer' diff --git a/app/mailers/custom_mailer.rb b/app/mailers/custom_mailer.rb index 38916ad..c61557c 100644 --- a/app/mailers/custom_mailer.rb +++ b/app/mailers/custom_mailer.rb @@ -1,5 +1,7 @@ +# frozen_string_literal: true + class CustomMailer < Devise::Mailer helper :application # gives access to all helpers defined within `application_helper`. include Devise::Controllers::UrlHelpers # Optional. eg. `confirmation_url` default template_path: 'devise/mailer' # to make sure that your mailer uses the devise views -end \ No newline at end of file +end diff --git a/app/mailers/welcome_mailer.rb b/app/mailers/welcome_mailer.rb index bde2105..2b51edf 100644 --- a/app/mailers/welcome_mailer.rb +++ b/app/mailers/welcome_mailer.rb @@ -1,6 +1,8 @@ +# frozen_string_literal: true + class WelcomeMailer < CustomMailer def welcome_email(user) @user = user mail(to: @user.email, subject: 'Babywearing Account Registration') end - end \ No newline at end of file + end diff --git a/app/models/agreement.rb b/app/models/agreement.rb index 2be349d..cbca053 100644 --- a/app/models/agreement.rb +++ b/app/models/agreement.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Agreement < ApplicationRecord has_many :signed_agreements diff --git a/app/models/application_record.rb b/app/models/application_record.rb index 10a4cba..71fbba5 100644 --- a/app/models/application_record.rb +++ b/app/models/application_record.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ApplicationRecord < ActiveRecord::Base self.abstract_class = true end diff --git a/app/models/carrier.rb b/app/models/carrier.rb index b94e5b5..50dd371 100644 --- a/app/models/carrier.rb +++ b/app/models/carrier.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Carrier < ApplicationRecord belongs_to :location has_many :loans diff --git a/app/models/cart.rb b/app/models/cart.rb index 0931a34..941c391 100644 --- a/app/models/cart.rb +++ b/app/models/cart.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Cart < ApplicationRecord belongs_to :member, class_name: "User" validates :member, presence: true diff --git a/app/models/category.rb b/app/models/category.rb index 18b5a5f..de7615f 100644 --- a/app/models/category.rb +++ b/app/models/category.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Category < ApplicationRecord validates :name, presence: true, uniqueness: true diff --git a/app/models/fee_type.rb b/app/models/fee_type.rb index 6fbf1ef..a3fce2d 100644 --- a/app/models/fee_type.rb +++ b/app/models/fee_type.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class FeeType < ApplicationRecord validates_presence_of :name, :amount end diff --git a/app/models/loan.rb b/app/models/loan.rb index 4b01c3b..a6d6b49 100644 --- a/app/models/loan.rb +++ b/app/models/loan.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Loan < ApplicationRecord belongs_to :cart belongs_to :carrier diff --git a/app/models/location.rb b/app/models/location.rb index aa1b7fc..1097dbc 100644 --- a/app/models/location.rb +++ b/app/models/location.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Location < ApplicationRecord has_many :carriers belongs_to :organization diff --git a/app/models/membership_type.rb b/app/models/membership_type.rb index 6c1110c..3f48b24 100644 --- a/app/models/membership_type.rb +++ b/app/models/membership_type.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class MembershipType < ApplicationRecord validates :name, :fee_cents, :duration_days, :number_of_items, :description, presence: true end diff --git a/app/models/organization.rb b/app/models/organization.rb index 6cec8a8..1c13a70 100644 --- a/app/models/organization.rb +++ b/app/models/organization.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Organization < ApplicationRecord validates :name, presence: true has_many :locations diff --git a/app/models/role.rb b/app/models/role.rb index 3116ff2..4bdf5ed 100644 --- a/app/models/role.rb +++ b/app/models/role.rb @@ -1,15 +1,17 @@ +# frozen_string_literal: true + class Role < ApplicationRecord -has_and_belongs_to_many :users, :join_table => :users_roles + has_and_belongs_to_many :users, :join_table => :users_roles -belongs_to :resource, - :polymorphic => true, - :optional => true + belongs_to :resource, + :polymorphic => true, + :optional => true -validates :resource_type, - :inclusion => { :in => Rolify.resource_types }, - :allow_nil => true + validates :resource_type, + :inclusion => { :in => Rolify.resource_types }, + :allow_nil => true -scopify + scopify end diff --git a/app/models/signed_agreement.rb b/app/models/signed_agreement.rb index 7353bdc..ef099f0 100644 --- a/app/models/signed_agreement.rb +++ b/app/models/signed_agreement.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class SignedAgreement < ApplicationRecord belongs_to :user belongs_to :agreement diff --git a/app/models/user.rb b/app/models/user.rb index 02da642..3cec525 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class User < ApplicationRecord rolify # Include default devise modules. Others available are: diff --git a/app/policies/application_policy.rb b/app/policies/application_policy.rb index d170281..cb4f866 100644 --- a/app/policies/application_policy.rb +++ b/app/policies/application_policy.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ApplicationPolicy attr_reader :user, :members diff --git a/app/policies/user_policy.rb b/app/policies/user_policy.rb index d2637e8..f2a49b8 100644 --- a/app/policies/user_policy.rb +++ b/app/policies/user_policy.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class UserPolicy < ApplicationPolicy attr_reader :user, :members @@ -9,4 +11,4 @@ def initialize(user, members) def index? user.has_role?(:admin) or user.has_role?(:volunteer) end -end \ No newline at end of file +end diff --git a/app/views/agreements/_form.html.erb b/app/views/agreements/_form.html.erb index 742c7f1..f310c8b 100644 --- a/app/views/agreements/_form.html.erb +++ b/app/views/agreements/_form.html.erb @@ -11,17 +11,15 @@ <% end %> -
+
<%= form.label :title %> - <%= form.text_field :title %> + <%= form.text_field :title, class: "form-control" %>
-
+
<%= form.label :content %> - <%= form.text_area :content %> + <%= form.text_area :content, rows: 10, class: "form-control" %>
-
- <%= form.submit %> -
+ <%= form.submit class: "btn btn-primary" %> <% end %> diff --git a/app/views/agreements/edit.html.erb b/app/views/agreements/edit.html.erb index d900410..d0da54f 100644 --- a/app/views/agreements/edit.html.erb +++ b/app/views/agreements/edit.html.erb @@ -1,6 +1,8 @@ -

Editing Agreement

- -<%= render 'form', agreement: @agreement %> - -<%= link_to 'Show', @agreement %> | -<%= link_to 'Back', agreements_path %> +
+

Editing Agreement

+
+ <%= render 'form', agreement: @agreement %> + <%= link_to 'Show', @agreement %> | + <%= link_to 'Back', agreements_path %> +
+
diff --git a/app/views/agreements/index.html.erb b/app/views/agreements/index.html.erb index ecbc449..e388daa 100644 --- a/app/views/agreements/index.html.erb +++ b/app/views/agreements/index.html.erb @@ -1,31 +1,33 @@ -

<%= notice %>

+
+
+

Agreements

+ <%= link_to '+ New', new_agreement_path, class: "btn btn-primary" %> +
-

Agreements

+
+ + + + + + + + + + -
SignedTitleContent
- - - - - - - - + + <% @agreements.each do |agreement| %> + + + + - - <% @agreements.each do |agreement| %> - - - - - - - - - <% end %> - -
SignedTitleContent
<%= check_box_tag 'signed', '', agreement.signed_by?(current_user), disabled: true %><%= link_to agreement.title, agreement %><%= truncate(agreement.content) %>
<%= check_box_tag 'signed', '', agreement.signed_by?(current_user), disabled: true %><%= agreement.title %><%= link_to 'Show', agreement %><%= link_to 'Edit', edit_agreement_path(agreement) %><%= link_to 'Destroy', agreement, method: :delete, data: { confirm: 'Are you sure?' } %>
- -
- -<%= link_to 'New Agreement', new_agreement_path %> + <%= link_to 'Edit', edit_agreement_path(agreement) %> + <%= link_to 'Destroy', agreement, method: :delete, data: { confirm: 'Are you sure?' } %> + + <% end %> + + +
+
diff --git a/app/views/agreements/new.html.erb b/app/views/agreements/new.html.erb index dd71fbf..9f4fa5d 100644 --- a/app/views/agreements/new.html.erb +++ b/app/views/agreements/new.html.erb @@ -1,5 +1,7 @@ -

New Agreement

- -<%= render 'form', agreement: @agreement %> - -<%= link_to 'Back', agreements_path %> \ No newline at end of file +
+

New Agreement

+
+ <%= render 'form', agreement: @agreement %> + <%= link_to 'Back', agreements_path %> +
+
diff --git a/app/views/carriers/_carrier_form.html.erb b/app/views/carriers/_carrier_form.html.erb index d1c5fcb..e5b0f8d 100644 --- a/app/views/carriers/_carrier_form.html.erb +++ b/app/views/carriers/_carrier_form.html.erb @@ -1,64 +1,66 @@ -<%= form_for @carrier do |c| %> - <%= c.label :name %> - <%= c.text_field :name %> - -

- - <%= c.label :item_id %> - <%= c.text_field :item_id %> - -

- - <%= c.label :manufacturer %> - <%= c.text_field :manufacturer %> - -

- - <%= c.label :model %> - <%= c.text_field :model %> - -

- - <%= c.label :color %> - <%= c.text_field :color %> - -

- - <%= c.label :size %> - <%= c.text_field :size %> - -

- - <%= c.label :location_id %> - <%= c.collection_select :location_id, @locations, :id, :name %> - -

- - <%= c.label :category_id %> - <%= c.collection_select :category_id, @categories, :id, :name %> - -

- - <%= c.label :default_loan_length_days, 'Default Loan Length' %> - <%= c.number_field :default_loan_length_days %> days - -

- - <% if @carrier.photos.attached? %> - <% @carrier.photos.each do |photo| %> -
- <%= image_tag(photo.variant(resize: "100x100").processed, class: "card-img-top") %> -
- <%= link_to 'Remove', photo_path(photo.id), method: :delete, data: { confirm: 'Are you sure?' }, class: "btn btn-danger" %> +<%= form_for @carrier do |form| %> +
+ <%= form.label :name %> + <%= form.text_field :name, class: "form-control" %> +
+ +
+ <%= form.label :item_id %> + <%= form.text_field :item_id, class: "form-control" %> +
+ +
+ <%= form.label :manufacturer %> + <%= form.text_field :manufacturer, class: "form-control" %> +
+ +
+ <%= form.label :model %> + <%= form.text_field :model, class: "form-control" %> +
+ +
+ <%= form.label :color %> + <%= form.text_field :color, class: "form-control" %> +
+ +
+ <%= form.label :size %> + <%= form.text_field :size, class: "form-control" %> +
+ +
+ <%= form.label :location_id %> + <%= form.collection_select :location_id, @locations, :id, :name, {}, class: "form-control" %> +
+ +
+ <%= form.label :category_id %> + <%= form.collection_select :category_id, @categories, :id, :name, {}, class: "form-control" %> +
+ +
+ <%= form.label :default_loan_length_days, 'Default Loan Length' %> + <%= form.number_field :default_loan_length_days, class: "form-control" %> days +
+ +
+ <% if @carrier.photos.attached? %> + <% @carrier.photos.each do |photo| %> +
+ <%= image_tag(photo.variant(resize: "100x100").processed, class: "card-img-top") %> +
+ <%= link_to 'Remove', photo_path(photo.id), method: :delete, data: { confirm: 'Are you sure?' }, class: "btn btn-danger" %> +
-
- <% end %> - <% end%> - - <%= c.label :photos %> - <%= c.file_field :photos, multiple: true %> + <% end %> + <% end%> +
-

+
+ <%= form.label :photos %> + <%= form.file_field :photos, multiple: true, class: "form-control" %> +
- <%= c.submit %> + <%= form.submit class: "btn btn-primary" %> <% end %> diff --git a/app/views/carriers/edit.html.erb b/app/views/carriers/edit.html.erb index 6a56c8e..3ae582e 100644 --- a/app/views/carriers/edit.html.erb +++ b/app/views/carriers/edit.html.erb @@ -1,13 +1,6 @@ -<% if flash[:errors] %> -
    - <% flash[:errors].each do |error| %> -
  • <%= error %>
  • - <% end %> -
-<% elsif flash[:success] %> -
<%= flash[:success] %>
-<% end %> - -

Edit Carrier

- -<%= render 'carrier_form' %> \ No newline at end of file +
+

Edit Carrier

+
+ <%= render 'carrier_form' %> +
+
diff --git a/app/views/carriers/index.html.erb b/app/views/carriers/index.html.erb index e900113..1a0afec 100644 --- a/app/views/carriers/index.html.erb +++ b/app/views/carriers/index.html.erb @@ -4,10 +4,23 @@

Carriers

-
    - <% @carriers.each do |carrier| %> -
  • - <%= link_to carrier.name, carrier %>
    -
  • - <% end %> -
+<% @carriers.each_slice(4) do |carriers| %> +
+ <% carriers.each do |carrier| %> +
+
+ <% if carrier.photos.attached? %> + <%= image_tag(carrier.photos.first.variant(resize: "200x300").processed, class: "img-thumbnail img-fluid") %> + <% else %> + <%= image_tag("img_placeholder.svg", class: "img-thumbnail img-fluid h-100") %> + <% end %> +
+

<%= carrier.name %>

+

<%= carrier.location.name %>

+
+
+
+ <% end %> +
+<% end %> + diff --git a/app/views/carriers/new.html.erb b/app/views/carriers/new.html.erb index 1d002bf..d5dea40 100644 --- a/app/views/carriers/new.html.erb +++ b/app/views/carriers/new.html.erb @@ -1,11 +1,6 @@ -<% if flash[:errors] %> -
    - <% flash[:errors].each do |error| %> -
  • <%= error %>
  • - <% end %> -
-<% end %> - -

New Carrier

- -<%= render 'carrier_form' %> +
+

New Carrier

+
+ <%= render 'carrier_form' %> +
+
diff --git a/app/views/categories/_form.html.erb b/app/views/categories/_form.html.erb index 3c3c103..d3bfc4b 100644 --- a/app/views/categories/_form.html.erb +++ b/app/views/categories/_form.html.erb @@ -11,22 +11,20 @@
<% end %> -
+
<%= form.label :name %> - <%= form.text_field :name %> + <%= form.text_field :name, class: "form-control" %>
-
+
<%= form.label :description %> - <%= form.text_field :description %> + <%= form.text_field :description, class: "form-control" %>
-
+
<%= form.label :parent_id %> - <%= form.text_field :parent_id %> + <%= form.text_field :parent_id, class: "form-control" %>
-
- <%= form.submit %> -
+ <%= form.submit class: "btn btn-primary" %> <% end %> diff --git a/app/views/categories/edit.html.erb b/app/views/categories/edit.html.erb index b969417..3df3f00 100644 --- a/app/views/categories/edit.html.erb +++ b/app/views/categories/edit.html.erb @@ -1,6 +1,9 @@ -

Editing Category

+
+

Editing Category

+
+ <%= render 'form', category: @category %> -<%= render 'form', category: @category %> - -<%= link_to 'Show', @category %> | -<%= link_to 'Back', categories_path %> + <%= link_to 'Show', @category %> | + <%= link_to 'Back', categories_path %> +
+
diff --git a/app/views/categories/index.html.erb b/app/views/categories/index.html.erb index c88d8aa..1126cb7 100644 --- a/app/views/categories/index.html.erb +++ b/app/views/categories/index.html.erb @@ -1,31 +1,32 @@ -

<%= notice %>

+
+
+

Categories

+ <%= link_to '+ New', new_category_path, class: "btn btn-primary" %> +
-

Categories

+
+ + + + + + + + + + -
NameDescriptionParent
- - - - - - - - - - - <% @categories.each do |category| %> - - - - - - - - - <% end %> - -
NameDescriptionParent
<%= category.name %><%= category.description %><%= category.parent&.name %><%= link_to 'Show', category %><%= link_to 'Edit', edit_category_path(category) %><%= link_to 'Destroy', category, method: :delete, data: { confirm: 'Are you sure?' } %>
- -
- -<%= link_to 'New Category', new_category_path %> + + <% @categories.each do |category| %> + + <%= link_to category.name, category %> + <%= category.description %> + <%= category.parent&.name %> + <%= link_to 'Edit', edit_category_path(category) %> + <%= link_to 'Destroy', category, method: :delete, data: { confirm: 'Are you sure?' } %> + + <% end %> + + +
+
diff --git a/app/views/categories/new.html.erb b/app/views/categories/new.html.erb index 91d5ef7..caa8dbe 100644 --- a/app/views/categories/new.html.erb +++ b/app/views/categories/new.html.erb @@ -1,5 +1,7 @@ -

New Category

- -<%= render 'form', category: @category %> - -<%= link_to 'Back', categories_path %> +
+

New Category

+
+ <%= render 'form', category: @category %> + <%= link_to 'Back', categories_path %> +
+
diff --git a/app/views/categories/show.html.erb b/app/views/categories/show.html.erb index 721c3d7..ddf21fa 100644 --- a/app/views/categories/show.html.erb +++ b/app/views/categories/show.html.erb @@ -10,6 +10,19 @@ <%= @category.description %>

+

+ Carriers: + <% if @category.carriers.blank? %> +

There are no carriers of this type in inventory at this time. Please check back later.

+ <% else %> +
    + <% @category.carriers.each do |carrier| %> +
  • <%= link_to carrier.name, carrier_path(carrier) %>
  • + <% end %> +
+ <% end %> +

+

Parent: <%= @category.parent %> diff --git a/app/views/fee_types/_form.html.erb b/app/views/fee_types/_form.html.erb index 607abc9..8b021d1 100644 --- a/app/views/fee_types/_form.html.erb +++ b/app/views/fee_types/_form.html.erb @@ -11,17 +11,15 @@

<% end %> -
+
<%= form.label :name %> - <%= form.text_field :name %> + <%= form.text_field :name, class: "form-control" %>
-
+
<%= form.label :amount %> - <%= form.text_field :amount %> + <%= form.text_field :amount, class: "form-control" %>
-
- <%= form.submit %> -
+ <%= form.submit class: "btn btn-primary" %> <% end %> diff --git a/app/views/fee_types/edit.html.erb b/app/views/fee_types/edit.html.erb index 4560516..5d468d7 100644 --- a/app/views/fee_types/edit.html.erb +++ b/app/views/fee_types/edit.html.erb @@ -1,5 +1,8 @@ -

Editing Fee Type

-<%= render 'form', fee_type: @fee_type %> - -<%= link_to 'Show', @fee_type %> | -<%= link_to 'Back', fee_types_path %> +
+

Editing Fee Type

+
+ <%= render 'form', fee_type: @fee_type %> + <%= link_to 'Show', @fee_type %> | + <%= link_to 'Back', fee_types_path %> +
+
diff --git a/app/views/fee_types/index.html.erb b/app/views/fee_types/index.html.erb index a970250..0c6fb59 100644 --- a/app/views/fee_types/index.html.erb +++ b/app/views/fee_types/index.html.erb @@ -1,29 +1,30 @@ -

<%= notice %>

+
+
+

Fee Types

+ <%= link_to '+ New', new_fee_type_path, class: "btn btn-primary" %> +
-

Fee Types

+
+ + + + + + + + + -
NameAmount
- - - - - - - - - - <% @fee_types.each do |fee_type| %> - - - - - - - - <% end %> - -
NameAmount
<%= fee_type.name %><%= number_to_currency(fee_type.amount/100) %><%= link_to 'Show', fee_type %><%= link_to 'Edit', edit_fee_type_path(fee_type) %><%= link_to 'Destroy', fee_type, method: :delete, data: { confirm: 'Are you sure?' } %>
- -
- -<%= link_to 'New Fee Type', new_fee_type_path %> + + <% @fee_types.each do |fee_type| %> + + <%= link_to fee_type.name, fee_type %> + <%= number_to_currency(fee_type.amount/100) %> + <%= link_to 'Edit', edit_fee_type_path(fee_type) %> + <%= link_to 'Destroy', fee_type, method: :delete, data: { confirm: 'Are you sure?' } %> + + <% end %> + + +
+
diff --git a/app/views/fee_types/new.html.erb b/app/views/fee_types/new.html.erb index c7fbfeb..aff6429 100644 --- a/app/views/fee_types/new.html.erb +++ b/app/views/fee_types/new.html.erb @@ -1,5 +1,7 @@ -

New Fee Type

- -<%= render 'form', fee_type: @fee_type %> - -<%= link_to 'Back', fee_types_path %> +
+

New Fee Type

+
+ <%= render 'form', fee_type: @fee_type %> + <%= link_to 'Back', fee_types_path %> +
+
diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb new file mode 100644 index 0000000..bb10a71 --- /dev/null +++ b/app/views/layouts/_header.html.erb @@ -0,0 +1,33 @@ + diff --git a/app/views/layouts/_sidebar.html.erb b/app/views/layouts/_sidebar.html.erb new file mode 100644 index 0000000..85b7b16 --- /dev/null +++ b/app/views/layouts/_sidebar.html.erb @@ -0,0 +1,28 @@ + diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 280dea2..cb93742 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -10,89 +10,20 @@ - - - -
+ <%= render "shared/flash" %> - <% flash.each do |name, msg| -%> - <%= content_tag :div, msg, class: flash_class(name) %> - <% end -%> +
+
+ <%= render "layouts/sidebar" if signed_in? %> -

<%= notice %>

-

<%= alert %>

- - - -
- <%= yield %> -
-
- +
+ <%= form.label :name %> + <%= form.text_field :name, class: "form-control" %> +
- <%= f.collection_select(:organization_id, Organization.all, :id, :name) %> - <%= f.submit %> -<% end %> \ No newline at end of file +
+ <%= form.label :organization %> + <%= form.collection_select(:organization_id, Organization.all, :id, :name, {}, class: "form-control") %> +
+ + <%= form.submit class: "btn btn-primary" %> +<% end %> diff --git a/app/views/locations/edit.html.erb b/app/views/locations/edit.html.erb index 0c3cf82..2c11935 100644 --- a/app/views/locations/edit.html.erb +++ b/app/views/locations/edit.html.erb @@ -1,2 +1,6 @@ -

Edit

-<%= render :partial => 'form', :locals => {edit: true} %> \ No newline at end of file +
+

Editing location

+
+ <%= render :partial => 'form', :locals => {edit: true} %> +
+
diff --git a/app/views/locations/index.html.erb b/app/views/locations/index.html.erb index 51fca6e..2a68a5e 100644 --- a/app/views/locations/index.html.erb +++ b/app/views/locations/index.html.erb @@ -1,25 +1,28 @@ -

<%= notice %>

+
+
+

Locations

+ <%= link_to '+ New', new_location_path, class: "btn btn-primary" %> +
-

Locations

+
+ + + + + + + + -
Name
- - - - - - - - - <% @locations.each do |location| %> - - - - - - - <% end %> - -
Name
<%= location.name %><%= link_to 'Show', location %><%= link_to 'Edit', edit_location_path(location) %><%= link_to 'Destroy', location, method: :delete, data: { confirm: 'Are you sure?' } %>
- -<%= link_to "Add a new location", new_location_path %>

+ + <% @locations.each do |location| %> + + <%= link_to location.name, location %> + <%= link_to 'Edit', edit_location_path(location) %> + <%= link_to 'Destroy', location, method: :delete, data: { confirm: 'Are you sure?' } %> + + <% end %> + + +
+
diff --git a/app/views/locations/new.html.erb b/app/views/locations/new.html.erb index 6bea293..097a220 100644 --- a/app/views/locations/new.html.erb +++ b/app/views/locations/new.html.erb @@ -1,3 +1,6 @@ -

Create a location

-

-<%= render :partial => 'form', :locals => {edit: false} %> \ No newline at end of file +
+

Create a location

+
+ <%= render :partial => 'form', :locals => {edit: false} %> +
+
diff --git a/app/views/membership_types/_form.html.erb b/app/views/membership_types/_form.html.erb index ad03e3e..e94bde5 100644 --- a/app/views/membership_types/_form.html.erb +++ b/app/views/membership_types/_form.html.erb @@ -11,32 +11,30 @@
<% end %> -
+
<%= form.label :name %> - <%= form.text_field :name %> + <%= form.text_field :name, class: "form-control" %>
-
+
<%= form.label :fee_cents %> - <%= form.text_field :fee_cents %> + <%= form.text_field :fee_cents, class: "form-control" %>
-
+
<%= form.label :duration_days %> - <%= form.text_field :duration_days %> + <%= form.text_field :duration_days, class: "form-control" %>
-
+
<%= form.label :number_of_items %> - <%= form.text_field :number_of_items %> + <%= form.text_field :number_of_items, class: "form-control" %>
-
+
<%= form.label :description %> - <%= form.text_field :description %> + <%= form.text_field :description, class: "form-control" %>
-
- <%= form.submit %> -
+ <%= form.submit class: "btn btn-primary" %> <% end %> diff --git a/app/views/membership_types/edit.html.erb b/app/views/membership_types/edit.html.erb index ec81c64..8ea4663 100644 --- a/app/views/membership_types/edit.html.erb +++ b/app/views/membership_types/edit.html.erb @@ -1,6 +1,8 @@ -

Editing Membership Type

- -<%= render 'form', membership_type: @membership_type %> - -<%= link_to 'Show', @membership_type %> | -<%= link_to 'Back', membership_types_path %> +
+

Editing Membership Type

+
+ <%= render 'form', membership_type: @membership_type %> + <%= link_to 'Show', @membership_type %> | + <%= link_to 'Back', membership_types_path %> +
+
diff --git a/app/views/membership_types/index.html.erb b/app/views/membership_types/index.html.erb index fb081ff..9531fb0 100644 --- a/app/views/membership_types/index.html.erb +++ b/app/views/membership_types/index.html.erb @@ -1,35 +1,36 @@ -

<%= notice %>

+
+
+

Membership Types

+ <%= link_to '+ New', new_membership_type_path, class: "btn btn-primary" %> +
-

Membership Types

+
+ + + + + + + + + + + + -
NameFeeDurationNumber of itemsDescription
- - - - - - - - - - - - - <% @membership_types.each do |membership_type| %> - - - - - - - - - - - <% end %> - -
NameFeeDurationNumber of itemsDescription
<%= membership_type.name %><%= membership_type.fee_cents %><%= membership_type.duration_days %><%= membership_type.number_of_items %><%= membership_type.description %><%= link_to 'Show', membership_type %><%= link_to 'Edit', edit_membership_type_path(membership_type) %><%= link_to 'Destroy', membership_type, method: :delete, data: { confirm: 'Are you sure?' } %>
- -
- -<%= link_to 'New Membership Type', new_membership_type_path %> + + <% @membership_types.each do |membership_type| %> + + <%= link_to membership_type.name, membership_type %> + <%= membership_type.fee_cents %> + <%= membership_type.duration_days %> + <%= membership_type.number_of_items %> + <%= membership_type.description %> + <%= link_to 'Edit', edit_membership_type_path(membership_type) %> + <%= link_to 'Destroy', membership_type, method: :delete, data: { confirm: 'Are you sure?' } %> + + <% end %> + + +
+
diff --git a/app/views/membership_types/new.html.erb b/app/views/membership_types/new.html.erb index 8e4c773..aec4b49 100644 --- a/app/views/membership_types/new.html.erb +++ b/app/views/membership_types/new.html.erb @@ -1,5 +1,7 @@ -

New Membership Type

- -<%= render 'form', membership_type: @membership_type %> - -<%= link_to 'Back', membership_types_path %> +
+

New Membership Type

+
+ <%= render 'form', membership_type: @membership_type %> + <%= link_to 'Back', membership_types_path %> +
+
diff --git a/app/views/organizations/_form.html.erb b/app/views/organizations/_form.html.erb index ae0b1fa..014e779 100644 --- a/app/views/organizations/_form.html.erb +++ b/app/views/organizations/_form.html.erb @@ -11,17 +11,15 @@
<% end %> -
+
<%= form.label :name %> - <%= form.text_field :name %> + <%= form.text_field :name, class: "form-control" %>
-
+
<%= form.label :description %> - <%= form.text_field :description %> + <%= form.text_field :description, class: "form-control" %>
-
- <%= form.submit %> -
+ <%= form.submit class: "btn btn-primary" %> <% end %> diff --git a/app/views/organizations/edit.html.erb b/app/views/organizations/edit.html.erb index 0514ab1..36d907a 100644 --- a/app/views/organizations/edit.html.erb +++ b/app/views/organizations/edit.html.erb @@ -1,6 +1,8 @@ -

Editing Organization

- -<%= render 'form', organization: @organization %> - -<%= link_to 'Show', @organization %> | -<%= link_to 'Back', organizations_path %> +
+

Editing Organization

+
+ <%= render 'form', organization: @organization %> + <%= link_to 'Show', @organization %> | + <%= link_to 'Back', organizations_path %> +
+
diff --git a/app/views/organizations/index.html.erb b/app/views/organizations/index.html.erb index ec0d5f3..871e0f9 100644 --- a/app/views/organizations/index.html.erb +++ b/app/views/organizations/index.html.erb @@ -1,29 +1,30 @@ -

<%= notice %>

+
+
+

Organizations

+ <%= link_to '+ New', new_organization_path, class: "btn btn-primary" %> +
-

Organizations

+
+ + + + + + + + + -
NameDescription
- - - - - - - - - - <% @organizations.each do |organization| %> - - - - - - - - <% end %> - -
NameDescription
<%= organization.name %><%= organization.description %><%= link_to 'Show', organization %><%= link_to 'Edit', edit_organization_path(organization) %><%= link_to 'Destroy', organization, method: :delete, data: { confirm: 'Are you sure?' } %>
- -
- -<%= link_to 'New Organization', new_organization_path %> + + <% @organizations.each do |organization| %> + + <%= link_to organization.name, organization %> + <%= organization.description %> + <%= link_to 'Edit', edit_organization_path(organization) %> + <%= link_to 'Destroy', organization, method: :delete, data: { confirm: 'Are you sure?' } %> + + <% end %> + + +
+
diff --git a/app/views/organizations/new.html.erb b/app/views/organizations/new.html.erb index be2be97..6c4c852 100644 --- a/app/views/organizations/new.html.erb +++ b/app/views/organizations/new.html.erb @@ -1,5 +1,7 @@ -

New Organization

- -<%= render 'form', organization: @organization %> - -<%= link_to 'Back', organizations_path %> +
+

New Organization

+
+ <%= render 'form', organization: @organization %> + <%= link_to 'Back', organizations_path %> +
+
diff --git a/app/views/organizations/show.html.erb b/app/views/organizations/show.html.erb index 79e7390..0fcc98d 100644 --- a/app/views/organizations/show.html.erb +++ b/app/views/organizations/show.html.erb @@ -10,25 +10,5 @@ <%= @organization.description %>

-<% @organization.carriers.each_slice(4) do |carriers| %> -
- <% carriers.each do |carrier| %> -
-
- <% if carrier.photos.attached? %> - <%= image_tag(carrier.photos.first.variant(resize: "200x300").processed, class: "img-thumbnail img-fluid") %> - <% else %> - <%= image_tag("img_placeholder.svg", class: "img-thumbnail img-fluid h-100") %> - <% end %> -
-

<%= carrier.name %>

-

<%= carrier.location.name %>

-
-
-
- <% end %> -
-<% end %> - <%= link_to 'Edit', edit_organization_path(@organization) %> | <%= link_to 'Back', organizations_path %> diff --git a/app/views/shared/_flash.html.erb b/app/views/shared/_flash.html.erb new file mode 100644 index 0000000..ebb4b76 --- /dev/null +++ b/app/views/shared/_flash.html.erb @@ -0,0 +1,5 @@ +<% flash.each do |key, value| %> +
+ <%= value %> +
+<% end %> diff --git a/bin/setup b/bin/setup index 94fd4d7..fa9712f 100755 --- a/bin/setup +++ b/bin/setup @@ -17,20 +17,11 @@ chdir APP_ROOT do system! 'gem install bundler --conservative' system('bundle check') || system!('bundle install') - # Install JavaScript dependencies if using Yarn - # system('bin/yarn') - - # puts "\n== Copying sample files ==" - # unless File.exist?('config/database.yml') - # cp 'config/database.yml.sample', 'config/database.yml' - # end - puts "\n== Preparing database ==" system! 'bin/rails db:setup' puts "\n== Removing old logs and tempfiles ==" system! 'bin/rails log:clear tmp:clear' - puts "\n== Restarting application server ==" - system! 'bin/rails restart' + puts "\n== DONE! Go ahead and start the rails server with bin/rails server==" end diff --git a/config/routes.rb b/config/routes.rb index 24b2dfe..51c8300 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -13,5 +13,5 @@ resources :categories # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html - root 'home#index' + root 'carriers#index' end diff --git a/spec/features/agreement_spec.rb b/spec/features/agreement_spec.rb index b35e0d5..eba2f07 100644 --- a/spec/features/agreement_spec.rb +++ b/spec/features/agreement_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.feature 'create an agreement', type: :feature do fixtures :users, :agreements let(:user) { users(:user) } @@ -10,7 +12,7 @@ scenario 'SHOW' do visit agreements_path - click_on 'Show' + click_on agreement.title expect(page).to have_content('Test Agreement') expect(page).to have_content('Content') @@ -47,7 +49,7 @@ scenario 'CREATE when title is NOT given' do visit agreements_path - click_link('New Agreement') + click_link('+ New') fill_in 'Title', with: nil fill_in 'Content', with: 'Content of Fake Agreement' click_on 'Create Agreement' @@ -58,7 +60,7 @@ scenario 'CREATE when all expected information is given' do visit agreements_path - click_link('New Agreement') + click_link('+ New') fill_in 'Title', with: 'Fake Agreement' fill_in 'Content', with: 'Content of Fake Agreement' click_on 'Create Agreement' @@ -66,4 +68,4 @@ expect(page).to have_content('Agreement was successfully created.') end -end \ No newline at end of file +end diff --git a/spec/features/carrier_spec.rb b/spec/features/carrier_spec.rb index d108360..f424542 100644 --- a/spec/features/carrier_spec.rb +++ b/spec/features/carrier_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.describe 'Carrier' do fixtures :categories let(:category) { categories(:category) } diff --git a/spec/features/category_spec.rb b/spec/features/category_spec.rb index f47bec3..50e8f98 100644 --- a/spec/features/category_spec.rb +++ b/spec/features/category_spec.rb @@ -1,7 +1,12 @@ +# frozen_string_literal: true + RSpec.feature "category" do fixtures :categories - let!(:category) { categories(:category) } + fixtures :carriers fixtures :users + + let!(:category) { categories(:category) } + let!(:carrier) { carriers(:carrier) } let(:user) { users(:user) } before :each do @@ -11,7 +16,7 @@ scenario "should allow user to create a category" do visit "/categories" - find_link("New Category").click + find_link("+ New").click fill_in "Name", with: "pineapple" fill_in "Description", with: "sweet" fill_in "Parent", with: "1" @@ -21,7 +26,7 @@ scenario "should allow user to update a category" do visit "/categories" - find_link("Show").click + click_link category.name expect(page).to have_content category.name find_link("Edit").click fill_in "Name", with: "orange" @@ -36,4 +41,22 @@ find_link("Destroy").click expect(page).to have_content "Category was successfully destroyed." end + + scenario 'should show carriers for category as a link' do + visit category_path(category) + expect(page).to have_content(category.name) + find_link(carrier.name).click + expect(page).to have_current_path(carrier_path(carrier)) + end + + scenario 'should show a empty message if category has no carriers' do + category.carriers = [] + + visit category_path(category) + + expect(page).to have_content( + 'There are no carriers of this type in ' + + 'inventory at this time. Please check back later.' + ) + end end diff --git a/spec/features/fee_type_spec.rb b/spec/features/fee_type_spec.rb index 9b054b2..444bab3 100644 --- a/spec/features/fee_type_spec.rb +++ b/spec/features/fee_type_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.feature "fee_type" do fixtures :users let(:user) { users(:user) } @@ -12,7 +14,7 @@ scenario 'SHOW' do visit fee_types_path - click_link 'Show' + click_link @fee_type.name expect(page).to have_content('Upgrade Membership') expect(page).to have_content('20.00') @@ -49,7 +51,7 @@ scenario 'CREATE when name is NOT given' do visit fee_types_path - click_link('New Fee Type') + click_link('+ New') fill_in 'Name', with: nil fill_in 'Amount', with: '4000' click_on 'Create Fee type' @@ -60,7 +62,7 @@ scenario 'CREATE when all expected information is given' do visit fee_types_path - click_link('New Fee Type') + click_link('+ New') fill_in 'Name', with: 'Upgrade Membership' fill_in 'Amount', with: '3000' click_on 'Create Fee type' @@ -68,4 +70,4 @@ expect(page).to have_content('Fee type was successfully created.') end -end \ No newline at end of file +end diff --git a/spec/features/location_spec.rb b/spec/features/location_spec.rb index b9fb485..115b340 100644 --- a/spec/features/location_spec.rb +++ b/spec/features/location_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.feature 'create a location', type: :feature do fixtures :users let(:user) { users(:user) } @@ -10,8 +12,8 @@ scenario 'should allow admin to create a new location' do visit "/locations" - find_link("Add a new location", match: :first).click - fill_in "name", with: "Bellvue" + find_link("+ New", match: :first).click + fill_in "Name", with: "Bellvue" select "Ruby For Good", from: "location_organization_id" click_button "Create Location" expect(page).to have_content "Bellvue" @@ -19,28 +21,28 @@ scenario 'should allow admin to create a new location' do visit "/locations" - find_link("Add a new location", match: :first).click - fill_in "name", with: "Robinson" + find_link("+ New", match: :first).click + fill_in "Name", with: "Robinson" click_button "Create Location" expect(page).to have_content "Robinson" end scenario 'should allow admin to update a location' do visit "/locations" - find_link("Add a new location", match: :first).click - fill_in "name", with: "Robinson" + find_link("+ New", match: :first).click + fill_in "Name", with: "Robinson" click_button "Create Location" expect(page).to have_content "Robinson" find_link("Edit this location").click - fill_in "name", with: "New location" + fill_in "Name", with: "New location" click_button "Update Location" expect(page).to have_content "New location" end scenario 'should allow adming to delete a location' do visit "/locations" - find_link("Add a new location", match: :first).click - fill_in "name", with: "Bridgeville" + find_link("+ New", match: :first).click + fill_in "Name", with: "Bridgeville" click_button "Create Location" expect(page).to have_content "Bridgeville" find_link("Delete this location").click diff --git a/spec/features/membership_type_spec.rb b/spec/features/membership_type_spec.rb index 3d96b0c..efbee88 100644 --- a/spec/features/membership_type_spec.rb +++ b/spec/features/membership_type_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.describe 'MembershipType', type: :feature do fixtures :users let(:user) { users(:user) } @@ -16,7 +18,7 @@ scenario 'SHOW' do visit "/membership_types" - expect(page).to have_content('New Membership Type') + expect(page).to have_content('+ New') end scenario 'EDIT when name is NOT given' do @@ -47,7 +49,7 @@ scenario 'CREATE when name is NOT given' do visit membership_types_path - click_link('New Membership Type') + click_link('+ New') fill_in 'Name', with: "" click_on 'Create Membership type' expect(page).to have_content("Name can't be blank") @@ -56,7 +58,7 @@ scenario 'CREATE when all expected information is given' do visit membership_types_path - click_link('New Membership Type') + click_link('+ New') fill_in 'Name', with: 'Trial' fill_in 'Description', with: 'A text description goes here.' fill_in 'Duration', with: 2 diff --git a/spec/features/organization_spec.rb b/spec/features/organization_spec.rb index 888401c..4c24ec6 100644 --- a/spec/features/organization_spec.rb +++ b/spec/features/organization_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.describe 'Organization' do fixtures :users let(:user) { users(:user) } @@ -12,8 +14,8 @@ scenario 'SHOW' do visit organizations_path - click_link 'Show' - + click_link @organization.name + expect(page).to have_content('Henrys Baby Hammocks') expect(page).to have_content('Hammocks for the babies') end @@ -49,7 +51,7 @@ scenario 'CREATE when name is NOT given' do visit organizations_path - click_link('New Organization') + click_link('+ New') fill_in 'Name', with: nil fill_in 'Description', with: 'Desciption of Fake Organization' click_on 'Create Organization' @@ -60,7 +62,7 @@ scenario 'CREATE when all expected information is given' do visit organizations_path - click_link('New Organization') + click_link('+ New') fill_in 'Name', with: 'Fake Organization' fill_in 'Description', with: 'Desciption of Fake Organization' click_on 'Create Organization' diff --git a/spec/features/signed_agreement_spec.rb b/spec/features/signed_agreement_spec.rb index 6e2ea3c..7a20424 100644 --- a/spec/features/signed_agreement_spec.rb +++ b/spec/features/signed_agreement_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.describe SignedAgreement do fixtures :users fixtures :agreements @@ -27,4 +29,4 @@ expect(page).to have_content('Agreement was successfully signed.') end -end \ No newline at end of file +end diff --git a/spec/features/user_registration_spec.rb b/spec/features/user_registration_spec.rb index fed0cbb..864148d 100644 --- a/spec/features/user_registration_spec.rb +++ b/spec/features/user_registration_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.feature "user registration" do scenario "should allow user to create a user account" do visit "/" diff --git a/spec/features/user_spec.rb b/spec/features/user_spec.rb index 9593ae1..244a6b7 100644 --- a/spec/features/user_spec.rb +++ b/spec/features/user_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe "User" do diff --git a/spec/fixtures/carriers.yml b/spec/fixtures/carriers.yml index 63696f2..e72c1f7 100644 --- a/spec/fixtures/carriers.yml +++ b/spec/fixtures/carriers.yml @@ -1,7 +1,9 @@ carrier: name: "test carrier" item_id: "TEST1234" + category: category manufacturer: "babywearing" model: "test model" color: "blue" size: 5 + location: location diff --git a/spec/models/agreement_spec.rb b/spec/models/agreement_spec.rb index df40adf..5d2457b 100644 --- a/spec/models/agreement_spec.rb +++ b/spec/models/agreement_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.describe Agreement do fixtures :users, :agreements @@ -19,4 +21,4 @@ end end end -end \ No newline at end of file +end diff --git a/spec/models/carrier_spec.rb b/spec/models/carrier_spec.rb index ec7c315..5834453 100644 --- a/spec/models/carrier_spec.rb +++ b/spec/models/carrier_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.describe Carrier do fixtures :locations let(:location) { locations(:location) } diff --git a/spec/models/cart_spec.rb b/spec/models/cart_spec.rb index 2924940..0dbb603 100644 --- a/spec/models/cart_spec.rb +++ b/spec/models/cart_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.describe Cart do fixtures(:users) diff --git a/spec/models/category_spec.rb b/spec/models/category_spec.rb index 1022584..90ad85f 100644 --- a/spec/models/category_spec.rb +++ b/spec/models/category_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.describe Category, type: :model do fixtures :categories let!(:category) { categories(:category) } diff --git a/spec/models/loan_spec.rb b/spec/models/loan_spec.rb index dce9010..51b4deb 100644 --- a/spec/models/loan_spec.rb +++ b/spec/models/loan_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.describe Loan do fixtures(:carriers, :users) diff --git a/spec/models/organization_spec.rb b/spec/models/organization_spec.rb index aeffaf3..5303274 100644 --- a/spec/models/organization_spec.rb +++ b/spec/models/organization_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.describe Organization, :type => :model do subject { described_class.new(name: 'name of organization', description: 'test description') diff --git a/spec/models/role_spec.rb b/spec/models/role_spec.rb index e875ac1..b12231b 100644 --- a/spec/models/role_spec.rb +++ b/spec/models/role_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Role do @@ -7,4 +9,4 @@ expect(test_role.macro).to eq(:has_and_belongs_to_many) end end -end \ No newline at end of file +end diff --git a/spec/models/signed_agreement_spec.rb b/spec/models/signed_agreement_spec.rb index cc9745e..648e248 100644 --- a/spec/models/signed_agreement_spec.rb +++ b/spec/models/signed_agreement_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.describe SignedAgreement do fixtures :users fixtures :agreements @@ -16,4 +18,4 @@ it 'is not valid without a signature' do expect(described_class.new(signature: nil)).to_not be_valid end -end \ No newline at end of file +end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index e561487..034f832 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe User do @@ -7,4 +9,4 @@ expect(test_user.macro).to eq(:has_and_belongs_to_many) end end -end \ No newline at end of file +end diff --git a/spec/policies/user_policy.spec.rb b/spec/policies/user_policy.spec.rb index df0479c..a46ea1e 100644 --- a/spec/policies/user_policy.spec.rb +++ b/spec/policies/user_policy.spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe UserPolicy do diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index c6c07cd..0362620 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This file is copied to spec/ when you run 'rails generate rspec:install' require 'spec_helper' # require 'rails_helper' diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 1880900..d2f53cc 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # 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 diff --git a/spec/support/devise.rb b/spec/support/devise.rb index 2b7eeb3..c1f9c35 100644 --- a/spec/support/devise.rb +++ b/spec/support/devise.rb @@ -1,5 +1,7 @@ +# frozen_string_literal: true + RSpec.configure do |config| config.include Devise::Test::ControllerHelpers, type: :controller config.include Devise::Test::ControllerHelpers, type: :view config.include Devise::Test::IntegrationHelpers, type: :feature -end \ No newline at end of file +end diff --git a/spec/support/factory_bot.rb b/spec/support/factory_bot.rb index c7890e4..2e7665c 100644 --- a/spec/support/factory_bot.rb +++ b/spec/support/factory_bot.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.configure do |config| config.include FactoryBot::Syntax::Methods end diff --git a/spec/support/location.rb b/spec/support/location.rb index 09b4ea1..9d2361a 100644 --- a/spec/support/location.rb +++ b/spec/support/location.rb @@ -1,5 +1,7 @@ +# frozen_string_literal: true + RSpec.configure do |config| config.include Devise::Test::ControllerHelpers, type: :controller config.include Devise::Test::ControllerHelpers, type: :view config.include Devise::Test::IntegrationHelpers, type: :feature -end \ No newline at end of file +end