Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/bundler/rubocop-rails-2.27.0
Browse files Browse the repository at this point in the history
  • Loading branch information
awwaiid authored Dec 15, 2024
2 parents ee8e894 + 36f4fe8 commit 2b95d86
Show file tree
Hide file tree
Showing 431 changed files with 6,088 additions and 4,585 deletions.
File renamed without changes.
1 change: 0 additions & 1 deletion .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ Layout/SpaceInsideHashLiteralBraces:
- 'app/models/product_drive_participant.rb'
- 'app/models/distribution.rb'
- 'app/models/donation.rb'
- 'app/models/inventory_item.rb'
- 'app/models/item.rb'
- 'app/models/item_category.rb'
- 'app/models/kit.rb'
Expand Down
46 changes: 41 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,49 @@ Make sure to install **Ubuntu** as your Linux distribution. (This should be defa
<details>
<summary> Bank Users 🏦 </summary>

Pawnee Diaper Bank
A fully set up bank with items, storage locations, donations, distributions, requests, etc.
The bank has multiple partners associated with it.
```
Organization Admin
Email: org_admin1@example.com
Email: org_admin1@example.com
Password: password!
User
Email: user_1@example.com
Password: password!
```

Second City Essentials Bank
A fully set up bank with items, storage locations, donations, distributions, requests, etc.
The bank has four items unique to it (named Second City Item #).
```
Organization Admin
Email: second_city_admin@example.com
Password: password!
User
Email: second_city_user@example.com
Password: password!
```

SF Diaper Bank
A bank which has just been accepted and so is not fully set up. It lacks many of the records the other banks have.
```
Organization Admin
Email: org_admin2@example.com
Password: password!
User
Email: user_2@example.com
Password: password!
```
</details>

<details>
<summary> Partner Users 👥 </summary>

Partners in Pawnee Diaper Bank partner groups
```
Verified Partner
Email: verified@example.com
Expand All @@ -87,10 +116,17 @@ Make sure to install **Ubuntu** as your Linux distribution. (This should be defa
Waiting Approval Partner
Email: waiting@example.com
Password: password!
Another approved partner (with all groups):
Another verified partner (in second partner group):
Email: approved_2@example.com
Pasword: password!
Password: password!
```

Partners in Second City Essentials Bank partner group
```
Verified partner
Email: second_city_senior_center@example.com
Password: password!
```
</details>

Expand Down Expand Up @@ -221,7 +257,7 @@ Before submitting a pull request, run all tests and lints. Fix any broken tests
- Once your first PR has been merged, all commits pushed to an open PR will also run these workflows.
#### Local testing
- Run all lints with `bin/lint`.
- Run all lints with `bin/lint`. (You can lint a single file/folder with `bin/lint {path_to_folder_or_file}`.)
- Run all tests with `bundle exec rspec`
- You can run a single test with `bundle exec rspec {path_to_test_name}_spec.rb` or on a specific line by appending `:LineNumber`
- If you need to skip a failing test, place `pending("Reason you are skipping the test")` into the `it` block rather than skipping with `xit`. This will allow rspec to deliver the error message without causing the test suite to fail.
Expand Down
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ gem "jwt"
gem "newrelic_rpm"
# Used to manage periodic cron-like jobs
gem "clockwork"
# Speed up app boot time by caching expensive operations
gem 'bootsnap', require: false

##### DEPENDENCY PINS ######
# These are gems that aren't used directly, only as dependencies for other gems.
Expand Down
31 changes: 18 additions & 13 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ GEM
bindex (0.8.1)
binding_of_caller (1.0.1)
debug_inspector (>= 1.2.0)
bootsnap (1.18.4)
msgpack (~> 1.2)
bootstrap (5.2.3)
autoprefixer-rails (>= 9.1.0)
popper_js (>= 2.11.6, < 3)
Expand All @@ -120,7 +122,7 @@ GEM
bugsnag (6.27.1)
concurrent-ruby (~> 1.0)
builder (3.3.0)
bullet (7.2.0)
bullet (8.0.0)
activesupport (>= 3.0.0)
uniform_notifier (~> 1.11)
capybara (3.40.0)
Expand All @@ -143,7 +145,7 @@ GEM
coderay (1.1.3)
concurrent-ruby (1.3.4)
connection_pool (2.4.1)
coverband (6.1.2)
coverband (6.1.4)
redis (>= 3.0)
crack (1.0.0)
bigdecimal
Expand All @@ -162,9 +164,9 @@ GEM
irb (~> 1.10)
reline (>= 0.3.8)
debug_inspector (1.2.0)
delayed_job (4.1.11)
delayed_job (4.1.12)
activesupport (>= 3.0, < 8.0)
delayed_job_active_record (4.1.8)
delayed_job_active_record (4.1.10)
activerecord (>= 3.0, < 8.0)
delayed_job (>= 3.0, < 5)
delayed_job_web (1.4.4)
Expand Down Expand Up @@ -259,11 +261,11 @@ GEM
ffi (1.17.0-x86_64-darwin)
ffi (1.17.0-x86_64-linux-gnu)
filterrific (5.2.5)
flipper (1.3.1)
flipper (1.3.2)
concurrent-ruby (< 2)
flipper-active_record (1.3.0)
activerecord (>= 4.2, < 8)
flipper (~> 1.3.0)
flipper-active_record (1.3.2)
activerecord (>= 4.2, < 9)
flipper (~> 1.3.2)
flipper-ui (1.3.1)
erubi (>= 1.0.0, < 2.0.0)
flipper (~> 1.3.1)
Expand Down Expand Up @@ -373,7 +375,7 @@ GEM
method_source (1.1.0)
mini_magick (4.13.2)
mini_mime (1.1.5)
minitest (5.25.1)
minitest (5.25.2)
monetize (1.12.0)
money (~> 6.12)
money (6.16.0)
Expand All @@ -383,12 +385,13 @@ GEM
monetize (~> 1.9)
money (~> 6.13)
railties (>= 3.0)
msgpack (1.7.5)
multi_xml (0.7.1)
bigdecimal (~> 3.1)
multipart-post (2.4.1)
mustermann (3.0.0)
ruby2_keywords (~> 0.0.1)
mutex_m (0.2.0)
mutex_m (0.3.0)
nenv (0.3.0)
net-http-persistent (4.0.2)
connection_pool (~> 2.2)
Expand All @@ -401,7 +404,7 @@ GEM
timeout
net-smtp (0.5.0)
net-protocol
newrelic_rpm (9.13.0)
newrelic_rpm (9.16.0)
nio4r (2.7.3)
nokogiri (1.16.7-arm64-darwin)
racc (~> 1.4)
Expand Down Expand Up @@ -669,7 +672,7 @@ GEM
execjs (>= 0.3.0, < 3)
thor (1.3.2)
tilt (2.2.0)
timeout (0.4.1)
timeout (0.4.2)
ttfunk (1.7.0)
turbo-rails (2.0.10)
actionpack (>= 6.0.0)
Expand Down Expand Up @@ -704,6 +707,7 @@ PLATFORMS
arm64-darwin-21
arm64-darwin-22
arm64-darwin-23
arm64-darwin-24
x86_64-darwin-20
x86_64-darwin-21
x86_64-darwin-22
Expand All @@ -716,6 +720,7 @@ DEPENDENCIES
azure-storage-blob
better_errors
binding_of_caller
bootsnap
bootstrap (~> 5.2)
brakeman
bugsnag
Expand Down Expand Up @@ -798,4 +803,4 @@ DEPENDENCIES
webmock (~> 3.24)

BUNDLED WITH
2.5.22
2.5.23
10 changes: 10 additions & 0 deletions app/assets/stylesheets/custom.scss
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,13 @@
margin-top: 40px;
}
}

