Repository navigation
Conversation
…rubyforgood#2695) - Add nullable organization_id references to workshop_ideas and workshops tables - Add belongs_to :organization, optional: true to WorkshopIdea and Workshop - Update Organization with direct has_many :workshops and has_many :workshop_ideas - Load scoped organizations in WorkshopIdeasController and WorkshopsController forms using currently_affiliated policy scope - Preserve organization_id when promoting WorkshopIdea to Workshop in WorkshopFromIdeaService - Update forms to follow rubyforgood#2693 pattern (single org hidden field vs multiple org select dropdown) - Display organization on index and show views for WorkshopIdea and Workshop - Add comprehensive unit, service, and request specs
- Guard @organizations with fallback to empty array to avoid NoMethodError when unassigned - Update view specs to assign :organizations and verify organization_id select
- Set ActiveRecord::Schema version to 2026_10_18_123640 in db/schema.rb so parallel_rspec and test database setup recognize migrations as applied
| # has_many through | ||
| has_many :categories, through: :categorizable_items | ||
| has_many :sectors, through: :sectorable_items | ||
| has_many :workshops, through: :users |
There was a problem hiding this comment.
this wasn't in the spec, but on org profile we should put both workshops/ideas that are directly connected to the organization, and, also pull through the Affiliation > Person > Workshops/ideas authored (not user_id). would you be ok to add that this this pr so the list that shows on Org profile shows directly and indirectly associated workshops and ideas?
| required: false, | ||
| disabled: promoted_to_workshop, | ||
| prompt: "Select organization", | ||
| selected: (params[:organization_id].presence || f.object.organization_id), |
There was a problem hiding this comment.
we need include_blank: "Select organization" so they can remove an org/leave it blank
|
thanks for working on this, @1steve78 ! left a few comments. and, would you add a seeds features file for this? |
|
Thanks for the review! I'll address all three comments by adding directly and indirectly associated workshops and ideas to the organization profile, allowing the organization field to be cleared using |
Closes #2695
Summary
Workshop variation ideas and story ideas record which organization they originated from, but workshop ideas did not have an
organization_idcolumn or dropdown.This PR implements organization tracking on
workshop_ideasandworkshops, following the#2693scoping pattern:WorkshopIdeato aWorkshop, theorganization_idis retained.WorkshopIdeaandWorkshop.Key Changes
Migrations & Schema
organization:references(type: :integer, null: true, foreign_key: true) toworkshop_ideas.organization:references(type: :integer, null: true, foreign_key: true) toworkshops.Models
WorkshopIdea: Addedbelongs_to :organization, optional: true.Workshop: Addedbelongs_to :organization, optional: true.Organization: Addedhas_many :workshop_ideasand directhas_many :workshops.Controllers & Promotion
WorkshopIdeasController&WorkshopsController: Scoped@organizationsinset_form_variablesusingauthorized_scope(Organization.all, as: :currently_affiliated).order(:name)and permitted:organization_idin strong parameters.WorkshopFromIdeaService: Preservesorganization_idwhen promoting aWorkshopIdeato aWorkshop.Views & Forms
workshop_ideas/_form.html.erb&workshops/_form.html.erb: Implemented the#2693dropdown pattern (hidden input when@organizations.size == 1, select prompt when> 1or admin).workshop_ideas/show.html.erb&workshop_ideas/index.html.erb: Displays organization name / link.workshops/_show_header.html.erb&workshops/_index_row.html.erb: Displays organization name / link.Tests
spec/models/workshop_idea_spec.rb&spec/models/workshop_spec.rb: Verified association and validity with and without an organization.spec/models/organization_spec.rb: Verifiedhave_manyassociations.spec/services/workshop_from_idea_service_spec.rb: Verifiedorganization_idpersistence upon idea promotion.spec/requests/workshop_ideas_spec.rb&spec/requests/workshops_spec.rb: Added admin and regular user request specs covering index, show, form rendering (hidden field vs dropdown), and CRUD actions.How to Test
bin/rails db:migratebundle exec rspec spec/models/workshop_idea_spec.rb spec/models/workshop_spec.rb spec/services/workshop_from_idea_service_spec.rbbundle exec rspec spec/requests/workshop_ideas_spec.rb spec/requests/workshops_spec.rb/workshop_ideas/new-> verify all organizations appear in the Organization dropdown with a prompt./workshop_ideas/new-> verify the organization dropdown is hidden and populated with the user's active organization.WorkshopIdeawith an organization and promote it to aWorkshop-> verify the newWorkshoppreserves the organization.WorkshopIdeaandWorkshopwith and without an organization to verify graceful rendering.Verification