diff --git a/.gitignore b/.gitignore index 987e212de4..1ac41c0742 100644 --- a/.gitignore +++ b/.gitignore @@ -44,3 +44,4 @@ pdx_db_test .DS_Store .ruby-gemset *.pdf +/spec/example_failures.txt diff --git a/app/controllers/admin/barcode_items_controller.rb b/app/controllers/admin/barcode_items_controller.rb new file mode 100644 index 0000000000..d52c2896f9 --- /dev/null +++ b/app/controllers/admin/barcode_items_controller.rb @@ -0,0 +1,53 @@ +class Admin::BarcodeItemsController < AdminController + def edit + @barcode_item = BarcodeItem.find(params[:id]) + end + + def update + @barcode_item = BarcodeItem.find(params[:id]) + if @barcode_item.update(barcode_item_params) + redirect_to admin_barcode_items_path, notice: "Updated Barcode Item!" + else + flash[:error] = "Failed to update this Barcode Item." + render :edit + end + end + + def index + @barcode_items = BarcodeItem.all + end + + def new + @barcode_item = BarcodeItem.new + end + + def create + @barcode_item = BarcodeItem.create(barcode_item_params) + if @barcode_item.save + redirect_to admin_barcode_items_path, notice: "Barcode Item added!" + else + flash[:error] = "Failed to create Barcode Item." + render :new + end + end + + def show + @barcode_item = BarcodeItem.includes(items: [:organization]).find(params[:id]) + @items = @barcode_item.items + end + + def destroy + @barcode_item = BarcodeItem.find(params[:id]) + if @barcode_item.destroy + redirect_to admin_barcode_items_path, notice: "Barcode Item deleted!" + else + redirect_to admin_barcode_items_path, alert: "Failed to delete Barcode Item." + end + end + + private + + def barcode_item_params + params.require(:barcode_item).permit(:name, :key, :category) + end +end diff --git a/app/controllers/canonical_items_controller.rb b/app/controllers/admin/canonical_items_controller.rb similarity index 67% rename from app/controllers/canonical_items_controller.rb rename to app/controllers/admin/canonical_items_controller.rb index e057a2b6e3..d0d5e64d3b 100644 --- a/app/controllers/canonical_items_controller.rb +++ b/app/controllers/admin/canonical_items_controller.rb @@ -1,6 +1,4 @@ -class CanonicalItemsController < ApplicationController - before_action :authorize_user - +class Admin::CanonicalItemsController < AdminController def edit @canonical_item = CanonicalItem.find(params[:id]) end @@ -8,7 +6,7 @@ def edit def update @canonical_item = CanonicalItem.find(params[:id]) if @canonical_item.update(canonical_item_params) - redirect_to canonical_items_path, notice: "Updated canonical item!" + redirect_to admin_canonical_items_path, notice: "Updated canonical item!" else flash[:error] = "Failed to update this canonical item." render :edit @@ -26,7 +24,7 @@ def new def create @canonical_item = CanonicalItem.create(canonical_item_params) if @canonical_item.save - redirect_to canonical_items_path, notice: "Canonical Item added!" + redirect_to admin_canonical_items_path, notice: "Canonical Item added!" else flash[:error] = "Failed to create Canonical Item." render :new @@ -41,18 +39,14 @@ def show def destroy @canonical_item = CanonicalItem.includes(:items).find(params[:id]) if !@canonical_item.items.empty? && @canonical_item.destroy - redirect_to canonical_items_path, notice: "Canonical Item deleted!" + redirect_to admin_canonical_items_path, notice: "Canonical Item deleted!" else - redirect_to admins_path, alert: "Failed to delete Canonical Item. Are there still items attached?" + redirect_to admin_canonical_items_path, alert: "Failed to delete Canonical Item. Are there still items attached?" end end private - def authorize_user - verboten! unless current_user.organization_admin - end - def canonical_item_params params.require(:canonical_item).permit(:name, :key, :category) end diff --git a/app/controllers/admins_controller.rb b/app/controllers/admin/organizations_controller.rb similarity index 58% rename from app/controllers/admins_controller.rb rename to app/controllers/admin/organizations_controller.rb index ea2da58022..bd30134ac7 100644 --- a/app/controllers/admins_controller.rb +++ b/app/controllers/admin/organizations_controller.rb @@ -1,6 +1,4 @@ -class AdminsController < ApplicationController - before_action :authorize_user - +class Admin::OrganizationsController < AdminController def edit @organization = Organization.find(params[:id]) end @@ -8,7 +6,7 @@ def edit def update @organization = Organization.find(params[:id]) if @organization.update(organization_params) - redirect_to admins_path, notice: "Updated organization!" + redirect_to admin_organizations_path, notice: "Updated organization!" else flash[:error] = "Failed to update this organization." render :edit @@ -19,11 +17,6 @@ def index @organizations = Organization.all end - def invite_user - User.invite!(email: params[:email], name: params[:name], organization_id: params[:org]) - redirect_to admins_path, notice: "User invited to organization!" - end - def new @organization = Organization.new end @@ -32,7 +25,7 @@ def create @organization = Organization.create(organization_params) if @organization.save Organization.seed_items(@organization) - redirect_to admins_path, notice: "Organization added!" + redirect_to admin_organizations_path, notice: "Organization added!" else flash[:error] = "Failed to create Organization." render :new @@ -46,19 +39,15 @@ def show def destroy @organization = Organization.find(params[:id]) if @organization.destroy - redirect_to admins_path, notice: "Organization deleted!" + redirect_to admin_organizations_path, notice: "Organization deleted!" else - redirect_to admins_path, alert: "Failed to delete Organization." + redirect_to admin_organizations_path, alert: "Failed to delete Organization." end end private - def authorize_user - verboten! unless current_user.organization_admin - end - def organization_params - params.require(:organization).permit(:name, :short_name, :street, :city, :state, :zipcode, :email, :url, :logo) + params.require(:organization).permit(:name, :short_name, :street, :city, :state, :zipcode, :email, :url, :logo, :intake_location) end end diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb new file mode 100644 index 0000000000..5cc5231d7a --- /dev/null +++ b/app/controllers/admin/users_controller.rb @@ -0,0 +1,40 @@ +class Admin::UsersController < AdminController + def index + @users = User.all + end + + def update; end + + def new + @user = User.new + @organizations = Organization.all + end + + def create + @user = User.new(user_params) + + if @user.save + @user.invite!(@user) + redirect_to admin_users_path, notice: "Created a new user!" + else + flash[:error] = "Failed to create user" + render "admin/users/new" + end + end + + def destroy + @user = User.find_by(id: params[:id]) + if @user.present? + @user.destroy + redirect_to admin_users_path, notice: "Deleted that user" + else + redirect_to admin_users_path, flash: { error: "Couldn't find that user, sorry" } + end + end + + private + + def user_params + params.require(:user).permit(:name, :organization_id, :email, :password, :password_confirmation) + end +end diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb new file mode 100644 index 0000000000..94601cd360 --- /dev/null +++ b/app/controllers/admin_controller.rb @@ -0,0 +1,10 @@ +class AdminController < ApplicationController + before_action :require_admin + layout "admin" + + def require_admin + verboten! unless current_user.super_admin? + end + + def dashboard; end +end \ No newline at end of file diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 1c4d4d12ca..a193a3ae6e 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -10,7 +10,7 @@ class ApplicationController < ActionController::Base rescue_from ActiveRecord::RecordNotFound, with: :not_found! def current_organization - @organization ||= Organization.find_by(short_name: params[:organization_id]) + @organization ||= Organization.find_by(short_name: params[:organization_id]) || current_user&.organization end helper_method :current_organization @@ -24,14 +24,15 @@ def organization_url_options(options = {}) def default_url_options(options = {}) if current_organization.present? && !options.key?(:organization_id) options[:organization_id] = current_organization.to_param - elsif current_user && !current_user.is_superadmin? && current_user.organization.present? + elsif current_user && !current_user.super_admin? && current_user.organization.present? options[:organization_id] = current_user.organization.to_param end options end def authorize_user - verboten! unless params[:controller].include?("devise") || current_organization.id == current_user.organization_id + # params[:controller].include?("admin") || + verboten! unless params[:controller].include?("devise") || current_user.super_admin? || current_organization.id == current_user.organization_id end def not_found! diff --git a/app/controllers/barcode_items_controller.rb b/app/controllers/barcode_items_controller.rb index adbb864d45..484ba3160b 100644 --- a/app/controllers/barcode_items_controller.rb +++ b/app/controllers/barcode_items_controller.rb @@ -58,7 +58,7 @@ def update def destroy begin # If the user is a superadmin, they can delete any Barcode - if current_user.is_superadmin? + if current_user.superadmin? barcode = BarcodeItem.find(params[:id]) # Otherwise it has to be non-global in their organization else diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index 2a12478095..a074a359db 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -1,4 +1,11 @@ class OrganizationsController < ApplicationController + before_action :authorize_admin, except: [:show] + before_action :authorize_user, only: [:show] + + def show + @organization = current_organization + end + def edit @organization = current_organization end @@ -6,15 +13,28 @@ def edit def update @organization = current_organization if @organization.update(organization_params) - redirect_to edit_organization_path(organization_id: current_organization.to_param), notice: "Updated organization!" + redirect_to organization_path(@organization), notice: "Updated your organization!" else - flash[:error] = "Failed to update organization" + flash[:error] = "Failed to update your organization." render :edit end end + def invite_user + User.invite!(email: params[:email], name: params[:name], organization_id: params[:org]) + redirect_to organization_path, notice: "User invited to organization!" + end + private + def authorize_admin + verboten! unless current_user.super_admin? || (current_user.organization_admin? && current_organization.id == current_user.organization_id) + end + + def authorize_user + verboten! unless current_user.super_admin? || (current_organization.id == current_user.organization_id) + end + def organization_params params.require(:organization).permit(:name, :short_name, :street, :city, :state, :zipcode, :email, :url, :logo, :intake_location) end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 2484acead7..8bba17c377 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -2,38 +2,4 @@ class UsersController < ApplicationController def index @users = current_organization.users end - - def update; end - - def new - @user = User.new - end - - def create - @user = User.new(user_params.merge(organization_id: current_organization.id)) - - if @user.save - @user.invite!(@user) - redirect_to users_path, notice: "Created a new user!" - else - flash[:error] = "Failed to create user" - render :new - end - end - - def destroy - @user = current_organization.users.find_by(id: params[:id]) - if @user.present? - @user.destroy - redirect_to users_path, notice: "Deleted that user" - else - redirect_to users_path, flash: { error: "Couldn't find that user, sorry" } - end - end - - private - - def user_params - params.require(:user).permit(:name, :email, :password, :password_confirmation) - end end diff --git a/app/models/adjustment.rb b/app/models/adjustment.rb index d19f411e93..9ecc06e8f3 100644 --- a/app/models/adjustment.rb +++ b/app/models/adjustment.rb @@ -2,7 +2,7 @@ # # Table name: adjustments # -# id :bigint(8) not null, primary key +# id :integer not null, primary key # organization_id :integer # storage_location_id :integer # comment :text diff --git a/app/models/barcode_item.rb b/app/models/barcode_item.rb index a35da72516..7c05632eb6 100644 --- a/app/models/barcode_item.rb +++ b/app/models/barcode_item.rb @@ -2,7 +2,7 @@ # # Table name: barcode_items # -# id :bigint(8) not null, primary key +# id :integer not null, primary key # value :string # barcodeable_id :integer # quantity :integer diff --git a/app/models/diaper_drive_participant.rb b/app/models/diaper_drive_participant.rb index 2dc97a2ecd..7d2ceba02f 100644 --- a/app/models/diaper_drive_participant.rb +++ b/app/models/diaper_drive_participant.rb @@ -2,8 +2,7 @@ # # Table name: diaper_drive_participants # -# id :bigint(8) not null, primary key -# name :string +# id :integer not null, primary key # contact_name :string # email :string # phone :string @@ -15,6 +14,7 @@ # business_name :string # latitude :float # longitude :float +# class DiaperDriveParticipant < ApplicationRecord require "csv" diff --git a/app/models/distribution.rb b/app/models/distribution.rb index 45e34bf2ee..e82bf4b10c 100644 --- a/app/models/distribution.rb +++ b/app/models/distribution.rb @@ -2,7 +2,7 @@ # # Table name: distributions # -# id :bigint(8) not null, primary key +# id :integer not null, primary key # comment :text # created_at :datetime # updated_at :datetime diff --git a/app/models/donation.rb b/app/models/donation.rb index 51b619fe33..c1228e8053 100644 --- a/app/models/donation.rb +++ b/app/models/donation.rb @@ -2,7 +2,7 @@ # # Table name: donations # -# id :bigint(8) not null, primary key +# id :integer not null, primary key # source :string # donation_site_id :integer # created_at :datetime @@ -12,6 +12,7 @@ # organization_id :integer # diaper_drive_participant_id :integer # issued_at :datetime +# money_raised :integer # class Donation < ApplicationRecord diff --git a/app/models/donation_site.rb b/app/models/donation_site.rb index 832c8e31ec..e21ffe0c1e 100644 --- a/app/models/donation_site.rb +++ b/app/models/donation_site.rb @@ -2,7 +2,7 @@ # # Table name: donation_sites # -# id :bigint(8) not null, primary key +# id :integer not null, primary key # name :string # address :string # created_at :datetime diff --git a/app/models/inventory_item.rb b/app/models/inventory_item.rb index c09ec1cde3..fb23093ae6 100644 --- a/app/models/inventory_item.rb +++ b/app/models/inventory_item.rb @@ -2,10 +2,10 @@ # # Table name: inventory_items # -# id :bigint(8) not null, primary key +# id :integer not null, primary key # storage_location_id :integer # item_id :integer -# quantity :integer +# quantity :integer default(0) # created_at :datetime # updated_at :datetime # diff --git a/app/models/item.rb b/app/models/item.rb index aedf5f9933..50caeb156c 100644 --- a/app/models/item.rb +++ b/app/models/item.rb @@ -2,7 +2,7 @@ # # Table name: items # -# id :bigint(8) not null, primary key +# id :integer not null, primary key # name :string # category :string # created_at :datetime diff --git a/app/models/line_item.rb b/app/models/line_item.rb index c7fa25a939..ec491bd5f8 100644 --- a/app/models/line_item.rb +++ b/app/models/line_item.rb @@ -2,7 +2,7 @@ # # Table name: line_items # -# id :bigint(8) not null, primary key +# id :integer not null, primary key # quantity :integer # item_id :integer # itemizable_id :integer diff --git a/app/models/organization.rb b/app/models/organization.rb index a9e254eb2c..6e96b60658 100644 --- a/app/models/organization.rb +++ b/app/models/organization.rb @@ -2,7 +2,7 @@ # # Table name: organizations # -# id :bigint(8) not null, primary key +# id :integer not null, primary key # name :string # short_name :string # email :string diff --git a/app/models/partner.rb b/app/models/partner.rb index 368ee262a4..d54d4eaa70 100644 --- a/app/models/partner.rb +++ b/app/models/partner.rb @@ -2,12 +2,13 @@ # # Table name: partners # -# id :bigint(8) not null, primary key +# id :integer not null, primary key # name :string # email :string # created_at :datetime # updated_at :datetime # organization_id :integer +# status :string # class Partner < ApplicationRecord diff --git a/app/models/request.rb b/app/models/request.rb index 89d699a191..244c6ee31a 100644 --- a/app/models/request.rb +++ b/app/models/request.rb @@ -1,3 +1,17 @@ +# == Schema Information +# +# Table name: requests +# +# id :bigint(8) not null, primary key +# partner_id :bigint(8) +# organization_id :bigint(8) +# status :string default("Active") +# request_items :jsonb +# comments :text +# created_at :datetime not null +# updated_at :datetime not null +# + class Request < ApplicationRecord belongs_to :partner belongs_to :organization diff --git a/app/models/storage_location.rb b/app/models/storage_location.rb index 346253f3fe..71db4fc909 100644 --- a/app/models/storage_location.rb +++ b/app/models/storage_location.rb @@ -2,7 +2,7 @@ # # Table name: storage_locations # -# id :bigint(8) not null, primary key +# id :integer not null, primary key # name :string # address :string # created_at :datetime diff --git a/app/models/transfer.rb b/app/models/transfer.rb index db9979c577..f8064a7009 100644 --- a/app/models/transfer.rb +++ b/app/models/transfer.rb @@ -2,7 +2,7 @@ # # Table name: transfers # -# id :bigint(8) not null, primary key +# id :integer not null, primary key # from_id :integer # to_id :integer # comment :string diff --git a/app/models/user.rb b/app/models/user.rb index bcbc4d74fd..39d53c6739 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -2,7 +2,7 @@ # # Table name: users # -# id :bigint(8) not null, primary key +# id :integer not null, primary key # email :string default(""), not null # encrypted_password :string default(""), not null # reset_password_token :string @@ -26,6 +26,7 @@ # invitations_count :integer default(0) # organization_admin :boolean # name :string default("CHANGEME"), not null +# super_admin :boolean default(FALSE) # class User < ApplicationRecord @@ -38,8 +39,4 @@ class User < ApplicationRecord :recoverable, :rememberable, :trackable, :validatable validates :name, :email, presence: true - - def is_superadmin? - false - end end diff --git a/app/views/canonical_items/_canonical_item_row.html.erb b/app/views/admin/canonical_items/_canonical_item_row.html.erb similarity index 58% rename from app/views/canonical_items/_canonical_item_row.html.erb rename to app/views/admin/canonical_items/_canonical_item_row.html.erb index 7e9b26f0bb..aef4220b27 100644 --- a/app/views/canonical_items/_canonical_item_row.html.erb +++ b/app/views/admin/canonical_items/_canonical_item_row.html.erb @@ -3,8 +3,8 @@ <%= canonical_item_row.category %> <%= canonical_item_row.item_count %> - <%= link_to "View", canonical_item_row, class: "btn btn-primary btn-xs" %> - <%= link_to edit_canonical_item_path(canonical_item_row), class: "btn btn-info btn-xs" do %> + <%= link_to "View", admin_canonical_item_path(canonical_item_row), class: "btn btn-primary btn-xs" %> + <%= link_to edit_admin_canonical_item_path(canonical_item_row), class: "btn btn-info btn-xs" do %> Edit <% end %> diff --git a/app/views/admin/canonical_items/_dropdown.html.erb b/app/views/admin/canonical_items/_dropdown.html.erb new file mode 100644 index 0000000000..be7263b288 --- /dev/null +++ b/app/views/admin/canonical_items/_dropdown.html.erb @@ -0,0 +1,5 @@ + <%= dropdown.association :canonical_item, + collection: @canonical_items, + label: "Base Item", + error: "Please choose what kind of basic item this is", + wrapper: :vertical_input_group %> \ No newline at end of file diff --git a/app/views/admin/canonical_items/_form.html.erb b/app/views/admin/canonical_items/_form.html.erb new file mode 100644 index 0000000000..c0cbf72627 --- /dev/null +++ b/app/views/admin/canonical_items/_form.html.erb @@ -0,0 +1,11 @@ + <%= form.input :name, label: "Name", wrapper: :vertical_input_group do %> + + <%= form.input_field :name, class: "form-control" %> + <% end %> + + <%= form.input :category, label: "Category", wrapper: :vertical_input_group do %> + + <%= form.input_field :category, class: "form-control" %> + <% end %> + + \ No newline at end of file diff --git a/app/views/canonical_items/edit.html.erb b/app/views/admin/canonical_items/edit.html.erb similarity index 60% rename from app/views/canonical_items/edit.html.erb rename to app/views/admin/canonical_items/edit.html.erb index 9f6a016cb0..7e6a066084 100644 --- a/app/views/canonical_items/edit.html.erb +++ b/app/views/admin/canonical_items/edit.html.erb @@ -8,7 +8,7 @@ Home <% end %> -
  • <%= link_to "All Canonical Items", (canonical_items_path) %>
  • +
  • <%= link_to "All Canonical Items", (admin_canonical_items_path) %>
  • Editing <%= @canonical_item.name %>
  • @@ -22,8 +22,12 @@

    Update <%= @canonical_item.name %>

    - - <%= render partial: "form", object: @canonical_item, locals: { submit_text: "Update Canonical Item" } %> +
    + <%= simple_form_for [:admin, @canonical_item], html: { class: 'form-horizontal' }, url: admin_canonical_item_path(@canonical_item) do |f| %> + <%= render partial: "form", object: f %> + <%= f.button :submit, "Update Canonical Item", class:"btn btn-info"%> + <% end %> +
    diff --git a/app/views/canonical_items/index.html.erb b/app/views/admin/canonical_items/index.html.erb similarity index 99% rename from app/views/canonical_items/index.html.erb rename to app/views/admin/canonical_items/index.html.erb index ea21e5134c..680fa6c3df 100644 --- a/app/views/canonical_items/index.html.erb +++ b/app/views/admin/canonical_items/index.html.erb @@ -36,4 +36,5 @@ + diff --git a/app/views/canonical_items/new.html.erb b/app/views/admin/canonical_items/new.html.erb similarity index 61% rename from app/views/canonical_items/new.html.erb rename to app/views/admin/canonical_items/new.html.erb index d9d6a85317..d11ec92805 100644 --- a/app/views/canonical_items/new.html.erb +++ b/app/views/admin/canonical_items/new.html.erb @@ -8,7 +8,7 @@ Home <% end %> -
  • <%= link_to "All Canonical Items", (canonical_items_path) %>
  • +
  • <%= link_to "All Canonical Items", (admin_canonical_items_path) %>
  • New Canonical Item
  • @@ -22,7 +22,12 @@

    New Canonical Item

    - <%= render partial: "form", object: @canonical_item, locals: { submit_text: "Create Canonical Item" } %> +
    + <%= simple_form_for [:admin, @canonical_item], html: { class: 'form-horizontal' } do |f| %> + <%= render partial: "form", object: f %> + <%= f.button :submit, "Create Canonical Item", class:"btn btn-info"%> + <% end %> +
    diff --git a/app/views/canonical_items/show.html.erb b/app/views/admin/canonical_items/show.html.erb similarity index 95% rename from app/views/canonical_items/show.html.erb rename to app/views/admin/canonical_items/show.html.erb index 43bc75ae24..9ddc3702f9 100644 --- a/app/views/canonical_items/show.html.erb +++ b/app/views/admin/canonical_items/show.html.erb @@ -9,7 +9,7 @@ Home <% end %> -
  • <%= link_to "Canonical Items", (canonical_items_path) %>
  • +
  • <%= link_to "Canonical Items", (admin_canonical_items_path) %>
  • <%= @canonical_item.name %>
  • diff --git a/app/views/admin/dashboard.html.erb b/app/views/admin/dashboard.html.erb new file mode 100644 index 0000000000..e69de29bb2 diff --git a/app/views/admin/organizations/_organization_row.html.erb b/app/views/admin/organizations/_organization_row.html.erb new file mode 100644 index 0000000000..20ae49d1b6 --- /dev/null +++ b/app/views/admin/organizations/_organization_row.html.erb @@ -0,0 +1,15 @@ + + <%= organization_row.name %> + <%= link_to organization_row.email, "mailto:#{organization_row.email}" %> + + <%= link_to admin_organization_path(organization_row.id), class: "btn btn-info btn-xs" do %> + <%= fa_icon "view" %> View + <% end %> + <%= link_to edit_admin_organization_path(organization_row.id), class: "btn btn-info btn-xs" do %> + <%= fa_icon "edit" %> Edit + <% end %> + <%= link_to admin_organization_path(organization_row.id), method: :delete, data: { confirm: confirm_delete_msg(organization_row.name) }, class: "btn btn-danger btn-xs" do %> + <%= fa_icon "trash" %> Delete + <% end unless (Organization.count <= 1) %> + + diff --git a/app/views/admins/edit.html.erb b/app/views/admin/organizations/edit.html.erb similarity index 92% rename from app/views/admins/edit.html.erb rename to app/views/admin/organizations/edit.html.erb index 93c58014b8..269b1a61bf 100644 --- a/app/views/admins/edit.html.erb +++ b/app/views/admin/organizations/edit.html.erb @@ -9,7 +9,7 @@ Editing Home <% end %> -
  • <%= link_to "Administration", (admins_path(organization_id: current_user.organization)) %>
  • +
  • <%= link_to "Administration", (admin_organizations_path) %>
  • Editing <%= @organization.name %>
  • @@ -23,7 +23,7 @@ Editing

    Update record for <%= current_organization.name %>

    -<%= simple_form_for @organization, url: admin_path do |f| %> +<%= simple_form_for @organization, url: admin_organization_path do |f| %>
    <%= f.input :name, required: true, autofocus: true %> diff --git a/app/views/admin/organizations/index.html.erb b/app/views/admin/organizations/index.html.erb new file mode 100644 index 0000000000..f4b3d09fb7 --- /dev/null +++ b/app/views/admin/organizations/index.html.erb @@ -0,0 +1,50 @@ +
    + <% content_for :title, "Admin - Organizations" %> +

    + All Diaperbase Organizations + +

    + +
    + + +
    + +
    +
    +
    + <%= link_to new_admin_organization_path, class: "btn btn-success" do %> + <%= fa_icon "plus" %> Add New Organization + <% end %> +
    +
    +
    + +
    + + + + + + + + + + + <%= render partial: "organization_row", collection: @organizations %> + +
    OrganizationContact E-mailActions
    + +
    + +
    +
    +
    +
    +
    diff --git a/app/views/admins/new.html.erb b/app/views/admin/organizations/new.html.erb similarity index 88% rename from app/views/admins/new.html.erb rename to app/views/admin/organizations/new.html.erb index 2352acdd88..36152b4e63 100644 --- a/app/views/admins/new.html.erb +++ b/app/views/admin/organizations/new.html.erb @@ -9,7 +9,7 @@ New Organization Home <% end %> -
  • <%= link_to "Administration", (admins_path(organization_id: current_user.organization)) %>
  • +
  • <%= link_to "Administration", new_admin_organization_path %>
  • New Organization
  • @@ -23,7 +23,7 @@ New Organization

    Add New Diaperbase Organization

    -<%= simple_form_for @organization, url: admins_path do |f| %> +<%= simple_form_for @organization, url: admin_organizations_path do |f| %>
    <%= f.input :name, required: true, autofocus: true %> diff --git a/app/views/admin/organizations/show.html.erb b/app/views/admin/organizations/show.html.erb new file mode 100644 index 0000000000..a93e7cc82e --- /dev/null +++ b/app/views/admin/organizations/show.html.erb @@ -0,0 +1,41 @@ +
    + <% content_for :title, "Organizations - #{@organization.name}" %> +

    + Organization info + for <%= @organization.name %> +

    + +
    + + +
    + + +
    +
    +

    <%= @organization.name %>

    +
    +
    +
    +

    Contact Info

    +

    <%= fa_icon "envelope" %> <%= link_to @organization.email, "mailto:#{@organization.email}" %>

    +
    <%= fa_icon "map-marker" %> <%= @organization.address %>
    +
    +
    +

    Users

    +
      +
    • + <%= @organization.display_users.split(",").join("
    • ").html_safe %> +
    • +
    +
    +
    + +
    +
    \ No newline at end of file diff --git a/app/views/admin/users/index.html.erb b/app/views/admin/users/index.html.erb new file mode 100644 index 0000000000..2cf3d26b13 --- /dev/null +++ b/app/views/admin/users/index.html.erb @@ -0,0 +1,69 @@ +
    + <% content_for :title, "Users" %> +

    + Users +

    + +
    + + +
    + + +
    +
    +
    + <%= link_to new_admin_user_path, class: "btn btn-success" do %> + <%= fa_icon "plus" %> Add a user + <% end %> +
    +
    +
    + +
    + + + + + + + + + + + + <% @users.each do |user| %> + + + + + + + + +
    OrganizationNameEmail
    <%= user.organization.name %><%= user.name %><%= user.email %> + <% if user != current_user %> + <%= link_to admin_user_path(user), method: :delete, confirm: "Are you sure you want to permanently remove this user?", class: "btn btn-danger btn-xs" do %> + <%= fa_icon "trash" %> Delete + <% end %> + <% end %> + + <%= link_to edit_user_registration_path(user), class: "btn btn-info btn-xs" do %> + <%= fa_icon "edit" %> Edit + <% end %> + <% end %> +
    + +
    +
    + +
    +
    +
    +
    diff --git a/app/views/admin/users/new.html.erb b/app/views/admin/users/new.html.erb new file mode 100644 index 0000000000..ab92a05007 --- /dev/null +++ b/app/views/admin/users/new.html.erb @@ -0,0 +1,43 @@ +
    +
    + + + <% content_for :title, "Users - New" %> + +

    Add a user

    + + <%= simple_form_for @user, url: admin_users_path do |f| %> + <%= f.error_notification %> +
    + <%= f.input :organization_id, label: "Organization", wrapper: :vertical_input_group, required: true, autofocus: true do %> + <%= fa_icon "building" %> + <%= f.input_field :organization_id, collection: @organizations, class: "form-control" %> + <% end %> + <%= f.input :name, label: "Name", wrapper: :vertical_input_group, required: true, autofocus: true do %> + <%= fa_icon "user" %> + <%= f.input_field :name, class: "form-control" %> + <% end %> + <%= f.input :email, label: "E-mail", wrapper: :vertical_input_group, required: true do %> + <%= fa_icon "envelope" %> + <%= f.input_field :email, class: "form-control" %> + <% end %> + <%= f.input :password, label: "Password", wrapper: :vertical_input_group, required: true, hint: ("#{@minimum_password_length} characters minimum" if @minimum_password_length) do %> + <%= fa_icon "lock" %> + <%= f.input_field :password, class: "form-control" %> + <% end %> + <%= f.input :password_confirmation, label: "Confirm Password", wrapper: :vertical_input_group, required: true do %> + <%= fa_icon "check" %> + <%= f.input_field :password_confirmation, class: "form-control" %> + <% end %> +
    + +
    + <%= f.button :submit, "Create User", class: "btn-primary" %> + <%= link_to "Cancel", :back, class: "btn btn-secondary" %> +
    + + <% end %> + + +
    +
    diff --git a/app/views/admins/_organization_row.html.erb b/app/views/admins/_organization_row.html.erb deleted file mode 100644 index d8e0aa4601..0000000000 --- a/app/views/admins/_organization_row.html.erb +++ /dev/null @@ -1,13 +0,0 @@ - - <%= organization_row.name %> - <%= link_to organization_row.email, "mailto:#{organization_row.email}" %> - - <%= link_to "View", admin_path(organization_row.id), class: "btn btn-primary btn-xs" %> - <%= link_to edit_admin_path(organization_row.id), class: "btn btn-info btn-xs" do %> - <%= fa_icon "edit" %> Edit - <% end %> - <%= link_to admin_path(organization_row.id), method: :delete, data: { confirm: confirm_delete_msg(organization_row.name) }, class: "btn btn-danger btn-xs" do %> - <%= fa_icon "trash" %> Delete - <% end unless (Organization.count <= 1) %> - - diff --git a/app/views/admins/index.html.erb b/app/views/admins/index.html.erb deleted file mode 100644 index fbe677fbe8..0000000000 --- a/app/views/admins/index.html.erb +++ /dev/null @@ -1,47 +0,0 @@ -
    -<% content_for :title, "Admin - Organizations" %> -

    -All Diaperbase Organizations - -

    - -
    - - -
    - -
    -
    -
    - <%= link_to new_admin_path(organization_id: current_user.organization.id), class: "btn btn-success" do %> - <%= fa_icon "plus" %> Add New Organization - <% end %> -
    -
    -
    - -
    - - - - - - - - - - <%= render partial: "organization_row", collection: @organizations %> - -
    OrganizationContact E-mailActions
    - -
    - -
    -
    -
    diff --git a/app/views/admins/show.html.erb b/app/views/admins/show.html.erb deleted file mode 100644 index f86f01f24c..0000000000 --- a/app/views/admins/show.html.erb +++ /dev/null @@ -1,78 +0,0 @@ -
    - <% content_for :title, "Organizations - #{@organization.name}" %> -

    - Organization info - for <%= @organization.name %> -

    - -
    - - -
    - - -
    -
    -

    <%= @organization.name %>

    -
    -
    -
    -

    Contact Info

    -

    <%= fa_icon "envelope" %> <%= link_to @organization.email, "mailto:#{@organization.email}" %>

    -
    <%= fa_icon "map-marker" %> <%= @organization.address %>
    -
    -
    -

    Users

    -
      -
    • - <%= @organization.display_users.split(",").join("
    • ").html_safe %> -
    • -
    - - <%= fa_icon "plus" %> Invite User to this Organization -
    - - -
    -
    diff --git a/app/views/canonical_items/_form.html.erb b/app/views/canonical_items/_form.html.erb deleted file mode 100644 index e0ed4f5127..0000000000 --- a/app/views/canonical_items/_form.html.erb +++ /dev/null @@ -1,19 +0,0 @@ -<% submit_text ||= form.submit_text %> - -
    - <%= simple_form_for form, html: { class: 'form-horizontal' } do |f| %> - <%= f.input :name, label: "Name", wrapper: :vertical_input_group do %> - - <%= f.input_field :name, class: "form-control" %> - <% end %> - - <%= f.input :category, label: "Category", wrapper: :vertical_input_group do %> - - <%= f.input_field :category, class: "form-control" %> - <% end %> - - - <%= f.button :submit, submit_text, class:"btn btn-info"%> - - <% end %> -
    diff --git a/app/views/layouts/_admin_navbar.html.erb b/app/views/layouts/_admin_navbar.html.erb deleted file mode 100644 index b6060010f2..0000000000 --- a/app/views/layouts/_admin_navbar.html.erb +++ /dev/null @@ -1,71 +0,0 @@ - diff --git a/app/views/layouts/_lte_admin_navbar.html.erb b/app/views/layouts/_lte_admin_navbar.html.erb new file mode 100644 index 0000000000..bf1215774f --- /dev/null +++ b/app/views/layouts/_lte_admin_navbar.html.erb @@ -0,0 +1,36 @@ + \ No newline at end of file diff --git a/app/views/layouts/_lte_admin_sidebar.html.erb b/app/views/layouts/_lte_admin_sidebar.html.erb new file mode 100644 index 0000000000..42f93db10c --- /dev/null +++ b/app/views/layouts/_lte_admin_sidebar.html.erb @@ -0,0 +1,103 @@ + + diff --git a/app/views/layouts/_lte_navbar.html.erb b/app/views/layouts/_lte_navbar.html.erb index 8d10693ad6..0a5de3456e 100644 --- a/app/views/layouts/_lte_navbar.html.erb +++ b/app/views/layouts/_lte_navbar.html.erb @@ -1,93 +1,111 @@ -<% if controller.controller_name != "admins" %> - + + + + + + + +
    \ No newline at end of file diff --git a/app/views/layouts/_lte_sidebar.html.erb b/app/views/layouts/_lte_sidebar.html.erb index ffaec27f55..5a123ecd60 100644 --- a/app/views/layouts/_lte_sidebar.html.erb +++ b/app/views/layouts/_lte_sidebar.html.erb @@ -1,163 +1,141 @@ -<% if controller.controller_name != "admins" %> - - \ No newline at end of file diff --git a/app/views/layouts/_navbar.html.erb b/app/views/layouts/_navbar.html.erb deleted file mode 100644 index 10fb8b33b8..0000000000 --- a/app/views/layouts/_navbar.html.erb +++ /dev/null @@ -1,101 +0,0 @@ - diff --git a/app/views/layouts/admin.html.erb b/app/views/layouts/admin.html.erb new file mode 100644 index 0000000000..fd024efa63 --- /dev/null +++ b/app/views/layouts/admin.html.erb @@ -0,0 +1,104 @@ + + + + + + <%= content_for?(:title) ? yield(:title) : default_title_content %> + + <%= csrf_meta_tags %> + <%= javascript_include_tag 'application' %> + <%= stylesheet_link_tag 'application', media: 'all' %> + + + + + + + + + +
    + +
    + + <% if user_signed_in? %> + + + +
    + + + + <% if user_signed_in? %> + <%= render partial: "layouts/lte_admin_sidebar" %> + <% end %> + + + + + +
    + +
    + <% flash.each do |key, value| %> +
    + <%= fa_icon('times') %> + <%= value %> +
    + <% end %> +
    + <%= yield %> + +
    + + + + + +
    +
    + + + +
    +
    + + + + + diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index a37f9263b4..de2c4d7cc3 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -54,8 +54,8 @@ - - <% if user_signed_in? %> + <% # If there's no organization set, most of these routes won't work. %> + <% if user_signed_in? && current_organization.id.present? %> <%= render partial: "layouts/lte_sidebar" %> <% end %> diff --git a/app/views/organizations/edit.html.erb b/app/views/organizations/edit.html.erb index fb6793cf4b..e189fbfb85 100644 --- a/app/views/organizations/edit.html.erb +++ b/app/views/organizations/edit.html.erb @@ -23,7 +23,7 @@

    Update record for <%= current_organization.name %>

    -<%= simple_form_for current_organization, url: organization_path do |f| %> +<%= simple_form_for current_organization, url: { controller: "organizations", action: "update" } do |f| %> <%= f.error_notification %>
    diff --git a/app/views/organizations/manage.html.erb b/app/views/organizations/manage.html.erb deleted file mode 100644 index 5882fa19ec..0000000000 --- a/app/views/organizations/manage.html.erb +++ /dev/null @@ -1,16 +0,0 @@ -<% content_for :title, "Organizations" %> - -

    Organizations

    - - - - - - - - - - - <%= render partial: "organization_row", collection: @organizations %> - -
    OrganizationsE-mail 
    diff --git a/app/views/organizations/show.html.erb b/app/views/organizations/show.html.erb index 738e7402d6..3e1319c85f 100644 --- a/app/views/organizations/show.html.erb +++ b/app/views/organizations/show.html.erb @@ -1,4 +1,88 @@ -<% content_for :title, "Organizations - #{@organization.name}" %> +<% can_administrate = (current_user.organization_admin? && current_user.organization_id == @organization.id) %> -

    <%= @organization.name %>

    -

    <%= link_to @organization.email, "mailto:#{@organization.email}" %>

    +
    + <% content_for :title, "Organizations - #{@organization.name}" %> +

    + Organization info + for <%= @organization.name %> +

    + +
    + + +
    + + +
    +
    +

    <%= @organization.name %>

    +
    +
    +
    +

    Contact Info

    +

    <%= fa_icon "envelope" %> <%= link_to @organization.email, "mailto:#{@organization.email}" %>

    +
    <%= fa_icon "map-marker" %> <%= @organization.address %>
    +
    +
    +

    Users

    +
      +
    • + <%= @organization.display_users.split(",").join("
    • ").html_safe %> +
    • +
    + +<% if can_administrate %> + <%= fa_icon "plus" %> Invite User to this Organization + +
    + +
    +<% if can_administrate %> + <%= link_to edit_organization_path do %> + Edit + <% end %> +<% end %> + +
    +
    +
    \ No newline at end of file diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb index d09358400b..a7ef5da776 100644 --- a/app/views/users/index.html.erb +++ b/app/views/users/index.html.erb @@ -33,7 +33,6 @@ Name Email - @@ -41,17 +40,6 @@ <%= user.name %> <%= user.email %> - - <% if user != current_user %> - <%= link_to user_path(user), method: :delete, confirm: "Are you sure you want to permanently remove this user?", class: "btn btn-danger btn-xs" do %> - <%= fa_icon "trash" %> Delete - <% end %> - <% else %> - <%= link_to edit_user_registration_path(organization_id: nil), class: "btn btn-info btn-xs" do %> - <%= fa_icon "edit" %> Edit - <% end %> - <% end %> - <% end %> @@ -62,4 +50,5 @@
    + diff --git a/config/routes.rb b/config/routes.rb index 3d0aa48731..1358972de5 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -8,12 +8,17 @@ end mount flipper_app, at: "/flipper" - resources :admins do - collection do - post :invite_user - end + # This is where a superadmin CRUDs all the things + namespace :admin do + get :dashboard + resources :canonical_items + resources :organizations + resources :users + resources :barcode_items end - resources :canonical_items + + # These are globally accessible + resources :canonical_items, only: %i(index show) namespace :api, defaults: { format: "json" } do namespace :v1 do @@ -24,9 +29,12 @@ scope path: ":organization_id" do resources :users - resource :organization do + + # Users that are organization admins can manage the organization itself + resource :organization, only: [:show] + resource :organization, path: :manage, only: %i(edit update) do collection do - get :manage + post :invite_user end end diff --git a/db/migrate/20180915191418_add_super_admin_to_user.rb b/db/migrate/20180915191418_add_super_admin_to_user.rb new file mode 100644 index 0000000000..810d189050 --- /dev/null +++ b/db/migrate/20180915191418_add_super_admin_to_user.rb @@ -0,0 +1,5 @@ +class AddSuperAdminToUser < ActiveRecord::Migration[5.2] + def change + add_column :users, :super_admin, :boolean, default: false + end +end diff --git a/db/schema.rb b/db/schema.rb index d030633066..1b2fd1b134 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -86,8 +86,8 @@ create_table "distributions", id: :serial, force: :cascade do |t| t.text "comment" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" t.integer "storage_location_id" t.integer "partner_id" t.integer "organization_id" @@ -101,8 +101,8 @@ create_table "donation_sites", id: :serial, force: :cascade do |t| t.string "name" t.string "address" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" t.integer "organization_id" t.float "latitude" t.float "longitude" @@ -113,8 +113,8 @@ create_table "donations", id: :serial, force: :cascade do |t| t.string "source" t.integer "donation_site_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" t.integer "storage_location_id" t.text "comment" t.integer "organization_id" @@ -146,15 +146,15 @@ t.integer "storage_location_id" t.integer "item_id" t.integer "quantity", default: 0 - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" end create_table "items", id: :serial, force: :cascade do |t| t.string "name" t.string "category" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" t.integer "barcode_count" t.integer "organization_id" t.integer "canonical_item_id" @@ -193,8 +193,8 @@ create_table "partners", id: :serial, force: :cascade do |t| t.string "name" t.string "email" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" t.integer "organization_id" t.string "status" t.index ["organization_id"], name: "index_partners_on_organization_id" @@ -229,8 +229,8 @@ create_table "storage_locations", id: :serial, force: :cascade do |t| t.string "name" t.string "address" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" t.integer "organization_id" t.float "latitude" t.float "longitude" @@ -272,11 +272,11 @@ t.integer "invitations_count", default: 0 t.boolean "organization_admin" t.string "name", default: "CHANGEME", null: false + t.boolean "super_admin", default: false t.index ["email"], name: "index_users_on_email", unique: true t.index ["invitation_token"], name: "index_users_on_invitation_token", unique: true t.index ["invitations_count"], name: "index_users_on_invitations_count" t.index ["invited_by_id"], name: "index_users_on_invited_by_id" - t.index ["invited_by_type", "invited_by_id"], name: "index_users_on_invited_by_type_and_invited_by_id" t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true end diff --git a/db/seeds.rb b/db/seeds.rb index afb64e7c23..a965f53d1e 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -38,8 +38,17 @@ end Organization.seed_items(sf_org) -user = User.create email: 'test@example.com', password: 'password', password_confirmation: 'password', organization: pdx_org, organization_admin: true -user2 = User.create email: 'test2@example.com', password: 'password', password_confirmation: 'password', organization: sf_org +# super admin +user = User.create email: 'superadmin@example.com', password: 'password', password_confirmation: 'password', organization_admin: false, super_admin: true + +# org admins +user = User.create email: 'org_admin1@example.com', password: 'password', password_confirmation: 'password', organization: pdx_org, organization_admin: true +user2 = User.create email: 'org_admin2@example.com', password: 'password', password_confirmation: 'password', organization: sf_org, organization_admin: true + +# regular users +User.create email: 'user_1@example.com', password: 'password', password_confirmation: 'password', organization: pdx_org, organization_admin: false +User.create email: 'user_2@example.com', password: 'password', password_confirmation: 'password', organization: sf_org, organization_admin: false + DonationSite.find_or_create_by!(name: "Know Thy Food & Warehouse Cafe") do |location| location.address = "3434 SE Milwaukie Ave., Portland, OR 97202" diff --git a/spec/controllers/admin/barcode_items_controller_spec.rb b/spec/controllers/admin/barcode_items_controller_spec.rb new file mode 100644 index 0000000000..cb132e89e0 --- /dev/null +++ b/spec/controllers/admin/barcode_items_controller_spec.rb @@ -0,0 +1,28 @@ +RSpec.describe Admin::BarcodeItemsController, type: :controller do + context "while signed in as a super admin" do + before do + sign_in(@super_admin) + end + + describe "DELETE #destroy" do + it "can delete anyone's barcode" do + allow_any_instance_of(User).to receive(:super_admin?).and_return(true) + other_org = create(:organization) + other_barcode = create(:barcode_item, organization_id: other_org.id, global: false) + expect do + delete :destroy, params: { id: other_barcode.to_param } + end.to change { BarcodeItem.count }.by(-1) + expect(flash.to_h).not_to have_key("error") + end + + it "allows deletion of a global barcode" do + allow_any_instance_of(User).to receive(:super_admin?).and_return(true) + other_barcode = create(:barcode_item, global: true) + expect do + delete :destroy, params: { id: other_barcode.to_param } + end.to change { BarcodeItem.count }.by(-1) + expect(flash.to_h).not_to have_key("error") + end + end + end +end \ No newline at end of file diff --git a/spec/controllers/admin/canonical_items_controller_spec.rb b/spec/controllers/admin/canonical_items_controller_spec.rb new file mode 100644 index 0000000000..190b3ef90d --- /dev/null +++ b/spec/controllers/admin/canonical_items_controller_spec.rb @@ -0,0 +1,104 @@ +RSpec.describe Admin::CanonicalItemsController, type: :controller do + context "while signed in as a super admin" do + before do + sign_in(@super_admin) + end + end +=begin + context "When logged in as an organization admin" do + before do + sign_in(@organization_admin) + end + + describe "GET #new" do + it "returns http success" do + get :new + expect(response).to be_successful + end + end + + describe "POST #create" do + it "redirects" do + post :create, params: { organization: attributes_for(:organization) } + expect(response).to be_redirect + end + end + + describe "GET #index" do + it "returns http success" do + get :index + expect(response).to be_successful + end + end + + describe "GET #show" do + it "returns http success" do + get :show, params: { id: @organization.id } + expect(response).to be_successful + end + end + + describe "GET #edit" do + it "returns http success" do + get :edit, params: { id: @organization.id } + expect(response).to be_successful + end + end + + describe "PUT #update" do + it "redirect" do + put :update, params: { id: @organization.id, organization: { name: "Foo" } } + expect(response).to be_redirect + end + end + + describe "DELETE #destroy" do + it "redirects" do + delete :destroy, params: { id: @organization.id } + expect(response).to be_redirect + end + end + end + + context "When logged in as a non-admin user" do + before do + sign_in(@user) + end + + describe "GET #new" do + it "redirects" do + get :new + expect(response).to be_redirect + end + end + + describe "POST #create" do + it "redirects" do + post :create, params: { organization: attributes_for(:organization) } + expect(response).to be_redirect + end + end + + describe "GET #index" do + it "redirects" do + get :index + expect(response).to be_redirect + end + end + + describe "GET #edit" do + it "redirects" do + get :edit, params: { id: @organization.id } + expect(response).to be_redirect + end + end + + describe "PUT #update" do + it "redirects" do + put :update, params: { id: @organization.id, organization: { name: "Foo" } } + expect(response).to be_redirect + end + end + end +=end +end diff --git a/spec/controllers/admin/organizations_controller_spec.rb b/spec/controllers/admin/organizations_controller_spec.rb new file mode 100644 index 0000000000..f86ceec1fc --- /dev/null +++ b/spec/controllers/admin/organizations_controller_spec.rb @@ -0,0 +1,104 @@ +RSpec.describe Admin::OrganizationsController, type: :controller do + let(:default_params) do + { organization_id: @organization.id } + end + + context "When logged in as a super admin" do + before do + sign_in(@super_admin) + end + + describe "GET #new" do + it "returns http success" do + get :new + expect(response).to be_successful + end + end + + describe "POST #create" do + it "redirects" do + post :create, params: { organization: attributes_for(:organization) } + expect(response).to be_redirect + end + end + + describe "GET #index" do + it "returns http success" do + get :index + expect(response).to be_successful + end + end + end +=begin + + describe "GET #show" do + it "returns http success" do + get :show, params: { id: @organization.id } + expect(response).to be_successful + end + end + + describe "GET #edit" do + it "returns http success" do + get :edit, params: { id: @organization.id } + expect(response).to be_successful + end + end + + describe "PUT #update" do + it "redirect" do + put :update, params: { id: @organization.id, organization: { name: "Foo" } } + expect(response).to be_redirect + end + end + + describe "DELETE #destroy" do + it "redirects" do + delete :destroy, params: { id: @organization.id } + expect(response).to be_redirect + end + end + end + + context "When logged in as a non-admin user" do + before do + sign_in(@user) + end + + describe "GET #new" do + it "redirects" do + get :new + expect(response).to be_redirect + end + end + + describe "POST #create" do + it "redirects" do + post :create, params: { organization: attributes_for(:organization) } + expect(response).to be_redirect + end + end + + describe "GET #index" do + it "redirects" do + get :index + expect(response).to be_redirect + end + end + + describe "GET #edit" do + it "redirects" do + get :edit, params: { id: @organization.id } + expect(response).to be_redirect + end + end + + describe "PUT #update" do + it "redirects" do + put :update, params: { id: @organization.id, organization: { name: "Foo" } } + expect(response).to be_redirect + end + end + end +=end +end diff --git a/spec/controllers/admin/users_controller_spec.rb b/spec/controllers/admin/users_controller_spec.rb new file mode 100644 index 0000000000..cd62ed6ce6 --- /dev/null +++ b/spec/controllers/admin/users_controller_spec.rb @@ -0,0 +1,102 @@ +RSpec.describe Admin::UsersController, type: :controller do + let(:default_params) do + { organization_id: @organization.id } + end +=begin + context "When logged in as an organization admin" do + before do + sign_in(@organization_admin) + end + + describe "GET #new" do + it "returns http success" do + get :new + expect(response).to be_successful + end + end + + describe "POST #create" do + it "redirects" do + post :create, params: { organization: attributes_for(:organization) } + expect(response).to be_redirect + end + end + + describe "GET #index" do + it "returns http success" do + get :index + expect(response).to be_successful + end + end + + describe "GET #show" do + it "returns http success" do + get :show, params: { id: @organization.id } + expect(response).to be_successful + end + end + + describe "GET #edit" do + it "returns http success" do + get :edit, params: { id: @organization.id } + expect(response).to be_successful + end + end + + describe "PUT #update" do + it "redirect" do + put :update, params: { id: @organization.id, organization: { name: "Foo" } } + expect(response).to be_redirect + end + end + + describe "DELETE #destroy" do + it "redirects" do + delete :destroy, params: { id: @organization.id } + expect(response).to be_redirect + end + end + end + + context "When logged in as a non-admin user" do + before do + sign_in(@user) + end + + describe "GET #new" do + it "redirects" do + get :new + expect(response).to be_redirect + end + end + + describe "POST #create" do + it "redirects" do + post :create, params: { organization: attributes_for(:organization) } + expect(response).to be_redirect + end + end + + describe "GET #index" do + it "redirects" do + get :index + expect(response).to be_redirect + end + end + + describe "GET #edit" do + it "redirects" do + get :edit, params: { id: @organization.id } + expect(response).to be_redirect + end + end + + describe "PUT #update" do + it "redirects" do + put :update, params: { id: @organization.id, organization: { name: "Foo" } } + expect(response).to be_redirect + end + end + end +=end +end diff --git a/spec/controllers/admin_controller_spec.rb b/spec/controllers/admin_controller_spec.rb new file mode 100644 index 0000000000..4ec5af9c9f --- /dev/null +++ b/spec/controllers/admin_controller_spec.rb @@ -0,0 +1,7 @@ +RSpec.describe AdminController, type: :controller do + context "while signed in as a super admin" do + before do + sign_in(@super_admin) + end + end +end \ No newline at end of file diff --git a/spec/controllers/admins_controller_spec.rb b/spec/controllers/admins_controller_spec.rb index 3478accd83..22ad1dcf3c 100644 --- a/spec/controllers/admins_controller_spec.rb +++ b/spec/controllers/admins_controller_spec.rb @@ -1,3 +1,4 @@ +=begin require "rails_helper" RSpec.describe AdminsController, type: :controller do @@ -101,3 +102,4 @@ end end end +=end \ No newline at end of file diff --git a/spec/controllers/barcode_items_controller_spec.rb b/spec/controllers/barcode_items_controller_spec.rb index 936e5dcdab..c8361fa831 100644 --- a/spec/controllers/barcode_items_controller_spec.rb +++ b/spec/controllers/barcode_items_controller_spec.rb @@ -70,23 +70,13 @@ end it "disallows a non-superadmin to delete a global barcode" do - allow_any_instance_of(User).to receive(:is_superadmin?).and_return(false) + allow_any_instance_of(User).to receive(:super_admin?).and_return(false) global_barcode = create(:global_barcode_item) delete :destroy, params: default_params.merge(id: global_barcode.to_param) expect(response).not_to be_successful expect(flash[:error]).to match(/permission/) end - it "allows a superadmin to delete anyone's barcode" do - allow_any_instance_of(User).to receive(:is_superadmin?).and_return(true) - other_org = create(:organization) - other_barcode = create(:barcode_item, organization_id: other_org.id, global: false) - expect do - delete :destroy, params: default_params.merge(id: other_barcode.to_param) - end.to change { BarcodeItem.count }.by(-1) - expect(flash.to_h).not_to have_key("error") - end - it "redirects to the index" do delete :destroy, params: default_params.merge(id: create(:barcode_item, global: false, organization_id: @organization.id)) expect(subject).to redirect_to(barcode_items_path) diff --git a/spec/controllers/organizations_controller_spec.rb b/spec/controllers/organizations_controller_spec.rb index e045c72d62..15db40ba07 100644 --- a/spec/controllers/organizations_controller_spec.rb +++ b/spec/controllers/organizations_controller_spec.rb @@ -1,30 +1,84 @@ -require "rails_helper" - RSpec.describe OrganizationsController, type: :controller do let(:default_params) do { organization_id: @organization.to_param } end - before do - sign_in(@user) - end + context "While signed in as a normal user" do + before do + sign_in(@user) + end + + describe "GET #show" do + subject { get :show, params: default_params } + + it "is successful" do + expect(subject).to be_successful + end + end - describe "GET #edit" do - subject { get :edit, params: default_params } + describe "GET #edit" do + subject { get :edit, params: default_params } - it "is successful" do - expect(subject).to be_successful + it "denies access and redirects with an error" do + expect(subject).to have_http_status(:redirect) + expect(flash[:error]).to be_present + end + end + + describe "PATCH #update" do + subject { patch :update, params: default_params.merge(organization: { name: "Thunder Pants" }) } + + it "denies access" do + expect(subject).to have_http_status(:redirect) + expect(flash[:error]).to be_present + end end end - describe "updating an existing organization" do - subject { patch :update, params: default_params.merge(organization: { name: "Thunder Pants" }) } + context "While signed in as an organization admin" do + before do + sign_in(@organization_admin) + end + describe "GET #edit" do + subject { get :edit, params: default_params } + + it "is successful" do + expect(subject).to be_successful + end + end + + describe "PATCH #update" do + subject { patch :update, params: default_params.merge(organization: { name: "Thunder Pants" }) } + + it "can update name" do + expect(subject).to have_http_status(:redirect) + + @organization.reload + expect(@organization.name).to eq "Thunder Pants" + end + end + + context "when attempting to access a different organization" do + let(:other_organization) { create(:organization) } + let(:other_organization_params) do + { organization_id: other_organization.to_param } + end + + describe "GET #show" do + subject { get :show, params: other_organization_params } + + it "redirects to dashboard" do + expect(subject).to redirect_to(dashboard_path) + end + end - it "can update name" do - expect(subject).to have_http_status(:redirect) + describe "GET #edit" do + subject { get :edit, params: other_organization_params } - @organization.reload - expect(@organization.name).to eq "Thunder Pants" + it "redirects to dashboard" do + expect(subject).to redirect_to(dashboard_path) + end + end end end end diff --git a/spec/example_failures.txt b/spec/example_failures.txt new file mode 100644 index 0000000000..a91d2cc78f --- /dev/null +++ b/spec/example_failures.txt @@ -0,0 +1,452 @@ +example_id | status | run_time | +------------------------------------------------------------------------ | ------- | --------------- | +./spec/controllers/adjustments_controller_spec.rb[1:1:1:1] | passed | 0.38939 seconds | +./spec/controllers/adjustments_controller_spec.rb[1:1:2:1] | passed | 0.18584 seconds | +./spec/controllers/adjustments_controller_spec.rb[1:1:3:1] | passed | 0.1684 seconds | +./spec/controllers/adjustments_controller_spec.rb[1:1:4:1:1] | passed | 0.18338 seconds | +./spec/controllers/adjustments_controller_spec.rb[1:1:4:1:2] | passed | 0.16953 seconds | +./spec/controllers/adjustments_controller_spec.rb[1:1:4:1:3] | passed | 0.17081 seconds | +./spec/controllers/adjustments_controller_spec.rb[1:1:4:2:1] | passed | 0.15976 seconds | +./spec/controllers/adjustments_controller_spec.rb[1:1:4:2:2] | passed | 0.16321 seconds | +./spec/controllers/admin/barcode_items_controller_spec.rb[1:1:1:1] | passed | 0.35468 seconds | +./spec/controllers/admin/barcode_items_controller_spec.rb[1:1:1:2] | passed | 0.32209 seconds | +./spec/controllers/admin/organizations_controller_spec.rb[1:1:1:1] | passed | 0.16786 seconds | +./spec/controllers/admin/organizations_controller_spec.rb[1:1:2:1] | passed | 0.32224 seconds | +./spec/controllers/admin/organizations_controller_spec.rb[1:1:3:1] | passed | 0.17114 seconds | +./spec/controllers/barcode_items_controller_spec.rb[1:1:1:1] | passed | 0.17368 seconds | +./spec/controllers/barcode_items_controller_spec.rb[1:1:2:1] | passed | 0.16287 seconds | +./spec/controllers/barcode_items_controller_spec.rb[1:1:3:1] | passed | 0.17631 seconds | +./spec/controllers/barcode_items_controller_spec.rb[1:1:4:1] | passed | 0.17445 seconds | +./spec/controllers/barcode_items_controller_spec.rb[1:1:5:1:1] | passed | 0.33667 seconds | +./spec/controllers/barcode_items_controller_spec.rb[1:1:5:1:2] | passed | 0.33273 seconds | +./spec/controllers/barcode_items_controller_spec.rb[1:1:5:1:3:1] | passed | 0.33489 seconds | +./spec/controllers/barcode_items_controller_spec.rb[1:1:6:1] | passed | 0.33063 seconds | +./spec/controllers/barcode_items_controller_spec.rb[1:1:6:2] | passed | 0.16737 seconds | +./spec/controllers/barcode_items_controller_spec.rb[1:1:6:3] | passed | 0.16864 seconds | +./spec/controllers/barcode_items_controller_spec.rb[1:1:7:1] | passed | 0.35163 seconds | +./spec/controllers/dashboard_controller_spec.rb[1:1:1:1] | passed | 0.18448 seconds | +./spec/controllers/dashboard_controller_spec.rb[1:1:1:2:1] | passed | 0.31264 seconds | +./spec/controllers/dashboard_controller_spec.rb[1:2:1] | passed | 0.30725 seconds | +./spec/controllers/diaper_drive_participants_controller_spec.rb[1:1:1:1] | passed | 0.16785 seconds | +./spec/controllers/diaper_drive_participants_controller_spec.rb[1:1:2:1] | passed | 0.17659 seconds | +./spec/controllers/diaper_drive_participants_controller_spec.rb[1:1:3:1] | passed | 0.17567 seconds | +./spec/controllers/diaper_drive_participants_controller_spec.rb[1:1:4:1] | passed | 0.1644 seconds | +./spec/controllers/diaper_drive_participants_controller_spec.rb[1:1:5:1] | passed | 0.16312 seconds | +./spec/controllers/diaper_drive_participants_controller_spec.rb[1:1:6:1] | passed | 0.17834 seconds | +./spec/controllers/diaper_drive_participants_controller_spec.rb[1:1:6:2] | passed | 0.17779 seconds | +./spec/controllers/diaper_drive_participants_controller_spec.rb[1:1:7:1] | passed | 0.15672 seconds | +./spec/controllers/diaper_drive_participants_controller_spec.rb[1:1:7:2] | passed | 0.16274 seconds | +./spec/controllers/diaper_drive_participants_controller_spec.rb[1:1:8:1] | passed | 0.31166 seconds | +./spec/controllers/diaper_drive_participants_controller_spec.rb[1:2:1] | passed | 0.16492 seconds | +./spec/controllers/distributions_controller_spec.rb[1:1:1:1] | passed | 0.19754 seconds | +./spec/controllers/distributions_controller_spec.rb[1:1:2:1] | passed | 0.17419 seconds | +./spec/controllers/distributions_controller_spec.rb[1:1:3:1] | passed | 0.1647 seconds | +./spec/controllers/distributions_controller_spec.rb[1:1:4:1] | passed | 0.18246 seconds | +./spec/controllers/distributions_controller_spec.rb[1:1:4:2] | passed | 0.20803 seconds | +./spec/controllers/distributions_controller_spec.rb[1:1:5:1] | passed | 0.18648 seconds | +./spec/controllers/distributions_controller_spec.rb[1:1:6:1] | passed | 0.17093 seconds | +./spec/controllers/distributions_controller_spec.rb[1:1:7:1] | passed | 0.32401 seconds | +./spec/controllers/distributions_controller_spec.rb[1:2:1] | passed | 0.16504 seconds | +./spec/controllers/donation_sites_controller_spec.rb[1:1:1:1] | passed | 0.19094 seconds | +./spec/controllers/donation_sites_controller_spec.rb[1:1:2:1] | passed | 0.17648 seconds | +./spec/controllers/donation_sites_controller_spec.rb[1:1:3:1] | passed | 0.16409 seconds | +./spec/controllers/donation_sites_controller_spec.rb[1:1:4:1] | passed | 0.1746 seconds | +./spec/controllers/donation_sites_controller_spec.rb[1:1:5:1] | passed | 0.16742 seconds | +./spec/controllers/donation_sites_controller_spec.rb[1:1:6:1] | passed | 0.32199 seconds | +./spec/controllers/donation_sites_controller_spec.rb[1:2:1] | passed | 0.1843 seconds | +./spec/controllers/donations_controller_spec.rb[1:1:1:1] | passed | 0.1725 seconds | +./spec/controllers/donations_controller_spec.rb[1:1:2:1] | passed | 0.18126 seconds | +./spec/controllers/donations_controller_spec.rb[1:1:3:1] | passed | 0.18902 seconds | +./spec/controllers/donations_controller_spec.rb[1:1:3:2] | passed | 0.18168 seconds | +./spec/controllers/donations_controller_spec.rb[1:1:4:1] | passed | 0.17816 seconds | +./spec/controllers/donations_controller_spec.rb[1:1:4:2] | passed | 0.2101 seconds | +./spec/controllers/donations_controller_spec.rb[1:1:4:3:1] | passed | 0.21035 seconds | +./spec/controllers/donations_controller_spec.rb[1:1:4:3:2] | passed | 0.20981 seconds | +./spec/controllers/donations_controller_spec.rb[1:1:5:1] | passed | 0.19808 seconds | +./spec/controllers/donations_controller_spec.rb[1:1:6:1] | passed | 0.18243 seconds | +./spec/controllers/donations_controller_spec.rb[1:1:7:1] | passed | 0.1803 seconds | +./spec/controllers/donations_controller_spec.rb[1:1:8:1] | passed | 0.32187 seconds | +./spec/controllers/donations_controller_spec.rb[1:1:8:2] | passed | 0.33445 seconds | +./spec/controllers/donations_controller_spec.rb[1:2:1] | passed | 0.17651 seconds | +./spec/controllers/donations_controller_spec.rb[1:2:2] | passed | 0.17637 seconds | +./spec/controllers/items_controller_spec.rb[1:1:1:1] | passed | 0.1775 seconds | +./spec/controllers/items_controller_spec.rb[1:1:2:1] | passed | 0.17239 seconds | +./spec/controllers/items_controller_spec.rb[1:1:3:1] | passed | 0.17027 seconds | +./spec/controllers/items_controller_spec.rb[1:1:4:1] | passed | 0.17283 seconds | +./spec/controllers/items_controller_spec.rb[1:1:5:1] | passed | 0.1784 seconds | +./spec/controllers/items_controller_spec.rb[1:1:6:1] | passed | 0.30628 seconds | +./spec/controllers/items_controller_spec.rb[1:2:1] | passed | 0.16847 seconds | +./spec/controllers/organizations_controller_spec.rb[1:1:1:1] | passed | 0.16912 seconds | +./spec/controllers/organizations_controller_spec.rb[1:1:2:1] | passed | 0.16824 seconds | +./spec/controllers/organizations_controller_spec.rb[1:1:3:1] | passed | 0.18626 seconds | +./spec/controllers/organizations_controller_spec.rb[1:2:1:1] | passed | 0.16827 seconds | +./spec/controllers/organizations_controller_spec.rb[1:2:2:1] | passed | 0.17625 seconds | +./spec/controllers/organizations_controller_spec.rb[1:2:3:1:1] | passed | 0.31873 seconds | +./spec/controllers/organizations_controller_spec.rb[1:2:3:2:1] | passed | 0.32635 seconds | +./spec/controllers/partners_controller_spec.rb[1:1:1] | passed | 0.16759 seconds | +./spec/controllers/partners_controller_spec.rb[1:2:1] | passed | 0.17497 seconds | +./spec/controllers/partners_controller_spec.rb[1:3:1] | passed | 0.1675 seconds | +./spec/controllers/partners_controller_spec.rb[1:4:1] | passed | 0.17018 seconds | +./spec/controllers/partners_controller_spec.rb[1:5:1] | passed | 0.17614 seconds | +./spec/controllers/purchases_controller_spec.rb[1:1:1:1] | passed | 0.16694 seconds | +./spec/controllers/purchases_controller_spec.rb[1:1:2:1] | passed | 0.18023 seconds | +./spec/controllers/purchases_controller_spec.rb[1:1:3:1] | passed | 0.19007 seconds | +./spec/controllers/purchases_controller_spec.rb[1:1:3:2] | passed | 0.17433 seconds | +./spec/controllers/purchases_controller_spec.rb[1:1:4:1] | passed | 0.17365 seconds | +./spec/controllers/purchases_controller_spec.rb[1:1:4:2] | passed | 0.19507 seconds | +./spec/controllers/purchases_controller_spec.rb[1:1:4:3:1] | passed | 0.1954 seconds | +./spec/controllers/purchases_controller_spec.rb[1:1:4:3:2] | passed | 0.21473 seconds | +./spec/controllers/purchases_controller_spec.rb[1:1:5:1] | passed | 0.18706 seconds | +./spec/controllers/purchases_controller_spec.rb[1:1:6:1] | passed | 0.16758 seconds | +./spec/controllers/purchases_controller_spec.rb[1:1:7:1] | passed | 0.18934 seconds | +./spec/controllers/static_controller_spec.rb[1:1:1:1] | passed | 0.20265 seconds | +./spec/controllers/static_controller_spec.rb[1:1:1:2] | passed | 0.21871 seconds | +./spec/controllers/static_controller_spec.rb[1:1:2:1] | passed | 0.16712 seconds | +./spec/controllers/static_controller_spec.rb[1:2:1:1] | passed | 0.19087 seconds | +./spec/controllers/storage_locations_spec.rb[1:1:1:1] | passed | 0.1745 seconds | +./spec/controllers/storage_locations_spec.rb[1:1:2:1] | passed | 0.19663 seconds | +./spec/controllers/storage_locations_spec.rb[1:1:3:1] | passed | 0.19075 seconds | +./spec/controllers/storage_locations_spec.rb[1:1:4:1] | passed | 0.16947 seconds | +./spec/controllers/storage_locations_spec.rb[1:1:5:1] | passed | 0.17089 seconds | +./spec/controllers/storage_locations_spec.rb[1:1:6:1] | passed | 0.32798 seconds | +./spec/controllers/storage_locations_spec.rb[1:2:1] | passed | 0.1655 seconds | +./spec/controllers/transfers_controller_spec.rb[1:1:1:1] | passed | 0.16892 seconds | +./spec/controllers/transfers_controller_spec.rb[1:1:2:1] | passed | 0.19782 seconds | +./spec/controllers/transfers_controller_spec.rb[1:1:2:2] | passed | 0.17648 seconds | +./spec/controllers/transfers_controller_spec.rb[1:1:3:1] | passed | 0.16759 seconds | +./spec/controllers/transfers_controller_spec.rb[1:1:4:1] | passed | 0.18096 seconds | +./spec/controllers/transfers_controller_spec.rb[1:1:5:1] | passed | 0.32986 seconds | +./spec/controllers/transfers_controller_spec.rb[1:2:1] | passed | 0.16456 seconds | +./spec/controllers/users_controller_spec.rb[1:1:1] | passed | 0.18125 seconds | +./spec/features/account_spec.rb[1:1] | passed | 0.67629 seconds | +./spec/features/adjustment_spec.rb[1:1] | passed | 2.45 seconds | +./spec/features/adjustment_spec.rb[1:2] | passed | 1.12 seconds | +./spec/features/adjustment_spec.rb[1:3] | passed | 0.20899 seconds | +./spec/features/admin/canonical_items_spec.rb[1:1:1:1] | passed | 0.20183 seconds | +./spec/features/admin/canonical_items_spec.rb[1:1:1:2] | passed | 0.20099 seconds | +./spec/features/admin/canonical_items_spec.rb[1:1:2:1] | passed | 0.20491 seconds | +./spec/features/admin/canonical_items_spec.rb[1:1:2:2] | passed | 0.18933 seconds | +./spec/features/admin/canonical_items_spec.rb[1:1:3] | passed | 0.18922 seconds | +./spec/features/admin/canonical_items_spec.rb[1:1:4] | passed | 0.18928 seconds | +./spec/features/admin/canonical_items_spec.rb[1:2:1] | passed | 0.32911 seconds | +./spec/features/admin/organizations_spec.rb[1:1] | passed | 0.39629 seconds | +./spec/features/authorization_spec.rb[1:1] | passed | 0.21091 seconds | +./spec/features/barcode_item_spec.rb[1:1:1] | passed | 0.21752 seconds | +./spec/features/barcode_item_spec.rb[1:1:2] | passed | 0.22131 seconds | +./spec/features/barcode_item_spec.rb[1:2:1] | passed | 0.23738 seconds | +./spec/features/barcode_item_spec.rb[1:2:2] | passed | 0.22985 seconds | +./spec/features/barcode_item_spec.rb[1:2:3] | passed | 0.21491 seconds | +./spec/features/barcode_item_spec.rb[1:3:1] | passed | 0.24964 seconds | +./spec/features/barcode_item_spec.rb[1:4] | passed | 0.22329 seconds | +./spec/features/barcode_item_spec.rb[1:5] | passed | 0.20387 seconds | +./spec/features/barcode_item_spec.rb[1:6] | passed | 0.20874 seconds | +./spec/features/dashboard_spec.rb[1:1:1] | passed | 0.24335 seconds | +./spec/features/dashboard_spec.rb[1:2] | passed | 0.39645 seconds | +./spec/features/dashboard_spec.rb[1:3] | passed | 4.13 seconds | +./spec/features/dashboard_spec.rb[1:4] | passed | 1.25 seconds | +./spec/features/diaper_drive_participant_spec.rb[1:1:1] | passed | 0.18104 seconds | +./spec/features/diaper_drive_participant_spec.rb[1:2] | passed | 0.22303 seconds | +./spec/features/diaper_drive_participant_spec.rb[1:3] | passed | 0.19634 seconds | +./spec/features/diaper_drive_participant_spec.rb[1:4] | passed | 0.21396 seconds | +./spec/features/diaper_drive_participant_spec.rb[1:5] | passed | 0.22053 seconds | +./spec/features/diaper_drive_participant_spec.rb[1:6:1] | passed | 0.23796 seconds | +./spec/features/diaper_drive_participant_spec.rb[1:6:2] | passed | 0.23266 seconds | +./spec/features/distribution_spec.rb[1:1] | passed | 0.2745 seconds | +./spec/features/distribution_spec.rb[1:2] | passed | 0.33149 seconds | +./spec/features/distribution_spec.rb[1:3:1] | pending | 0.48185 seconds | +./spec/features/distribution_spec.rb[1:3:2] | pending | 0.23851 seconds | +./spec/features/donation_site_spec.rb[1:1:1] | passed | 0.214 seconds | +./spec/features/donation_site_spec.rb[1:2] | passed | 0.23558 seconds | +./spec/features/donation_site_spec.rb[1:3] | passed | 0.2073 seconds | +./spec/features/donation_site_spec.rb[1:4] | passed | 0.19505 seconds | +./spec/features/donation_site_spec.rb[1:5] | passed | 0.2344 seconds | +./spec/features/donation_site_spec.rb[1:6] | passed | 0.23721 seconds | +./spec/features/donation_spec.rb[1:1:1] | passed | 0.56147 seconds | +./spec/features/donation_spec.rb[1:1:2] | passed | 0.37546 seconds | +./spec/features/donation_spec.rb[1:2:1] | passed | 0.67498 seconds | +./spec/features/donation_spec.rb[1:2:2] | passed | 0.688 seconds | +./spec/features/donation_spec.rb[1:2:3] | passed | 0.65098 seconds | +./spec/features/donation_spec.rb[1:2:4] | passed | 0.6635 seconds | +./spec/features/donation_spec.rb[1:2:5] | passed | 1.06 seconds | +./spec/features/donation_spec.rb[1:2:6] | passed | 1.1 seconds | +./spec/features/donation_spec.rb[1:3:1:1] | passed | 1.1 seconds | +./spec/features/donation_spec.rb[1:3:1:2] | passed | 1.34 seconds | +./spec/features/donation_spec.rb[1:3:1:3] | passed | 1.21 seconds | +./spec/features/donation_spec.rb[1:3:1:4] | passed | 1.57 seconds | +./spec/features/donation_spec.rb[1:3:1:5] | passed | 1.16 seconds | +./spec/features/donation_spec.rb[1:3:1:6] | passed | 1.02 seconds | +./spec/features/donation_spec.rb[1:3:1:7] | passed | 1.02 seconds | +./spec/features/donation_spec.rb[1:3:1:8] | passed | 1.3 seconds | +./spec/features/donation_spec.rb[1:3:1:9] | passed | 1.57 seconds | +./spec/features/donation_spec.rb[1:3:2:1] | passed | 1.02 seconds | +./spec/features/donation_spec.rb[1:3:2:2] | passed | 0.72218 seconds | +./spec/features/donation_spec.rb[1:3:2:3] | pending | 0.3297 seconds | +./spec/features/item_spec.rb[1:1] | passed | 0.26549 seconds | +./spec/features/item_spec.rb[1:2] | passed | 0.22178 seconds | +./spec/features/item_spec.rb[1:3] | passed | 0.24089 seconds | +./spec/features/item_spec.rb[1:4] | passed | 0.22425 seconds | +./spec/features/item_spec.rb[1:5] | passed | 0.23189 seconds | +./spec/features/item_spec.rb[1:6] | passed | 0.2193 seconds | +./spec/features/item_spec.rb[1:7] | passed | 0.19849 seconds | +./spec/features/item_spec.rb[1:8:1] | passed | 1.29 seconds | +./spec/features/log_in_spec.rb[1:1:1] | passed | 0.20031 seconds | +./spec/features/manage_spec.rb[1:1:1] | passed | 0.18503 seconds | +./spec/features/manage_spec.rb[1:2:1] | passed | 0.1805 seconds | +./spec/features/manage_spec.rb[1:2:2] | passed | 0.24586 seconds | +./spec/features/manage_spec.rb[1:2:3:1] | passed | 0.21934 seconds | +./spec/features/organization_spec.rb[1:1:1] | passed | 0.17538 seconds | +./spec/features/organization_spec.rb[1:2:1:1] | passed | 0.24256 seconds | +./spec/features/organization_spec.rb[1:2:2] | passed | 0.20868 seconds | +./spec/features/partner_spec.rb[1:1:1] | passed | 0.19291 seconds | +./spec/features/partner_spec.rb[1:2] | passed | 0.21391 seconds | +./spec/features/partner_spec.rb[1:3] | passed | 0.21377 seconds | +./spec/features/partner_spec.rb[1:4] | passed | 0.21047 seconds | +./spec/features/partner_spec.rb[1:5] | passed | 0.2243 seconds | +./spec/features/purchase_spec.rb[1:1:1] | passed | 0.59841 seconds | +./spec/features/purchase_spec.rb[1:2:1] | passed | 0.64561 seconds | +./spec/features/purchase_spec.rb[1:3:1:1] | passed | 1.07 seconds | +./spec/features/purchase_spec.rb[1:3:1:2] | passed | 1.26 seconds | +./spec/features/purchase_spec.rb[1:3:1:3] | passed | 1.6 seconds | +./spec/features/purchase_spec.rb[1:3:2:1] | passed | 0.52078 seconds | +./spec/features/purchase_spec.rb[1:3:3:1] | pending | 0.52161 seconds | +./spec/features/purchase_spec.rb[1:3:3:2] | pending | 2.53 seconds | +./spec/features/purchase_spec.rb[1:3:3:3] | pending | 0.31064 seconds | +./spec/features/storage_location_spec.rb[1:1] | passed | 0.22948 seconds | +./spec/features/storage_location_spec.rb[1:2] | passed | 0.19748 seconds | +./spec/features/storage_location_spec.rb[1:3] | passed | 0.2116 seconds | +./spec/features/storage_location_spec.rb[1:4] | passed | 0.23278 seconds | +./spec/features/storage_location_spec.rb[1:5] | passed | 0.22284 seconds | +./spec/features/storage_location_spec.rb[1:6] | passed | 0.21076 seconds | +./spec/features/storage_location_spec.rb[1:7] | passed | 0.23094 seconds | +./spec/features/storage_location_spec.rb[1:8] | passed | 0.23704 seconds | +./spec/features/transfer_spec.rb[1:1] | passed | 0.28543 seconds | +./spec/features/transfer_spec.rb[1:2] | passed | 0.27084 seconds | +./spec/helpers/application_helper_spec.rb[1:1:1] | passed | 0.16897 seconds | +./spec/helpers/application_helper_spec.rb[1:2:1:1] | passed | 0.16208 seconds | +./spec/helpers/application_helper_spec.rb[1:2:2:1] | passed | 0.18167 seconds | +./spec/helpers/application_helper_spec.rb[1:2:3:1] | passed | 0.16553 seconds | +./spec/helpers/purchases_helper_spec.rb[1:1] | pending | 0.00001 seconds | +./spec/models/adjustment_spec.rb[1:1:2:1:1] | passed | 0.17828 seconds | +./spec/models/adjustment_spec.rb[1:1:2:1:2] | passed | 0.18636 seconds | +./spec/models/adjustment_spec.rb[1:1:2:2:1] | passed | 0.22636 seconds | +./spec/models/adjustment_spec.rb[1:1:2:3:1] | passed | 0.20122 seconds | +./spec/models/adjustment_spec.rb[1:1:2:3:2] | passed | 0.20778 seconds | +./spec/models/adjustment_spec.rb[1:1:2:4:1] | passed | 0.24782 seconds | +./spec/models/adjustment_spec.rb[1:1:2:5:1] | passed | 0.20091 seconds | +./spec/models/adjustment_spec.rb[1:1:2:6:1] | passed | 0.18101 seconds | +./spec/models/adjustment_spec.rb[1:2:1] | passed | 0.17783 seconds | +./spec/models/adjustment_spec.rb[1:3:1] | passed | 0.18245 seconds | +./spec/models/adjustment_spec.rb[1:4:1] | passed | 0.32203 seconds | +./spec/models/adjustment_spec.rb[1:5:1] | passed | 0.18446 seconds | +./spec/models/barcode_item_spec.rb[1:1:1] | passed | 0.17552 seconds | +./spec/models/barcode_item_spec.rb[1:1:2:1] | passed | 0.19143 seconds | +./spec/models/barcode_item_spec.rb[1:1:3:1] | passed | 0.17626 seconds | +./spec/models/barcode_item_spec.rb[1:1:4:1] | passed | 0.18806 seconds | +./spec/models/barcode_item_spec.rb[1:1:4:2:1] | passed | 0.18071 seconds | +./spec/models/barcode_item_spec.rb[1:1:4:3:1] | passed | 0.1673 seconds | +./spec/models/barcode_item_spec.rb[1:1:4:3:2] | passed | 0.16427 seconds | +./spec/models/barcode_item_spec.rb[1:1:4:3:3] | passed | 0.17458 seconds | +./spec/models/barcode_item_spec.rb[1:1:4:4:1] | passed | 0.17538 seconds | +./spec/models/barcode_item_spec.rb[1:1:4:4:2] | passed | 0.16717 seconds | +./spec/models/barcode_item_spec.rb[1:2:1] | passed | 0.17899 seconds | +./spec/models/barcode_item_spec.rb[1:2:2:1] | passed | 0.1843 seconds | +./spec/models/barcode_item_spec.rb[1:2:3:1] | passed | 0.32803 seconds | +./spec/models/barcode_item_spec.rb[1:2:4:1] | passed | 0.18474 seconds | +./spec/models/barcode_item_spec.rb[1:2:4:2:1] | passed | 0.16937 seconds | +./spec/models/barcode_item_spec.rb[1:2:4:3:1] | passed | 0.16836 seconds | +./spec/models/barcode_item_spec.rb[1:2:4:3:2] | passed | 0.16462 seconds | +./spec/models/barcode_item_spec.rb[1:2:4:3:3] | passed | 0.18443 seconds | +./spec/models/barcode_item_spec.rb[1:2:4:4:1] | passed | 0.16447 seconds | +./spec/models/barcode_item_spec.rb[1:2:4:4:2] | passed | 0.17001 seconds | +./spec/models/barcode_item_spec.rb[1:2:5:1] | passed | 0.18505 seconds | +./spec/models/canonical_item_spec.rb[1:1:1] | passed | 0.1636 seconds | +./spec/models/canonical_item_spec.rb[1:1:2] | passed | 0.16185 seconds | +./spec/models/canonical_item_spec.rb[1:1:3] | passed | 0.16209 seconds | +./spec/models/canonical_item_spec.rb[1:2:1] | passed | 0.18581 seconds | +./spec/models/data_export_spec.rb[1:1:1:1] | passed | 0.17981 seconds | +./spec/models/data_export_spec.rb[1:1:2:1] | passed | 0.41551 seconds | +./spec/models/data_export_spec.rb[1:1:3:1] | passed | 0.35979 seconds | +./spec/models/data_export_spec.rb[1:1:4:1] | passed | 0.3291 seconds | +./spec/models/data_export_spec.rb[1:1:5:1] | passed | 0.32567 seconds | +./spec/models/data_export_spec.rb[1:1:6:1] | passed | 0.33179 seconds | +./spec/models/data_export_spec.rb[1:1:7:1] | passed | 0.32313 seconds | +./spec/models/data_export_spec.rb[1:1:8:1] | passed | 0.33915 seconds | +./spec/models/data_export_spec.rb[1:1:9:1] | passed | 0.31769 seconds | +./spec/models/data_export_spec.rb[1:1:10:1] | passed | 0.3154 seconds | +./spec/models/data_export_spec.rb[1:1:11:1] | passed | 0.33113 seconds | +./spec/models/data_export_spec.rb[1:1:12:1] | passed | 0.33197 seconds | +./spec/models/data_export_spec.rb[1:1:13:1] | passed | 0.32991 seconds | +./spec/models/data_export_spec.rb[1:1:14:1] | passed | 0.33179 seconds | +./spec/models/diaper_drive_participant_spec.rb[1:1:1] | passed | 0.16941 seconds | +./spec/models/diaper_drive_participant_spec.rb[1:1:2] | passed | 0.16462 seconds | +./spec/models/diaper_drive_participant_spec.rb[1:1:3] | passed | 0.1632 seconds | +./spec/models/diaper_drive_participant_spec.rb[1:2:1:1] | passed | 0.19949 seconds | +./spec/models/diaper_drive_participant_spec.rb[1:3:1] | passed | 0.33062 seconds | +./spec/models/diaper_drive_participant_spec.rb[1:4:1] | passed | 0.187 seconds | +./spec/models/distribution_spec.rb[1:1:2:1:1] | passed | 0.18068 seconds | +./spec/models/distribution_spec.rb[1:1:2:1:2] | passed | 0.20853 seconds | +./spec/models/distribution_spec.rb[1:1:2:2:1] | passed | 0.23309 seconds | +./spec/models/distribution_spec.rb[1:1:2:3:1] | passed | 0.19859 seconds | +./spec/models/distribution_spec.rb[1:1:2:3:2] | passed | 0.20398 seconds | +./spec/models/distribution_spec.rb[1:1:2:4:1] | passed | 0.22131 seconds | +./spec/models/distribution_spec.rb[1:1:2:5:1] | passed | 0.20995 seconds | +./spec/models/distribution_spec.rb[1:1:2:6:1] | passed | 0.1947 seconds | +./spec/models/distribution_spec.rb[1:2:1] | passed | 0.17032 seconds | +./spec/models/distribution_spec.rb[1:2:2] | passed | 0.1658 seconds | +./spec/models/distribution_spec.rb[1:2:3] | passed | 0.16146 seconds | +./spec/models/distribution_spec.rb[1:2:4] | passed | 0.18905 seconds | +./spec/models/distribution_spec.rb[1:2:5] | passed | 0.19513 seconds | +./spec/models/distribution_spec.rb[1:3:1:1] | passed | 0.18946 seconds | +./spec/models/distribution_spec.rb[1:4:1] | passed | 0.17971 seconds | +./spec/models/distribution_spec.rb[1:5:1:1] | passed | 0.17735 seconds | +./spec/models/distribution_spec.rb[1:5:2:1] | passed | 0.20917 seconds | +./spec/models/distribution_spec.rb[1:5:3:1] | passed | 0.21766 seconds | +./spec/models/donation_site_spec.rb[1:1:1] | passed | 0.16058 seconds | +./spec/models/donation_site_spec.rb[1:1:2] | passed | 0.17554 seconds | +./spec/models/donation_site_spec.rb[1:1:3] | passed | 0.16279 seconds | +./spec/models/donation_site_spec.rb[1:2:1] | passed | 0.33803 seconds | +./spec/models/donation_site_spec.rb[1:3:1] | passed | 0.16375 seconds | +./spec/models/donation_spec.rb[1:1:2:1:1] | passed | 0.17927 seconds | +./spec/models/donation_spec.rb[1:1:2:1:2] | passed | 0.19946 seconds | +./spec/models/donation_spec.rb[1:1:2:2:1] | passed | 0.23783 seconds | +./spec/models/donation_spec.rb[1:1:2:3:1] | passed | 0.21971 seconds | +./spec/models/donation_spec.rb[1:1:2:3:2] | passed | 0.20207 seconds | +./spec/models/donation_spec.rb[1:1:2:4:1] | passed | 0.22101 seconds | +./spec/models/donation_spec.rb[1:1:2:5:1] | passed | 0.20486 seconds | +./spec/models/donation_spec.rb[1:1:2:6:1] | passed | 0.1957 seconds | +./spec/models/donation_spec.rb[1:2:1] | passed | 0.17502 seconds | +./spec/models/donation_spec.rb[1:2:2] | passed | 0.17716 seconds | +./spec/models/donation_spec.rb[1:2:3] | passed | 0.17752 seconds | +./spec/models/donation_spec.rb[1:2:4] | passed | 0.18208 seconds | +./spec/models/donation_spec.rb[1:2:5] | passed | 0.17841 seconds | +./spec/models/donation_spec.rb[1:2:6] | passed | 0.18352 seconds | +./spec/models/donation_spec.rb[1:3:1] | passed | 0.18236 seconds | +./spec/models/donation_spec.rb[1:3:2] | passed | 0.17713 seconds | +./spec/models/donation_spec.rb[1:4:1:1] | passed | 0.19249 seconds | +./spec/models/donation_spec.rb[1:4:2:1] | passed | 0.19511 seconds | +./spec/models/donation_spec.rb[1:4:2:2] | passed | 0.1879 seconds | +./spec/models/donation_spec.rb[1:5:1:1] | passed | 0.18325 seconds | +./spec/models/donation_spec.rb[1:6:1:1] | passed | 0.19343 seconds | +./spec/models/donation_spec.rb[1:6:2:1] | passed | 0.2078 seconds | +./spec/models/donation_spec.rb[1:6:3:1] | passed | 0.19853 seconds | +./spec/models/donation_spec.rb[1:6:3:2] | passed | 0.19508 seconds | +./spec/models/donation_spec.rb[1:6:3:3] | passed | 0.22275 seconds | +./spec/models/donation_spec.rb[1:6:4:1] | passed | 0.19877 seconds | +./spec/models/donation_spec.rb[1:6:4:2] | passed | 0.19702 seconds | +./spec/models/donation_spec.rb[1:6:4:3] | passed | 0.21801 seconds | +./spec/models/donation_spec.rb[1:6:5:1] | passed | 0.18984 seconds | +./spec/models/donation_spec.rb[1:6:6:1] | passed | 0.20998 seconds | +./spec/models/donation_spec.rb[1:7:1] | passed | 0.17113 seconds | +./spec/models/inventory_item_spec.rb[1:1:1:1] | passed | 0.16769 seconds | +./spec/models/inventory_item_spec.rb[1:1:1:2] | passed | 0.18759 seconds | +./spec/models/inventory_item_spec.rb[1:1:1:3] | passed | 0.17479 seconds | +./spec/models/inventory_item_spec.rb[1:1:2] | passed | 0.16987 seconds | +./spec/models/inventory_item_spec.rb[1:1:3] | passed | 0.16695 seconds | +./spec/models/inventory_item_spec.rb[1:2] | passed | 0.16764 seconds | +./spec/models/item_spec.rb[1:1:1] | passed | 0.16646 seconds | +./spec/models/item_spec.rb[1:1:2] | passed | 0.16355 seconds | +./spec/models/item_spec.rb[1:1:3] | passed | 0.17353 seconds | +./spec/models/item_spec.rb[1:2:1] | passed | 0.17487 seconds | +./spec/models/item_spec.rb[1:2:2] | passed | 0.17429 seconds | +./spec/models/item_spec.rb[1:2:3] | passed | 0.18127 seconds | +./spec/models/item_spec.rb[1:2:4] | passed | 0.18374 seconds | +./spec/models/item_spec.rb[1:2:5] | passed | 0.18624 seconds | +./spec/models/item_spec.rb[1:2:6] | passed | 0.19637 seconds | +./spec/models/item_spec.rb[1:2:7:1] | passed | 0.17097 seconds | +./spec/models/item_spec.rb[1:2:7:2] | passed | 0.32939 seconds | +./spec/models/item_spec.rb[1:3:1:1] | passed | 0.1848 seconds | +./spec/models/item_spec.rb[1:3:1:2] | passed | 0.17519 seconds | +./spec/models/item_spec.rb[1:3:2:1] | passed | 0.17328 seconds | +./spec/models/item_spec.rb[1:3:3:1] | passed | 0.18492 seconds | +./spec/models/item_spec.rb[1:3:4:1] | passed | 0.19131 seconds | +./spec/models/item_spec.rb[1:3:5:1] | passed | 0.21274 seconds | +./spec/models/item_spec.rb[1:3:6:1] | passed | 0.17395 seconds | +./spec/models/item_spec.rb[1:3:6:2] | passed | 0.18535 seconds | +./spec/models/line_item_spec.rb[1:1:1] | passed | 0.17448 seconds | +./spec/models/line_item_spec.rb[1:1:2] | passed | 0.18674 seconds | +./spec/models/line_item_spec.rb[1:1:3] | passed | 0.22885 seconds | +./spec/models/organization_spec.rb[1:1:1:1] | passed | 0.33634 seconds | +./spec/models/organization_spec.rb[1:1:1:2:1] | passed | 0.33774 seconds | +./spec/models/organization_spec.rb[1:2:1] | passed | 0.41148 seconds | +./spec/models/organization_spec.rb[1:3:1] | passed | 0.17226 seconds | +./spec/models/organization_spec.rb[1:4:1] | passed | 0.18392 seconds | +./spec/models/organization_spec.rb[1:5:1] | passed | 0.32997 seconds | +./spec/models/organization_spec.rb[1:5:2] | passed | 0.32435 seconds | +./spec/models/organization_spec.rb[1:6:1] | passed | 0.17283 seconds | +./spec/models/organization_spec.rb[1:6:2] | pending | 0.00001 seconds | +./spec/models/organization_spec.rb[1:7:1] | passed | 0.18097 seconds | +./spec/models/organization_stats_spec.rb[1:1:1:1] | passed | 0.16052 seconds | +./spec/models/organization_stats_spec.rb[1:1:2:1] | passed | 0.16552 seconds | +./spec/models/organization_stats_spec.rb[1:2:1:1] | passed | 0.16191 seconds | +./spec/models/organization_stats_spec.rb[1:2:2:1] | passed | 0.17435 seconds | +./spec/models/organization_stats_spec.rb[1:3:1:1] | passed | 0.16826 seconds | +./spec/models/organization_stats_spec.rb[1:3:2:1] | passed | 0.17861 seconds | +./spec/models/organization_stats_spec.rb[1:4:1:1] | passed | 0.1627 seconds | +./spec/models/organization_stats_spec.rb[1:4:2:1] | passed | 0.18351 seconds | +./spec/models/organization_stats_spec.rb[1:4:3:1] | passed | 0.16098 seconds | +./spec/models/partner_spec.rb[1:1:1] | passed | 0.16381 seconds | +./spec/models/partner_spec.rb[1:1:2] | passed | 0.172 seconds | +./spec/models/partner_spec.rb[1:1:3] | passed | 0.17102 seconds | +./spec/models/partner_spec.rb[1:2:1] | passed | 0.36018 seconds | +./spec/models/partner_spec.rb[1:2:2] | passed | 0.45554 seconds | +./spec/models/purchase_spec.rb[1:1:2:1:1] | passed | 0.19123 seconds | +./spec/models/purchase_spec.rb[1:1:2:1:2] | passed | 0.1932 seconds | +./spec/models/purchase_spec.rb[1:1:2:2:1] | passed | 0.21478 seconds | +./spec/models/purchase_spec.rb[1:1:2:3:1] | passed | 0.19934 seconds | +./spec/models/purchase_spec.rb[1:1:2:3:2] | passed | 0.20501 seconds | +./spec/models/purchase_spec.rb[1:1:2:4:1] | passed | 0.21957 seconds | +./spec/models/purchase_spec.rb[1:1:2:5:1] | passed | 0.20912 seconds | +./spec/models/purchase_spec.rb[1:1:2:6:1] | passed | 0.18942 seconds | +./spec/models/purchase_spec.rb[1:2:1] | passed | 0.17775 seconds | +./spec/models/purchase_spec.rb[1:2:2] | passed | 0.15857 seconds | +./spec/models/purchase_spec.rb[1:2:3] | passed | 0.17417 seconds | +./spec/models/purchase_spec.rb[1:3:1] | passed | 0.17503 seconds | +./spec/models/purchase_spec.rb[1:3:2] | passed | 0.19206 seconds | +./spec/models/purchase_spec.rb[1:4:1:1] | passed | 0.18257 seconds | +./spec/models/purchase_spec.rb[1:5:1:1] | passed | 0.17611 seconds | +./spec/models/purchase_spec.rb[1:6:1:1] | passed | 0.18139 seconds | +./spec/models/purchase_spec.rb[1:6:2:1] | passed | 0.20249 seconds | +./spec/models/purchase_spec.rb[1:6:3:1] | passed | 0.19107 seconds | +./spec/models/purchase_spec.rb[1:6:3:2] | passed | 0.18998 seconds | +./spec/models/purchase_spec.rb[1:6:3:3] | passed | 0.20118 seconds | +./spec/models/purchase_spec.rb[1:6:4:1] | passed | 0.20522 seconds | +./spec/models/purchase_spec.rb[1:6:4:2] | passed | 0.20667 seconds | +./spec/models/purchase_spec.rb[1:6:5:1] | passed | 0.18863 seconds | +./spec/models/storage_location_spec.rb[1:1:1] | passed | 0.16234 seconds | +./spec/models/storage_location_spec.rb[1:1:2] | passed | 0.17429 seconds | +./spec/models/storage_location_spec.rb[1:2:1] | passed | 0.20673 seconds | +./spec/models/storage_location_spec.rb[1:3:1:1] | passed | 0.18344 seconds | +./spec/models/storage_location_spec.rb[1:3:2:1] | passed | 0.18883 seconds | +./spec/models/storage_location_spec.rb[1:3:3:1] | passed | 0.18178 seconds | +./spec/models/storage_location_spec.rb[1:3:4:1] | passed | 0.17864 seconds | +./spec/models/storage_location_spec.rb[1:3:5:1] | passed | 0.20377 seconds | +./spec/models/storage_location_spec.rb[1:3:5:2] | passed | 0.21376 seconds | +./spec/models/storage_location_spec.rb[1:3:6:1] | passed | 0.20651 seconds | +./spec/models/storage_location_spec.rb[1:3:7:1:1] | passed | 0.20919 seconds | +./spec/models/storage_location_spec.rb[1:3:7:1:2] | passed | 0.21217 seconds | +./spec/models/storage_location_spec.rb[1:3:7:2:1] | passed | 0.21892 seconds | +./spec/models/storage_location_spec.rb[1:3:8:1] | passed | 0.19209 seconds | +./spec/models/storage_location_spec.rb[1:3:8:2] | passed | 0.19729 seconds | +./spec/models/storage_location_spec.rb[1:3:9:1] | passed | 0.33403 seconds | +./spec/models/storage_location_spec.rb[1:3:10:1] | passed | 0.56956 seconds | +./spec/models/storage_location_spec.rb[1:3:11:1] | passed | 0.2057 seconds | +./spec/models/storage_location_spec.rb[1:3:11:2] | passed | 0.18533 seconds | +./spec/models/storage_location_spec.rb[1:3:12:1] | passed | 0.20403 seconds | +./spec/models/storage_location_spec.rb[1:3:12:2] | passed | 0.20359 seconds | +./spec/models/storage_location_spec.rb[1:3:13:1] | passed | 0.21026 seconds | +./spec/models/storage_location_spec.rb[1:3:13:2] | passed | 0.21303 seconds | +./spec/models/storage_location_spec.rb[1:3:14:1] | passed | 0.18336 seconds | +./spec/models/transfer_spec.rb[1:1:2:1:1] | passed | 0.19963 seconds | +./spec/models/transfer_spec.rb[1:1:2:1:2] | passed | 0.19798 seconds | +./spec/models/transfer_spec.rb[1:1:2:2:1] | passed | 0.22509 seconds | +./spec/models/transfer_spec.rb[1:1:2:3:1] | passed | 0.213 seconds | +./spec/models/transfer_spec.rb[1:1:2:3:2] | passed | 0.20046 seconds | +./spec/models/transfer_spec.rb[1:1:2:4:1] | passed | 0.22079 seconds | +./spec/models/transfer_spec.rb[1:1:2:5:1] | passed | 0.21373 seconds | +./spec/models/transfer_spec.rb[1:1:2:6:1] | passed | 0.18689 seconds | +./spec/models/transfer_spec.rb[1:2:1] | passed | 0.16934 seconds | +./spec/models/transfer_spec.rb[1:3:1] | passed | 0.1835 seconds | +./spec/models/transfer_spec.rb[1:3:2] | passed | 0.17538 seconds | +./spec/models/transfer_spec.rb[1:4:1] | passed | 0.32712 seconds | +./spec/models/user_spec.rb[1:1:1] | passed | 0.17703 seconds | +./spec/models/user_spec.rb[1:1:2] | passed | 0.16242 seconds | diff --git a/spec/factories/adjustments.rb b/spec/factories/adjustments.rb index daf10ba3fc..170133c39f 100644 --- a/spec/factories/adjustments.rb +++ b/spec/factories/adjustments.rb @@ -2,7 +2,7 @@ # # Table name: adjustments # -# id :bigint(8) not null, primary key +# id :integer not null, primary key # organization_id :integer # storage_location_id :integer # comment :text diff --git a/spec/factories/barcode_items.rb b/spec/factories/barcode_items.rb index 1b505e356d..09383570d5 100644 --- a/spec/factories/barcode_items.rb +++ b/spec/factories/barcode_items.rb @@ -2,7 +2,7 @@ # # Table name: barcode_items # -# id :bigint(8) not null, primary key +# id :integer not null, primary key # value :string # barcodeable_id :integer # quantity :integer diff --git a/spec/factories/diaper_drive_participants.rb b/spec/factories/diaper_drive_participants.rb index 441e2768f7..8fe15c87f4 100644 --- a/spec/factories/diaper_drive_participants.rb +++ b/spec/factories/diaper_drive_participants.rb @@ -2,7 +2,7 @@ # # Table name: diaper_drive_participants # -# id :bigint(8) not null, primary key +# id :integer not null, primary key # contact_name :string # email :string # phone :string @@ -12,6 +12,8 @@ # updated_at :datetime not null # address :string # business_name :string +# latitude :float +# longitude :float # FactoryBot.define do diff --git a/spec/factories/distributions.rb b/spec/factories/distributions.rb index 115735a4d2..e4f4f17070 100644 --- a/spec/factories/distributions.rb +++ b/spec/factories/distributions.rb @@ -2,7 +2,7 @@ # # Table name: distributions # -# id :bigint(8) not null, primary key +# id :integer not null, primary key # comment :text # created_at :datetime # updated_at :datetime diff --git a/spec/factories/donations.rb b/spec/factories/donations.rb index 1305f61184..d165ecfc1d 100644 --- a/spec/factories/donations.rb +++ b/spec/factories/donations.rb @@ -2,7 +2,7 @@ # # Table name: donations # -# id :bigint(8) not null, primary key +# id :integer not null, primary key # source :string # donation_site_id :integer # created_at :datetime @@ -12,6 +12,7 @@ # organization_id :integer # diaper_drive_participant_id :integer # issued_at :datetime +# money_raised :integer # FactoryBot.define do diff --git a/spec/factories/inventory_items.rb b/spec/factories/inventory_items.rb index 3b3aec220b..ae4d3f909e 100644 --- a/spec/factories/inventory_items.rb +++ b/spec/factories/inventory_items.rb @@ -2,10 +2,10 @@ # # Table name: inventory_items # -# id :bigint(8) not null, primary key +# id :integer not null, primary key # storage_location_id :integer # item_id :integer -# quantity :integer +# quantity :integer default(0) # created_at :datetime # updated_at :datetime # diff --git a/spec/factories/items.rb b/spec/factories/items.rb index c9afdb213b..1787ea00ba 100644 --- a/spec/factories/items.rb +++ b/spec/factories/items.rb @@ -2,7 +2,7 @@ # # Table name: items # -# id :bigint(8) not null, primary key +# id :integer not null, primary key # name :string # category :string # created_at :datetime diff --git a/spec/factories/line_items.rb b/spec/factories/line_items.rb index 043e514c75..2423cd08cb 100644 --- a/spec/factories/line_items.rb +++ b/spec/factories/line_items.rb @@ -2,7 +2,7 @@ # # Table name: line_items # -# id :bigint(8) not null, primary key +# id :integer not null, primary key # quantity :integer # item_id :integer # itemizable_id :integer diff --git a/spec/factories/organizations.rb b/spec/factories/organizations.rb index 96ad6040e6..048cf9934b 100644 --- a/spec/factories/organizations.rb +++ b/spec/factories/organizations.rb @@ -2,7 +2,7 @@ # # Table name: organizations # -# id :bigint(8) not null, primary key +# id :integer not null, primary key # name :string # short_name :string # email :string @@ -14,8 +14,9 @@ # city :string # state :string # zipcode :string -# latitude :flaot +# latitude :float # longitude :float +# FactoryBot.define do factory :organization do diff --git a/spec/factories/partners.rb b/spec/factories/partners.rb index 781b5846e3..63ab754fac 100644 --- a/spec/factories/partners.rb +++ b/spec/factories/partners.rb @@ -2,12 +2,13 @@ # # Table name: partners # -# id :bigint(8) not null, primary key +# id :integer not null, primary key # name :string # email :string # created_at :datetime # updated_at :datetime # organization_id :integer +# status :string # FactoryBot.define do diff --git a/spec/factories/storage_locations.rb b/spec/factories/storage_locations.rb index 733a424a43..7b5b2377bb 100644 --- a/spec/factories/storage_locations.rb +++ b/spec/factories/storage_locations.rb @@ -2,12 +2,14 @@ # # Table name: storage_locations # -# id :bigint(8) not null, primary key +# id :integer not null, primary key # name :string # address :string # created_at :datetime # updated_at :datetime # organization_id :integer +# latitude :float +# longitude :float # FactoryBot.define do diff --git a/spec/factories/transfers.rb b/spec/factories/transfers.rb index a3051e7d60..8496249453 100644 --- a/spec/factories/transfers.rb +++ b/spec/factories/transfers.rb @@ -2,7 +2,7 @@ # # Table name: transfers # -# id :bigint(8) not null, primary key +# id :integer not null, primary key # from_id :integer # to_id :integer # comment :string diff --git a/spec/factories/users.rb b/spec/factories/users.rb index cc183ac713..92b8ac41ee 100644 --- a/spec/factories/users.rb +++ b/spec/factories/users.rb @@ -2,7 +2,7 @@ # # Table name: users # -# id :bigint(8) not null, primary key +# id :integer not null, primary key # email :string default(""), not null # encrypted_password :string default(""), not null # reset_password_token :string @@ -26,6 +26,7 @@ # invitations_count :integer default(0) # organization_admin :boolean # name :string default("CHANGEME"), not null +# super_admin :boolean default(FALSE) # FactoryBot.define do @@ -37,7 +38,13 @@ organization { Organization.try(:first) || create(:organization) } factory :organization_admin do + name "Very Organized Admin" organization_admin true end + + factory :super_admin do + name "Administrative User" + super_admin true + end end end diff --git a/spec/features/admin/admin_namespace_spec.rb b/spec/features/admin/admin_namespace_spec.rb new file mode 100644 index 0000000000..8a9630bfaf --- /dev/null +++ b/spec/features/admin/admin_namespace_spec.rb @@ -0,0 +1,19 @@ +RSpec.feature "Admin Namespace" do + context "While signed in as an admin user" do + before do + sign_in(@super_admin) + end + end + + context "While signed in as a normal user" do + before do + sign_in(@user) + end + end + + context "While signed in as an organizational admin" do + before do + sign_in(@organization_admin) + end + end +end \ No newline at end of file diff --git a/spec/features/admin/barcode_items_spec.rb b/spec/features/admin/barcode_items_spec.rb new file mode 100644 index 0000000000..542667f9de --- /dev/null +++ b/spec/features/admin/barcode_items_spec.rb @@ -0,0 +1,2 @@ +RSpec.feature "Barcode Items Admin" do +end \ No newline at end of file diff --git a/spec/features/admin/canonical_items_spec.rb b/spec/features/admin/canonical_items_spec.rb new file mode 100644 index 0000000000..c837b0949a --- /dev/null +++ b/spec/features/admin/canonical_items_spec.rb @@ -0,0 +1,82 @@ +RSpec.feature "Canonical Item Admin" do + context "While signed in as an organizationl admin" do + before do + sign_in(@super_admin) + end + + let!(:url_prefix) {} + context "when creating a new canonical item" do + before do + visit new_admin_canonical_item_path + end + + let(:canonical_item_traits) { attributes_for(:canonical_item) } + + scenario "it succeeds when creating a new canonical item with good data" do + fill_in "Name", with: canonical_item_traits[:name] + fill_in "Category", with: canonical_item_traits[:category] + click_button "Create Canonical Item" + + expect(page.find(".alert")).to have_content "added" + end + + scenario "it fails when creating a new canonical item with empty attributes" do + click_button "Create Canonical Item" + expect(page.find(".alert")).to have_content "ailed" + end + end + + context "when updating an existing canonical item" do + before do + visit edit_admin_canonical_item_path(canonical_item) + end + let(:canonical_item) { CanonicalItem.first } + + scenario "succeeds when changing the name" do + fill_in "Name", with: canonical_item.name + " new" + click_button "Update Canonical Item" + expect(page.find(".alert")).to have_content "pdated" + end + + scenario "fails when updating the name to empty" do + fill_in "Name", with: "" + click_button "Update Canonical Item" + expect(page.find(".alert")).to have_content "ailed" + end + end + + scenario "viewing a listing of all Canonical Items that shows a summary of its sub-items" do + canonical_item = CanonicalItem.first + create_list(:item, 2, canonical_item: canonical_item) + count = canonical_item.item_count + visit admin_canonical_items_path + expect(page).to have_content(canonical_item.name) + within "table tbody tr#canonical-item-row-#{canonical_item.to_param} td:nth-child(3)" do + expect(page).to have_content(count) + end + end + + scenario "viewing a single Canonical Item" do + canonical_item = CanonicalItem.first + visit admin_canonical_item_path(canonical_item) + expect(page).to have_content(canonical_item.name) + end + end + + context "While signed in as a normal user" do + before do + sign_in(@user) + end + scenario "A normal user can't see anything" do + visit new_admin_canonical_item_path + expect(page).to have_content("Access Denied") + visit admin_canonical_items_path + expect(page).to have_content("Access Denied") + canonical_item = create(:canonical_item) + visit admin_canonical_item_path(canonical_item) + expect(page).to have_content("Access Denied") + visit edit_admin_canonical_item_path(canonical_item) + expect(page).to have_content("Access Denied") + end + end +end \ No newline at end of file diff --git a/spec/features/admin/organizations_spec.rb b/spec/features/admin/organizations_spec.rb new file mode 100644 index 0000000000..a7164e0739 --- /dev/null +++ b/spec/features/admin/organizations_spec.rb @@ -0,0 +1,34 @@ +RSpec.feature "Organizations Admin" do + before :each do + sign_in(@super_admin) + end + + scenario "creating a new organization" do + visit new_admin_organization_path + screenshot_and_open_image + click_link "Add New Organization" + org_params = attributes_for(:organization) + fill_in "Name", with: org_params[:name] + fill_in "Short name", with: org_params[:short_name] + fill_in "Url", with: org_params[:url] + fill_in "Email", with: org_params[:email] + fill_in "Street", with: "1234 Banana Drive" + fill_in "City", with: "Boston" + select("MA", from: "State") + fill_in "Zipcode", with: "12345" + + click_on "Create" + + expect(page).to have_content("All Diaperbase Organizations") + + within("tr.#{org_params[:short_name]}") do + first(:link, "View").click + end + + expect(page).to have_content(org_params[:name]) + expect(page).to have_content("Banana") + expect(page).to have_content("Boston") + expect(page).to have_content("MA") + expect(page).to have_content("12345") + end +end \ No newline at end of file diff --git a/spec/features/admin/users_spec.rb b/spec/features/admin/users_spec.rb new file mode 100644 index 0000000000..e69de29bb2 diff --git a/spec/features/admins_spec.rb b/spec/features/admins_spec.rb deleted file mode 100644 index 28eaa2a79f..0000000000 --- a/spec/features/admins_spec.rb +++ /dev/null @@ -1,69 +0,0 @@ -RSpec.feature "Site Administration", type: :feature do - before do - sign_in(@organization_admin) - visit "/admins" - end - - scenario "Admin can create a new organization" do - click_link "Add New Organization" - org_params = attributes_for(:organization) - fill_in "Name", with: org_params[:name] - fill_in "Short name", with: org_params[:short_name] - fill_in "Url", with: org_params[:url] - fill_in "Email", with: org_params[:email] - fill_in "Street", with: "1234 Banana Drive" - fill_in "City", with: "Boston" - select("MA", from: "State") - fill_in "Zipcode", with: "12345" - - click_button "Create" - - expect(page).to have_content("All Diaperbase Organizations") - - within("tr", text: org_params[:name]) do - first(:link, "View").click - end - - expect(page).to have_content(org_params[:name]) - expect(page).to have_content("Banana") - expect(page).to have_content("Boston") - expect(page).to have_content("MA") - expect(page).to have_content("12345") - end - - scenario "Admin can bail back to their own site" do - expect(page).to have_xpath("//a[@href='#{dashboard_path(organization_id: @organization.to_param)}']") - end - - scenario "An admin can edit the properties for an organization" do - click_link "Edit" - fill_in "Name", with: "Something else" - click_button "Update" - expect(page).to have_content("pdated organization") - expect(page).to have_content("Something else") - end - - context "When looking at a single organization" do - before do - @organization.users << create(:user, email: "yet_another_user@website.com") - visit admin_path(@organization.id) - end - scenario "Admin can view details about an organization, including the users" do - expect(page).to have_content(@organization.email) - expect(page).to have_content(@organization.address) - @organization.users.each do |u| - expect(page).to have_content(u.email) - end - end - - scenario "An admin can add a new user to an organization" do - page.find("a", text: "Invite User to this Organization").click - allow(User).to receive(:invite!).and_return(true) - within "#addUserModal" do - fill_in "email", with: "some_new_user@website.com" - click_button "Invite User" - end - expect(page).to have_content("invited to organization") - end - end -end diff --git a/spec/features/authorization_spec.rb b/spec/features/authorization_spec.rb index 27ba2f68c4..ae324d831a 100644 --- a/spec/features/authorization_spec.rb +++ b/spec/features/authorization_spec.rb @@ -1,7 +1,7 @@ RSpec.feature "Authorization", type: :feature do scenario "should redirect to dashboard when unauthorized user attempts access" do sign_in(@user) - visit "/admins" + visit "/admin/dashboard" expect(page.find("h1")).to have_content "Dashboard" expect(page.find(".alert")).to have_content "Access Denied" end diff --git a/spec/features/canonical_item_spec.rb b/spec/features/canonical_item_spec.rb deleted file mode 100644 index e507464e91..0000000000 --- a/spec/features/canonical_item_spec.rb +++ /dev/null @@ -1,75 +0,0 @@ -RSpec.feature "Canonical Item management", type: :feature do - context "While signed in as an organizationl admin" do - before do - sign_in(@organization_admin) - end - - let!(:url_prefix) {} - scenario "Admin can create a new canonical item" do - visit "/canonical_items/new" - canonical_item_traits = attributes_for(:canonical_item) - fill_in "Name", with: canonical_item_traits[:name] - fill_in "Category", with: canonical_item_traits[:category] - click_button "Create Canonical Item" - - expect(page.find(".alert")).to have_content "added" - end - - scenario "Admin creates a new canonical item with empty attributes" do - visit "/canonical_items/new" - click_button "Create Canonical Item" - - expect(page.find(".alert")).to have_content "ailed" - end - - scenario "Admin updates an existing canonical item" do - canonical_item = CanonicalItem.first - visit "/canonical_items/#{canonical_item.to_param}/edit" - fill_in "Name", with: canonical_item.name + " new" - click_button "Update Canonical Item" - expect(page.find(".alert")).to have_content "pdated" - end - - scenario "Admin updates an existing item with empty attributes" do - canonical_item = CanonicalItem.first - visit "/canonical_items/#{canonical_item.to_param}/edit" - fill_in "Name", with: "" - click_button "Update Canonical Item" - expect(page.find(".alert")).to have_content "ailed" - end - - scenario "Admin can see a listing of all Canonical Items that shows a summary of its sub-items" do - canonical_item = CanonicalItem.first - create_list(:item, 2, canonical_item: canonical_item) - count = canonical_item.item_count - visit "/canonical_items" - expect(page).to have_content(canonical_item.name) - within "table tbody tr#canonical-item-row-#{canonical_item.to_param} td:nth-child(3)" do - expect(page).to have_content(count) - end - end - - scenario "Admin can view a single Canonical Item" do - canonical_item = CanonicalItem.first - visit "/canonical_items/#{canonical_item.to_param}" - expect(page).to have_content(canonical_item.name) - end - end - - context "While signed in as a normal user" do - before do - sign_in(@user) - end - scenario "A normal user can't see anything" do - visit "/canonical_items/new" - expect(page).to have_content("Access Denied") - visit "/canonical_items/index" - expect(page).to have_content("Access Denied") - canonical_item = create(:canonical_item) - visit "/canonical_items/#{canonical_item.id}" - expect(page).to have_content("Access Denied") - visit "/canonical_items/#{canonical_item.id}/edit" - expect(page).to have_content("Access Denied") - end - end -end diff --git a/spec/features/manage_spec.rb b/spec/features/manage_spec.rb new file mode 100644 index 0000000000..36b6403eb8 --- /dev/null +++ b/spec/features/manage_spec.rb @@ -0,0 +1,45 @@ +RSpec.feature "Organization Administration", type: :feature do + subject { "/#{@organization.to_param}/organization" } + context "while signed in as a normal user" do + before do + sign_in(@user) + visit subject + end + + scenario "the user does not see an edit link" do + expect(page).not_to have_link("Edit") + end + end + context "while signed in as an organization admin" do + before do + sign_in(@organization_admin) + visit subject + end + + scenario "the user can bail back to their own site" do + expect(page).to have_xpath("//a[@href='#{dashboard_path(organization_id: @organization.to_param)}']") + end + + scenario "An admin can edit the properties for an organization" do + click_on "Edit" + fill_in "Name", with: "Something else" + click_button "Update" + expect(page).to have_content("pdated your organization") + expect(page).to have_content("Something else") + end + + context "When looking at a single organization" do + before do + @organization.users << create(:user, email: "yet_another_user@website.com") + visit subject + end + scenario "Admin can view details about an organization, including the users" do + expect(page).to have_content(@organization.email) + expect(page).to have_content(@organization.address) + @organization.users.each do |u| + expect(page).to have_content(u.email) + end + end + end + end +end diff --git a/spec/features/organization_spec.rb b/spec/features/organization_spec.rb index a3b7d9de4e..9d141287ab 100644 --- a/spec/features/organization_spec.rb +++ b/spec/features/organization_spec.rb @@ -1,15 +1,43 @@ RSpec.feature "Organization management", type: :feature do - before do - sign_in(@user) - end let!(:url_prefix) { "/#{@organization.to_param}" } - scenario "When editing their organization, the user is prompted with placeholder text and a more helpful error message to ensure correct URL format" do - visit url_prefix + "/organization/edit" - fill_in "Url", with: "www.diaperbase.com" - click_button "Update" - - fill_in "Url", with: "http://www.diaperbase.com" - click_button "Update" - expect(page.find(".alert")).to have_content "pdated" + + context "while signed in as a normal user" do + before do + sign_in(@user) + end + + scenario "The user can see summary details about the organization" do + visit url_prefix + "/organization" + end + end + context "while signed in as an organization admin" do + before do + sign_in(@organization_admin) + end + + describe "Editing the organization" do + before do + visit url_prefix + "/manage/edit" + end + scenario "the user is prompted with placeholder text and a more helpful error message to ensure correct URL format" do + fill_in "Url", with: "www.diaperbase.com" + click_on "Update" + + fill_in "Url", with: "http://www.diaperbase.com" + click_on "Update" + expect(page.find(".alert")).to have_content "pdated" + end + end + + scenario "Adding a new user to an organization" do + allow(User).to receive(:invite!).and_return(true) + visit url_prefix + "/organization" + click_on "Invite User to this Organization" + within "#addUserModal" do + fill_in "email", with: "some_new_user@website.com" + click_on "Invite User" + end + expect(page).to have_content("invited to organization") + end end end diff --git a/spec/models/adjustment_spec.rb b/spec/models/adjustment_spec.rb index 78507aa93e..a507c1eb05 100644 --- a/spec/models/adjustment_spec.rb +++ b/spec/models/adjustment_spec.rb @@ -2,7 +2,7 @@ # # Table name: adjustments # -# id :bigint(8) not null, primary key +# id :integer not null, primary key # organization_id :integer # storage_location_id :integer # comment :text diff --git a/spec/models/barcode_item_spec.rb b/spec/models/barcode_item_spec.rb index c8bc59db3b..68994321e3 100644 --- a/spec/models/barcode_item_spec.rb +++ b/spec/models/barcode_item_spec.rb @@ -2,7 +2,7 @@ # # Table name: barcode_items # -# id :bigint(8) not null, primary key +# id :integer not null, primary key # value :string # barcodeable_id :integer # quantity :integer @@ -12,6 +12,7 @@ # global :boolean default(FALSE) # barcodeable_type :string default("Item") # + RSpec.shared_examples "common barcode tests" do |barcode_item_factory| describe "item >" do it "is invalid without an item associated with it" do diff --git a/spec/models/diaper_drive_participant_spec.rb b/spec/models/diaper_drive_participant_spec.rb index 9607537443..4f8d6fdacd 100644 --- a/spec/models/diaper_drive_participant_spec.rb +++ b/spec/models/diaper_drive_participant_spec.rb @@ -2,7 +2,7 @@ # # Table name: diaper_drive_participants # -# id :bigint(8) not null, primary key +# id :integer not null, primary key # contact_name :string # email :string # phone :string @@ -14,6 +14,7 @@ # business_name :string # latitude :float # longitude :float +# require "rails_helper" diff --git a/spec/models/distribution_spec.rb b/spec/models/distribution_spec.rb index e15508df91..ef864d1fb8 100644 --- a/spec/models/distribution_spec.rb +++ b/spec/models/distribution_spec.rb @@ -2,7 +2,7 @@ # # Table name: distributions # -# id :bigint(8) not null, primary key +# id :integer not null, primary key # comment :text # created_at :datetime # updated_at :datetime diff --git a/spec/models/donation_site_spec.rb b/spec/models/donation_site_spec.rb index 3a78ce1d9e..58fc7a1990 100644 --- a/spec/models/donation_site_spec.rb +++ b/spec/models/donation_site_spec.rb @@ -2,7 +2,7 @@ # # Table name: donation_sites # -# id :bigint(8) not null, primary key +# id :integer not null, primary key # name :string # address :string # created_at :datetime diff --git a/spec/models/donation_spec.rb b/spec/models/donation_spec.rb index 12b0774766..a13a5328fa 100644 --- a/spec/models/donation_spec.rb +++ b/spec/models/donation_spec.rb @@ -2,7 +2,7 @@ # # Table name: donations # -# id :bigint(8) not null, primary key +# id :integer not null, primary key # source :string # donation_site_id :integer # created_at :datetime @@ -12,6 +12,7 @@ # organization_id :integer # diaper_drive_participant_id :integer # issued_at :datetime +# money_raised :integer # RSpec.describe Donation, type: :model do diff --git a/spec/models/inventory_item_spec.rb b/spec/models/inventory_item_spec.rb index a70e686b03..c4e4ca7c04 100644 --- a/spec/models/inventory_item_spec.rb +++ b/spec/models/inventory_item_spec.rb @@ -2,10 +2,10 @@ # # Table name: inventory_items # -# id :bigint(8) not null, primary key +# id :integer not null, primary key # storage_location_id :integer # item_id :integer -# quantity :integer +# quantity :integer default(0) # created_at :datetime # updated_at :datetime # diff --git a/spec/models/item_spec.rb b/spec/models/item_spec.rb index 812c4fc7fb..1c55b02327 100644 --- a/spec/models/item_spec.rb +++ b/spec/models/item_spec.rb @@ -2,7 +2,7 @@ # # Table name: items # -# id :bigint(8) not null, primary key +# id :integer not null, primary key # name :string # category :string # created_at :datetime diff --git a/spec/models/line_item_spec.rb b/spec/models/line_item_spec.rb index c2b595bede..d4401569b4 100644 --- a/spec/models/line_item_spec.rb +++ b/spec/models/line_item_spec.rb @@ -2,7 +2,7 @@ # # Table name: line_items # -# id :bigint(8) not null, primary key +# id :integer not null, primary key # quantity :integer # item_id :integer # itemizable_id :integer diff --git a/spec/models/organization_spec.rb b/spec/models/organization_spec.rb index 4e9a737c17..56a214d99c 100644 --- a/spec/models/organization_spec.rb +++ b/spec/models/organization_spec.rb @@ -2,7 +2,7 @@ # # Table name: organizations # -# id :bigint(8) not null, primary key +# id :integer not null, primary key # name :string # short_name :string # email :string diff --git a/spec/models/partner_spec.rb b/spec/models/partner_spec.rb index 5a0c25f254..eb79ebad0b 100644 --- a/spec/models/partner_spec.rb +++ b/spec/models/partner_spec.rb @@ -2,12 +2,13 @@ # # Table name: partners # -# id :bigint(8) not null, primary key +# id :integer not null, primary key # name :string # email :string # created_at :datetime # updated_at :datetime # organization_id :integer +# status :string # RSpec.describe Partner, type: :model do diff --git a/spec/models/storage_location_spec.rb b/spec/models/storage_location_spec.rb index 7c2b659405..83fce905c1 100644 --- a/spec/models/storage_location_spec.rb +++ b/spec/models/storage_location_spec.rb @@ -2,7 +2,7 @@ # # Table name: storage_locations # -# id :bigint(8) not null, primary key +# id :integer not null, primary key # name :string # address :string # created_at :datetime diff --git a/spec/models/transfer_spec.rb b/spec/models/transfer_spec.rb index cb749b7971..77e15325b6 100644 --- a/spec/models/transfer_spec.rb +++ b/spec/models/transfer_spec.rb @@ -2,7 +2,7 @@ # # Table name: transfers # -# id :bigint(8) not null, primary key +# id :integer not null, primary key # from_id :integer # to_id :integer # comment :string diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 3b7635dbaa..325b7ba680 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -2,7 +2,7 @@ # # Table name: users # -# id :bigint(8) not null, primary key +# id :integer not null, primary key # email :string default(""), not null # encrypted_password :string default(""), not null # reset_password_token :string @@ -26,6 +26,7 @@ # invitations_count :integer default(0) # organization_admin :boolean # name :string default("CHANGEME"), not null +# super_admin :boolean default(FALSE) # RSpec.describe User, type: :model do diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 375afd3f1b..c9ae0492a1 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -7,6 +7,7 @@ require "rspec/rails" require "capybara/rails" require "capybara/rspec" +require "capybara-screenshot/rspec" require "pry" # Add additional requires below this line. Rails is not loaded until this point! @@ -44,6 +45,18 @@ # Enable JS for Capybara tests Capybara.javascript_driver = :chrome +Capybara::Screenshot.autosave_on_failure = true +# The driver name should match the Capybara driver config name. +Capybara::Screenshot.register_driver(:chrome) do |driver, path| + driver.browser.save_screenshot(path) +end + +# Set the asset host so that the screenshots look nice +Capybara.asset_host = "http://localhost:3000" + +# Only keep the most recent run +Capybara::Screenshot.prune_strategy = :keep_last_run + RSpec.configure do |config| config.include Devise::Test::ControllerHelpers, type: :controller config.include Devise::Test::ControllerHelpers, type: :view @@ -57,6 +70,9 @@ # Location for fixtures (logo, etc) config.fixture_path = "#{::Rails.root}/spec/fixtures" + # Persistence for failures + config.example_status_persistence_file_path = "spec/example_failures.txt" + # Make FactoryBot easier. config.include FactoryBot::Syntax::Methods @@ -94,10 +110,12 @@ # prepare a default @organization and @user to always be available for testing Rails.logger.info "\n\n-~=> Creating DEFAULT organization" @organization = create(:organization, name: "DEFAULT") - Rails.logger.info "\n\n-~=> Creating DEFAULT admin & user" - @organization_admin = create(:organization_admin, name: "DEFAULT ADMIN") + Rails.logger.info "\n\n-~=> Creating DEFAULT admins & user" + @organization_admin = create(:organization_admin, name: "DEFAULT ORG ADMIN", organization: @organization) @user = create(:user, organization: @organization, name: "DEFAULT USER") + @super_admin = create(:super_admin, name: "DEFAULT SUPERADMIN") + # Print the name of the example being run Rails.logger.info "\n\n-~=> #{self.class.description} ::::::::::::::::::::::" end @@ -109,16 +127,6 @@ # 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.