.accordion-button.saving::after {
background-image: none;
content: "Saving...";
font-size: 0.875rem;
color: #005568;
transform: none;
width: 3rem;
cursor: not-allowed;
}
6 changes: 5 additions & 1 deletion app/controllers/admin/base_items_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# [Super Admin] Manage the BaseItems -- this is the only place in the app where Base Items can be
# added / modified. Base Items are both the template and common thread for regular Items
#
# See #4656, BaseItems are pending significant changes/possible deletion
class Admin::BaseItemsController < AdminController
def edit
@base_item = BaseItem.find(params[:id])
Expand Down Expand Up @@ -40,7 +42,9 @@ def show

def destroy
@base_item = BaseItem.includes(:items).find(params[:id])
if @base_item.items.any? && @base_item.destroy
if @base_item.id == KitCreateService.find_or_create_kit_base_item!.id
redirect_to admin_base_items_path, alert: "You cannot delete the Kits base item. This is reserved for all Kits."
elsif @base_item.items.empty? && @base_item.destroy
redirect_to admin_base_items_path, notice: "Base Item deleted!"
else
redirect_to admin_base_items_path, alert: "Failed to delete Base Item. Are there still items attached?"
Expand Down
9 changes: 5 additions & 4 deletions app/controllers/admin/organizations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,14 @@ def new

def create
@organization = Organization.new(organization_params)
@user = User.new(user_params)

if @organization.save
Organization.seed_items(@organization)
@user = UserInviteService.invite(name: user_params[:name],
email: user_params[:email],
roles: [Role::ORG_USER, Role::ORG_ADMIN],
resource: @organization)
UserInviteService.invite(name: user_params[:name],
email: user_params[:email],
roles: [Role::ORG_USER, Role::ORG_ADMIN],
resource: @organization)
SnapshotEvent.publish(@organization) # need one to start with
redirect_to admin_organizations_path, notice: "Organization added!"
else
Expand Down
27 changes: 3 additions & 24 deletions app/controllers/audits_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@ def index
end

def show
if Event.read_events?(@audit.organization)
@items = View::Inventory.items_for_location(@audit.storage_location)
else
@inventory_items = @audit.storage_location.inventory_items
end
@items = View::Inventory.items_for_location(@audit.storage_location, include_omitted: true)
end

def edit
Expand All @@ -28,24 +24,7 @@ def finalize
@audit.adjustment = Adjustment.new(organization_id: @audit.organization_id, storage_location_id: @audit.storage_location_id, user_id: current_user.id, comment: 'Created Automatically through the Auditing Process')
@audit.save

inventory_items = @audit.storage_location.inventory_items

inventory_items.each do |inventory_item|
line_item = @audit.line_items.find_by(item: inventory_item.item)

next if line_item.nil?

if line_item.quantity != inventory_item.quantity
@audit.adjustment.line_items.create(item_id: inventory_item.item.id, quantity: line_item.quantity - inventory_item.quantity)
end
end

increasing_adjustment, decreasing_adjustment = @audit.adjustment.split_difference
ActiveRecord::Base.transaction do
@audit.storage_location.increase_inventory(increasing_adjustment.line_item_values)
@audit.storage_location.decrease_inventory(decreasing_adjustment.line_item_values)
AuditEvent.publish(@audit)
end
AuditEvent.publish(@audit)
@audit.finalized!
redirect_to audit_path(@audit), notice: "Audit is Finalized."
rescue => e
Expand Down Expand Up @@ -114,7 +93,7 @@ def set_storage_locations
end

def set_items
@items = current_organization.items.alphabetized
@items = current_organization.items.where(active: true).alphabetized
end

def save_audit_status_and_redirect(params)
Expand Down
Loading

0 comments on commit 2b95d86

Please sign in to comment.