- <%= f.input :project_id,
+ <%= f.input :organization_id,
as: :select,
label: "Organization",
- collection: @projects_array,
- selected: f.object.project_id,
+ collection: @organizations_array,
+ selected: f.object.organization_id,
input_html: {
class: "block w-full rounded-md border-gray-300 shadow-sm focus:ring-blue-500 focus:border-blue-500"
},
From 8b3239eb9d191272d00feb38cbab5e3fe8c63e7c Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Tue, 20 Jan 2026 01:14:18 +0000
Subject: [PATCH 04/10] Remove old Project files and update factories/specs
Co-authored-by: maebeale <7607813+maebeale@users.noreply.github.com>
---
app/controllers/organizations_controller.rb | 31 ++--
.../project_statuses_controller.rb | 68 --------
app/controllers/project_users_controller.rb | 13 --
app/controllers/projects_controller.rb | 138 ----------------
app/decorators/project_decorator.rb | 29 ----
app/decorators/project_status_decorator.rb | 3 -
app/decorators/project_user_decorator.rb | 5 -
app/models/project.rb | 106 ------------
app/models/project_obligation.rb | 5 -
app/models/project_status.rb | 7 -
app/models/project_user.rb | 18 ---
...004745_rename_projects_to_organizations.rb | 59 -------
...004745_rename_projects_to_organizations.rb | 98 +++++++++++
db/schema.rb | 146 ++++++++---------
.../decorators/organization_decorator_spec.rb | 4 +
.../organization_status_decorator_spec.rb | 4 +
spec/decorators/project_decorator_spec.rb | 4 -
.../project_status_decorator_spec.rb | 4 -
spec/factories/addresses.rb | 2 +-
spec/factories/community_news.rb | 8 +-
...gations.rb => organization_obligations.rb} | 2 +-
...t_statuses.rb => organization_statuses.rb} | 2 +-
...project_users.rb => organization_users.rb} | 4 +-
.../{projects.rb => organizations.rb} | 4 +-
spec/factories/reports.rb | 2 +-
spec/factories/stories.rb | 2 +-
spec/factories/story_ideas.rb | 4 +-
spec/lib/domain_theme_spec.rb | 4 +-
spec/models/location_spec.rb | 2 +-
spec/models/monthly_report_spec.rb | 2 +-
...pec.rb => organization_obligation_spec.rb} | 8 +-
.../{project_spec.rb => organization_spec.rb} | 14 +-
...us_spec.rb => organization_status_spec.rb} | 6 +-
...user_spec.rb => organization_user_spec.rb} | 12 +-
spec/models/report_spec.rb | 2 +-
spec/models/user_spec.rb | 10 +-
spec/models/workshop_log_spec.rb | 2 +-
spec/requests/community_news_spec.rb | 2 +-
spec/requests/organization_statuses_spec.rb | 118 ++++++++++++++
spec/requests/organizations_spec.rb | 143 ++++++++++++++++
spec/requests/project_statuses_spec.rb | 153 ------------------
spec/requests/projects_spec.rb | 143 ----------------
spec/requests/resources_spec.rb | 2 +-
spec/requests/stories_spec.rb | 4 +-
spec/requests/story_ideas_spec.rb | 4 +-
spec/requests/workshop_logs_spec.rb | 4 +-
.../organization_statuses_routing_spec.rb | 38 +++++
spec/routing/organizations_routing_spec.rb | 38 +++++
spec/routing/project_statuses_routing_spec.rb | 38 -----
spec/routing/projects_routing_spec.rb | 38 -----
.../community_news/edit.html.erb_spec.rb | 6 +-
.../community_news/index.html.erb_spec.rb | 50 ++++++
.../views/community_news/new.html.erb_spec.rb | 4 +-
.../community_news/show.html.erb_spec.rb | 2 +-
.../edit.html.erb_spec.rb | 19 +++
.../index.html.erb_spec.rb | 23 +++
.../new.html.erb_spec.rb | 19 +++
.../show.html.erb_spec.rb | 6 +-
.../views/organizations/edit.html.erb_spec.rb | 43 +++++
.../organizations/index.html.erb_spec.rb | 25 +++
spec/views/organizations/new.html.erb_spec.rb | 28 ++++
.../show.html.erb_spec.rb | 8 +-
.../project_statuses/edit.html.erb_spec.rb | 19 ---
.../project_statuses/index.html.erb_spec.rb | 23 ---
.../project_statuses/new.html.erb_spec.rb | 19 ---
spec/views/projects/edit.html.erb_spec.rb | 43 -----
spec/views/projects/index.html.erb_spec.rb | 25 ---
spec/views/projects/new.html.erb_spec.rb | 28 ----
spec/views/stories/edit.html.erb_spec.rb | 4 +-
spec/views/stories/new.html.erb_spec.rb | 4 +-
spec/views/stories/show.html.erb_spec.rb | 2 +-
.../show_with_story_idea.html.erb_spec.rb | 2 +-
spec/views/story_ideas/edit.html.erb_spec.rb | 4 +-
spec/views/story_ideas/new.html.erb_spec.rb | 4 +-
spec/views/story_ideas/show.html.erb_spec.rb | 2 +-
spec/views/users/show.html.erb_spec.rb | 103 +++++++++---
76 files changed, 898 insertions(+), 1176 deletions(-)
delete mode 100644 app/controllers/project_statuses_controller.rb
delete mode 100644 app/controllers/project_users_controller.rb
delete mode 100644 app/controllers/projects_controller.rb
delete mode 100644 app/decorators/project_decorator.rb
delete mode 100644 app/decorators/project_status_decorator.rb
delete mode 100644 app/decorators/project_user_decorator.rb
delete mode 100644 app/models/project.rb
delete mode 100644 app/models/project_obligation.rb
delete mode 100644 app/models/project_status.rb
delete mode 100644 app/models/project_user.rb
delete mode 100644 db/migrate/20260120004745_rename_projects_to_organizations.rb
create mode 100644 db/migrate/20260203004745_rename_projects_to_organizations.rb
create mode 100644 spec/decorators/organization_decorator_spec.rb
create mode 100644 spec/decorators/organization_status_decorator_spec.rb
delete mode 100644 spec/decorators/project_decorator_spec.rb
delete mode 100644 spec/decorators/project_status_decorator_spec.rb
rename spec/factories/{project_obligations.rb => organization_obligations.rb} (63%)
rename spec/factories/{project_statuses.rb => organization_statuses.rb} (68%)
rename spec/factories/{project_users.rb => organization_users.rb} (56%)
rename spec/factories/{projects.rb => organizations.rb} (68%)
rename spec/models/{project_obligation_spec.rb => organization_obligation_spec.rb} (61%)
rename spec/models/{project_spec.rb => organization_spec.rb} (65%)
rename spec/models/{project_status_spec.rb => organization_status_spec.rb} (52%)
rename spec/models/{project_user_spec.rb => organization_user_spec.rb} (51%)
create mode 100644 spec/requests/organization_statuses_spec.rb
create mode 100644 spec/requests/organizations_spec.rb
delete mode 100644 spec/requests/project_statuses_spec.rb
delete mode 100644 spec/requests/projects_spec.rb
create mode 100644 spec/routing/organization_statuses_routing_spec.rb
create mode 100644 spec/routing/organizations_routing_spec.rb
delete mode 100644 spec/routing/project_statuses_routing_spec.rb
delete mode 100644 spec/routing/projects_routing_spec.rb
create mode 100644 spec/views/community_news/index.html.erb_spec.rb
create mode 100644 spec/views/organization_statuses/edit.html.erb_spec.rb
create mode 100644 spec/views/organization_statuses/index.html.erb_spec.rb
create mode 100644 spec/views/organization_statuses/new.html.erb_spec.rb
rename spec/views/{project_statuses => organization_statuses}/show.html.erb_spec.rb (56%)
create mode 100644 spec/views/organizations/edit.html.erb_spec.rb
create mode 100644 spec/views/organizations/index.html.erb_spec.rb
create mode 100644 spec/views/organizations/new.html.erb_spec.rb
rename spec/views/{projects => organizations}/show.html.erb_spec.rb (51%)
delete mode 100644 spec/views/project_statuses/edit.html.erb_spec.rb
delete mode 100644 spec/views/project_statuses/index.html.erb_spec.rb
delete mode 100644 spec/views/project_statuses/new.html.erb_spec.rb
delete mode 100644 spec/views/projects/edit.html.erb_spec.rb
delete mode 100644 spec/views/projects/index.html.erb_spec.rb
delete mode 100644 spec/views/projects/new.html.erb_spec.rb
diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb
index 179e427a1..524b4b837 100644
--- a/app/controllers/organizations_controller.rb
+++ b/app/controllers/organizations_controller.rb
@@ -1,31 +1,25 @@
class OrganizationsController < ApplicationController
+ include AhoyTracking
before_action :set_organization, only: [ :show, :edit, :update, :destroy ]
def index
per_page = params[:number_of_items_per_page].presence || 25
- unpaginated = Organization.search_by_params(params).order(:name)
+ unpaginated = Organization.includes(:logo_attachment, :windows_type, :project_status)
+ .search_by_params(params).order(:name)
@organizations_count = unpaginated.count
@organizations = unpaginated.paginate(page: params[:page], per_page: per_page)
set_index_variables
end
def show
- @organization.increment_view_count!(session: session, request: request)
-
- # Reuse WorkshopLogsController#index logic programmatically
- workshop_logs_controller = WorkshopLogsController.new
- workshop_logs_controller.request = request
- workshop_logs_controller.response = response
- params[:organization_id] = @organization.id # Inject context so the WorkshopLogsController#index scopes properly
- workshop_logs_controller.params = params
- workshop_logs_controller.index
+ track_view(@organization)
workshop_logs = WorkshopLog.where(organization_id: @organization.id)
@month_year_options = workshop_logs.group("DATE_FORMAT(COALESCE(date, created_at, NOW()), '%Y-%m')")
- .select("DATE_FORMAT(COALESCE(date, created_at, NOW()), '%Y-%m') AS ym,
- MAX(COALESCE(date, created_at)) AS max_dt")
- .order("max_dt DESC")
- .map { |record| [ Date.strptime(record.ym, "%Y-%m").strftime("%B %Y"), record.ym ] }
+ .select("DATE_FORMAT(COALESCE(date, created_at, NOW()), '%Y-%m') AS ym,
+ MAX(COALESCE(date, created_at)) AS max_dt")
+ .order("max_dt DESC")
+ .map { |record| [ Date.strptime(record.ym, "%Y-%m").strftime("%B %Y"), record.ym ] }
@year_options = workshop_logs.pluck(
Arel.sql("DISTINCT EXTRACT(YEAR FROM COALESCE(date, created_at, NOW()))")
@@ -35,8 +29,13 @@ def show
@workshop_logs_unpaginated = workshop_logs
@workshop_logs_count = @workshop_logs_unpaginated.size
@workshop_logs = @workshop_logs_unpaginated.paginate(page: params[:page], per_page: @per_page)
- @facilitators = User.active.or(User.where(id: @workshop_logs_unpaginated.pluck(:user_id)))
- .joins(:workshop_logs)
+ @workshops = Workshop.includes(:windows_type)
+ .published
+ .references(:windows_type)
+ .order("workshops.title ASC, windows_types.name ASC")
+ user_ids = @workshop_logs_unpaginated.select(:user_id)
+ @facilitators = User.active
+ .or(User.where(id: user_ids))
.distinct
.order(:last_name, :first_name)
end
diff --git a/app/controllers/project_statuses_controller.rb b/app/controllers/project_statuses_controller.rb
deleted file mode 100644
index c3abc4319..000000000
--- a/app/controllers/project_statuses_controller.rb
+++ /dev/null
@@ -1,68 +0,0 @@
-class ProjectStatusesController < Admin::BaseController
- before_action :set_project_status, only: [ :show, :edit, :update, :destroy ]
-
- def index
- per_page = params[:number_of_items_per_page].presence || 25
- unfiltered = ProjectStatus.all
- @count_display = unfiltered.count
- @project_statuses = unfiltered.paginate(page: params[:page], per_page: per_page).decorate
- end
-
- def show
- @project_status = @project_status.decorate
- end
-
- def new
- @project_status = ProjectStatus.new.decorate
- set_form_variables
- end
-
- def edit
- @project_status = @project_status.decorate
- set_form_variables
- end
-
- def create
- @project_status = ProjectStatus.new(project_status_params)
-
- if @project_status.save
- redirect_to project_statuses_path, notice: "Project status was successfully created."
- else
- @project_status = ProjectStatus.new.decorate
- set_form_variables
- render :new, status: :unprocessable_content
- end
- end
-
- def update
- if @project_status.update(project_status_params)
- redirect_to project_statuses_path, notice: "Project status was successfully updated.", status: :see_other
- else
- @project_status = ProjectStatus.new.decorate
- set_form_variables
- render :edit, status: :unprocessable_content
- end
- end
-
- def destroy
- @project_status.destroy!
- redirect_to project_statuses_path, notice: "Project status was successfully destroyed."
- end
-
- # Optional hooks for setting variables for forms or index
- def set_form_variables
- end
-
- private
-
- def set_project_status
- @project_status = ProjectStatus.find(params[:id])
- end
-
- # Strong parameters
- def project_status_params
- params.require(:project_status).permit(
- :name
- )
- end
-end
diff --git a/app/controllers/project_users_controller.rb b/app/controllers/project_users_controller.rb
deleted file mode 100644
index e0e7d535a..000000000
--- a/app/controllers/project_users_controller.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-class ProjectUsersController < ApplicationController
- def destroy
- project_user = ProjectUser.find(params[:id])
- user = project_user.user
-
- if project_user.destroy
- flash[:notice] = "Project user has been deleted."
- else
- flash[:alert] = "Unable to delete project user. Please contact AWBW."
- end
- redirect_to generate_facilitator_user_path(user)
- end
-end
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
deleted file mode 100644
index 7138afcf1..000000000
--- a/app/controllers/projects_controller.rb
+++ /dev/null
@@ -1,138 +0,0 @@
-class ProjectsController < ApplicationController
- include AhoyTracking
- before_action :set_project, only: [ :show, :edit, :update, :destroy ]
-
- def index
- per_page = params[:number_of_items_per_page].presence || 25
- unpaginated = Project.includes(:logo_attachment, :windows_type, :project_status).search_by_params(params).order(:name)
- @projects_count = unpaginated.count
- @projects = unpaginated.paginate(page: params[:page], per_page: per_page)
- set_index_variables
- end
-
- def show
- track_view(@project)
-
- workshop_logs = WorkshopLog.where(project_id: @project.id)
- @month_year_options = workshop_logs.group("DATE_FORMAT(COALESCE(date, created_at, NOW()), '%Y-%m')")
- .select("DATE_FORMAT(COALESCE(date, created_at, NOW()), '%Y-%m') AS ym,
- MAX(COALESCE(date, created_at)) AS max_dt")
- .order("max_dt DESC")
- .map { |record| [ Date.strptime(record.ym, "%Y-%m").strftime("%B %Y"), record.ym ] }
-
- @year_options = workshop_logs.pluck(
- Arel.sql("DISTINCT EXTRACT(YEAR FROM COALESCE(date, created_at, NOW()))")
- ).sort.reverse
- @projects = Project.where(id: @project.id)
- @per_page = params[:per_page] || 10
- @workshop_logs_unpaginated = workshop_logs
- @workshop_logs_count = @workshop_logs_unpaginated.size
- @workshop_logs = @workshop_logs_unpaginated.paginate(page: params[:page], per_page: @per_page)
- user_ids = @workshop_logs_unpaginated.select(:user_id)
-
- @workshops = Workshop.includes(:windows_type)
- .published
- .references(:windows_type)
- .order("workshops.title ASC, windows_types.name ASC")
-
- @facilitators = User.active
- .or(User.where(id: user_ids))
- .distinct
- .order(:last_name, :first_name)
- end
-
- def new
- @project = Project.new
- set_form_variables
- end
-
- def edit
- set_form_variables
- end
-
- def create
- @project = Project.new(project_params)
-
- if @project.save
- redirect_to projects_path, notice: "Organization was successfully created."
- else
- set_form_variables
- render :new, status: :unprocessable_content
- end
- end
-
- def update
- if @project.update(project_params)
- redirect_to projects_path, notice: "Organization was successfully updated.", status: :see_other
- else
- set_form_variables
- render :edit, status: :unprocessable_content
- end
- end
-
- def destroy
- @project.destroy!
- redirect_to projects_path, notice: "Organization was successfully destroyed."
- end
-
- # Optional hooks for setting variables for forms or index
- def set_form_variables
- @project_statuses = ProjectStatus.all
- @facilitators_array = Facilitator.includes(:user)
- .joins(:user)
- .order(:first_name, :last_name)
- .map { |f| [ f.name, f.user.id ] }
- @project.project_users = @project.project_users
- .includes(:project)
- .sort_by { |pu| pu.user.facilitator&.name.to_s.downcase }
- end
-
- def set_index_variables
- @project_statuses = ProjectStatus.all
- end
-
- private
-
- def set_project
- @project = Project.find(params[:id])
- end
-
- # Strong parameters
- def project_params
- params.require(:project).permit(
- :name, :description, :start_date, :end_date, :mission_vision_values, :internal_id,
- :inactive, :logo, :notes, :agency_type, :agency_type_other, :website_url,
- :project_status_id, :location_id, :windows_type_id,
- sectorable_items_attributes: [
- :id,
- :sector_id,
- :_destroy
- ],
- project_users_attributes: [
- :id,
- :user_id,
- :inactive,
- :title,
- :_destroy
- ],
- addresses_attributes: [
- :id,
- :address_type,
- :inactive,
- :phone,
- :street_address,
- :city,
- :state,
- :zip_code,
- :county,
- :country,
- :district,
- :locality,
- :la_city_council_district,
- :la_supervisorial_district,
- :la_service_planning_area,
- :_destroy
- ]
- )
- end
-end
diff --git a/app/decorators/project_decorator.rb b/app/decorators/project_decorator.rb
deleted file mode 100644
index 4ac3de12a..000000000
--- a/app/decorators/project_decorator.rb
+++ /dev/null
@@ -1,29 +0,0 @@
-class ProjectDecorator < ApplicationDecorator
- def detail(length: nil)
- length ? description&.truncate(length) : description
- end
-
- def default_display_image
- return logo if respond_to?(:logo) && logo&.attached?
- "theme_default.png"
- end
-
- def title
- name
- end
-
- def badges
- years = start_date ? (Time.zone.now.year - start_date.year) : 0
- badges = []
- badges << [ "Legacy Organization (10+ years)", "yellow" ] if true || years >= 10
- badges << [ "Seasoned Organization (3-10 years)", "gray" ] if true || start_date.present? && years >= 3
- badges << [ "New Organization (<3 years)", "green" ] if true || start_date.present? && years < 3
- badges << [ "Spotlighted Organization", "gray" ] if true || stories_as_spotlighted_facilitator
- badges << [ "Events Hosted", "blue" ] if true || Event.count > 3
- # badges << ["Workshop Author", "gray"] if true || user.workshops.any? # indigo
- # badges << ["Story Author", "gray"] if true || user.stories_as_creator.any? # pink
- # badges << ["Sector Leader", "purple"] if true || sectorable_items.where(is_leader: true).any?
- badges << [ "Blog Contributor", "gray" ] if true # || user.respond_to?(:blogs) && user.blogs.any? # red
- badges
- end
-end
diff --git a/app/decorators/project_status_decorator.rb b/app/decorators/project_status_decorator.rb
deleted file mode 100644
index b295e8491..000000000
--- a/app/decorators/project_status_decorator.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-class ProjectStatusDecorator < Draper::Decorator
- delegate_all
-end
diff --git a/app/decorators/project_user_decorator.rb b/app/decorators/project_user_decorator.rb
deleted file mode 100644
index eeeb34ac7..000000000
--- a/app/decorators/project_user_decorator.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class ProjectUserDecorator < ApplicationDecorator
- def detail(length: nil)
- "#{user.full_name}: #{title.presence || position} - #{project.name}"
- end
-end
diff --git a/app/models/project.rb b/app/models/project.rb
deleted file mode 100644
index febe5528c..000000000
--- a/app/models/project.rb
+++ /dev/null
@@ -1,106 +0,0 @@
-class Project < ApplicationRecord
- include TagFilterable, Trendable, WindowsTypeFilterable
-
- belongs_to :project_status
- belongs_to :project_obligation, optional: true
- belongs_to :location, optional: true # TODO - remove Location if unused
- belongs_to :windows_type, optional: true
- has_many :addresses, as: :addressable, dependent: :destroy
- has_many :bookmarks, as: :bookmarkable, dependent: :destroy
- has_many :project_users, dependent: :restrict_with_error
- has_many :users, through: :project_users
- has_many :reports, through: :users
- has_many :workshop_logs, through: :users
-
- has_many :categorizable_items, dependent: :destroy, inverse_of: :categorizable, as: :categorizable
- has_many :sectorable_items, as: :sectorable, dependent: :destroy
- # has_many through
- has_many :categories, through: :categorizable_items
- has_many :sectors, through: :sectorable_items
-
- # Asset associations
- has_one_attached :logo
-
- # Validations
- validates :logo,
- content_type: %w[image/png image/jpeg image/webp],
- size: { less_than: 5.megabytes }
- validates :name, presence: true
- validates :project_status_id, presence: true
-
- # Nested attributes
- accepts_nested_attributes_for :addresses, allow_destroy: true, reject_if: :all_blank
- accepts_nested_attributes_for :sectorable_items, allow_destroy: true, reject_if: :all_blank
- accepts_nested_attributes_for :project_users, allow_destroy: true, reject_if: :all_blank
-
- # SearchCop
- include SearchCop
- search_scope :search do
- attributes :name
- end
-
- scope :address, ->(address) do
- return all if address.blank?
- exact = address.to_s
- wildcard = "%#{exact}%"
- left_joins(:addresses).where(
- <<~SQL,
- addresses.street_address LIKE :wildcard OR
- addresses.city LIKE :wildcard OR
- addresses.state LIKE :wildcard OR
- addresses.county LIKE :wildcard OR
- addresses.country LIKE :wildcard OR
- addresses.district LIKE :wildcard OR
- addresses.locality LIKE :wildcard OR
- addresses.zip_code LIKE :exact OR
- CAST(addresses.la_city_council_district AS CHAR) = :exact OR
- CAST(addresses.la_service_planning_area AS CHAR) = :exact OR
- CAST(addresses.la_supervisorial_district AS CHAR) = :exact
- SQL
- wildcard: wildcard, exact: exact)
- end
- scope :active, ->(active = nil) { active ? where(inactive: !active) : where(inactive: false) }
- scope :project_ids, ->(project_ids) { where(id: project_ids.to_s.split("-").map(&:to_i)) }
- scope :published, ->(published = nil) { published ? active(published) : active }
- scope :category_names, ->(names) { tag_names(:categories, names) }
- scope :sector_names, ->(names) { tag_names(:sectors, names) }
-
- def self.search_by_params(params)
- projects = self.all
- projects = projects.search(params[:query]) if params[:query].present?
- projects = projects.sector_names(params[:sector_names]) if params[:sector_names].present?
- projects = projects.category_names(params[:category_names]) if params[:category_names].present?
- projects = projects.address(params[:address]) if params[:address].present?
- projects = projects.windows_type_name(params[:windows_type_name]) if params[:windows_type_name].present?
- projects = projects.project_ids(params[:project_ids]) if params[:project_ids].present?
- projects
- end
-
- # Methods
- def led_by?(user)
- return false unless leader
- leader.user == user
- end
-
- def type_name
- "#{name} #{ " (#{windows_type.short_name})" if windows_type}"
- end
-
- def organization_description
- "#{name}, #{organization_locality}"
- end
-
- def organization_locality
- addresses.active.first&.locality
- end
-
- def sector_list
- sectors.pluck(:name)
- end
-
- private
-
- def leader
- project_users.find_by(position: 2)
- end
-end
diff --git a/app/models/project_obligation.rb b/app/models/project_obligation.rb
deleted file mode 100644
index 0eed854e9..000000000
--- a/app/models/project_obligation.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class ProjectObligation < ApplicationRecord
- OBLIGATION_TYPES = [ "Current Grant Funded", "Previous Grant Funded",
- "Voluntary Reporting", "Intermittent Reporting",
- "Active Non-Reporting" ]
-end
diff --git a/app/models/project_status.rb b/app/models/project_status.rb
deleted file mode 100644
index 0e1d6a949..000000000
--- a/app/models/project_status.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-class ProjectStatus < ApplicationRecord
- PROJECT_STATUSES = [ "Active", "Inactive", "Pending", "Reinstate", "Suspended", "Unknown" ]
-
- has_many :projects
-
- validates :name, presence: true, uniqueness: true
-end
diff --git a/app/models/project_user.rb b/app/models/project_user.rb
deleted file mode 100644
index 8e9716f74..000000000
--- a/app/models/project_user.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-class ProjectUser < ApplicationRecord
- belongs_to :project
- belongs_to :user
-
- # Validations
- validates_presence_of :project_id
- validates_presence_of :title
-
- # Enum
- enum :position, { default: 0, liaison: 1, leader: 2, assistant: 3 }
-
- scope :active, -> { where(inactive: false) }
-
- # Methods
- def name
- "#{user.name}" if user
- end
-end
diff --git a/db/migrate/20260120004745_rename_projects_to_organizations.rb b/db/migrate/20260120004745_rename_projects_to_organizations.rb
deleted file mode 100644
index c9235f56e..000000000
--- a/db/migrate/20260120004745_rename_projects_to_organizations.rb
+++ /dev/null
@@ -1,59 +0,0 @@
-class RenameProjectsToOrganizations < ActiveRecord::Migration[8.1]
- def change
- # Rename main projects table to organizations
- rename_table :projects, :organizations
-
- # Rename project_statuses table
- rename_table :project_statuses, :organization_statuses
-
- # Rename project_obligations table
- rename_table :project_obligations, :organization_obligations
-
- # Rename project_users table
- rename_table :project_users, :organization_users
-
- # Update foreign key columns
- rename_column :organization_users, :project_id, :organization_id
- rename_column :organization_users, :agency_id, :organization_agency_id
-
- # Update foreign key in organizations table
- rename_column :organizations, :project_status_id, :organization_status_id
-
- # Update project_id foreign keys in other tables
- rename_column :community_news, :project_id, :organization_id
- rename_column :monthly_reports, :project_id, :organization_id
- rename_column :reports, :project_id, :organization_id
- rename_column :stories, :project_id, :organization_id
- rename_column :story_ideas, :project_id, :organization_id
- rename_column :workshop_logs, :project_id, :organization_id
-
- # Rename project_user_id foreign key
- rename_column :monthly_reports, :project_user_id, :organization_user_id
-
- # Rename indexes
- rename_index :organization_users, 'index_project_users_on_project_id', 'index_organization_users_on_organization_id'
- rename_index :organization_users, 'index_project_users_on_agency_id', 'index_organization_users_on_organization_agency_id'
- rename_index :organization_users, 'index_project_users_on_user_id', 'index_organization_users_on_user_id'
-
- rename_index :organizations, 'index_projects_on_location_id', 'index_organizations_on_location_id'
- rename_index :organizations, 'index_projects_on_project_status_id', 'index_organizations_on_organization_status_id'
- rename_index :organizations, 'index_projects_on_view_count', 'index_organizations_on_view_count'
- rename_index :organizations, 'index_projects_on_windows_type_id', 'index_organizations_on_windows_type_id'
-
- rename_index :community_news, 'index_community_news_on_project_id', 'index_community_news_on_organization_id'
- rename_index :monthly_reports, 'index_monthly_reports_on_project_id', 'index_monthly_reports_on_organization_id'
- rename_index :monthly_reports, 'index_monthly_reports_on_project_user_id', 'index_monthly_reports_on_organization_user_id'
- rename_index :reports, 'index_reports_on_project_id', 'index_reports_on_organization_id'
- rename_index :stories, 'index_stories_on_project_id', 'index_stories_on_organization_id'
- rename_index :story_ideas, 'index_story_ideas_on_project_id', 'index_story_ideas_on_organization_id'
- rename_index :workshop_logs, 'index_workshop_logs_on_project_id', 'index_workshop_logs_on_organization_id'
-
- # Rename foreign key constraints
- # Note: Rails will handle updating foreign key references automatically when we rename the columns
- # However, we need to explicitly update any named foreign key constraints
-
- # For users table that references projects as agency_id
- # The existing foreign key is already named correctly as it references projects.id
- # Rails will automatically update this when we rename the table
- end
-end
diff --git a/db/migrate/20260203004745_rename_projects_to_organizations.rb b/db/migrate/20260203004745_rename_projects_to_organizations.rb
new file mode 100644
index 000000000..8c314af39
--- /dev/null
+++ b/db/migrate/20260203004745_rename_projects_to_organizations.rb
@@ -0,0 +1,98 @@
+class RenameProjectsToOrganizations < ActiveRecord::Migration[8.1]
+ def change
+ # Rename main projects table to organizations
+ rename_table :projects, :organizations
+
+ # Rename project_statuses table
+ rename_table :project_statuses, :organization_statuses
+
+ # Rename project_obligations table
+ rename_table :project_obligations, :organization_obligations
+
+ # Rename project_users table
+ rename_table :project_users, :organization_users
+
+ # Update foreign key columns
+ rename_column :organization_users, :project_id, :organization_id
+ rename_column :organization_users, :agency_id, :organization_agency_id
+
+ # Update foreign key in organizations table
+ rename_column :organizations, :project_status_id, :organization_status_id
+
+ # Update project_id foreign keys in other tables
+ rename_column :community_news, :project_id, :organization_id
+ rename_column :monthly_reports, :project_id, :organization_id
+ rename_column :reports, :project_id, :organization_id
+ rename_column :stories, :project_id, :organization_id
+ rename_column :story_ideas, :project_id, :organization_id
+ rename_column :workshop_logs, :project_id, :organization_id
+
+ # Rename project_user_id foreign key
+ rename_column :monthly_reports, :project_user_id, :organization_user_id
+
+ # Rename indexes
+ rename_index_if_exists :organization_users,
+ "index_project_users_on_project_id",
+ "index_organization_users_on_organization_id"
+
+ rename_index_if_exists :organization_users,
+ "index_project_users_on_agency_id",
+ "index_organization_users_on_organization_agency_id"
+
+ rename_index_if_exists :organization_users,
+ "index_project_users_on_user_id",
+ "index_organization_users_on_user_id"
+
+ rename_index_if_exists :organizations, 'index_projects_on_location_id',
+ 'index_organizations_on_location_id'
+ rename_index_if_exists :organizations, 'index_projects_on_project_status_id',
+ 'index_organizations_on_organization_status_id'
+ rename_index_if_exists :organizations, 'index_projects_on_view_count',
+ 'index_organizations_on_view_count'
+ rename_index_if_exists :organizations, 'index_projects_on_windows_type_id',
+ 'index_organizations_on_windows_type_id'
+
+ rename_index_if_exists :community_news,
+ "index_community_news_on_project_id",
+ "index_community_news_on_organization_id"
+
+ rename_index_if_exists :monthly_reports,
+ "index_monthly_reports_on_project_id",
+ "index_monthly_reports_on_organization_id"
+
+ rename_index_if_exists :monthly_reports,
+ "index_monthly_reports_on_project_user_id",
+ "index_monthly_reports_on_organization_user_id"
+
+ rename_index_if_exists :reports,
+ "index_reports_on_project_id",
+ "index_reports_on_organization_id"
+
+ rename_index_if_exists :stories,
+ "index_stories_on_project_id",
+ "index_stories_on_organization_id"
+
+ rename_index_if_exists :story_ideas,
+ "index_story_ideas_on_project_id",
+ "index_story_ideas_on_organization_id"
+
+ rename_index_if_exists :workshop_logs,
+ "index_workshop_logs_on_project_id",
+ "index_workshop_logs_on_organization_id"
+
+ # Rename foreign key constraints
+ # Note: Rails will handle updating foreign key references automatically when we rename the columns
+ # However, we need to explicitly update any named foreign key constraints
+
+ # For users table that references projects as agency_id
+ # The existing foreign key is already named correctly as it references projects.id
+ # Rails will automatically update this when we rename the table
+ end
+
+ def rename_index_if_exists(table, old_name, new_name)
+ return unless index_name_exists?(table, old_name)
+ return if index_name_exists?(table, new_name)
+
+ rename_index table, old_name, new_name
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 74d3310fb..1754441f3 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema[8.1].define(version: 2026_02_02_164015) do
+ActiveRecord::Schema[8.1].define(version: 2026_02_03_004745) do
create_table "action_text_mentions", charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t|
t.bigint "action_text_rich_text_id", null: false
t.datetime "created_at", null: false
@@ -271,7 +271,7 @@
t.datetime "created_at", null: false
t.integer "created_by_id", null: false
t.boolean "featured"
- t.integer "project_id"
+ t.integer "organization_id"
t.boolean "public", default: false, null: false
t.boolean "public_featured", default: false, null: false
t.boolean "published"
@@ -284,7 +284,7 @@
t.index ["author_id"], name: "index_community_news_on_author_id"
t.index ["body"], name: "index_community_news_on_body", type: :fulltext
t.index ["created_by_id"], name: "index_community_news_on_created_by_id"
- t.index ["project_id"], name: "index_community_news_on_project_id"
+ t.index ["organization_id"], name: "index_community_news_on_organization_id"
t.index ["updated_by_id"], name: "index_community_news_on_updated_by_id"
t.index ["windows_type_id"], name: "index_community_news_on_windows_type_id"
end
@@ -481,13 +481,13 @@
t.string "name"
t.string "num_new_participants"
t.string "num_ongoing_participants"
+ t.integer "organization_id"
+ t.integer "organization_user_id"
t.string "phone"
t.string "position"
- t.integer "project_id"
- t.integer "project_user_id"
t.datetime "updated_at", precision: nil, null: false
- t.index ["project_id"], name: "index_monthly_reports_on_project_id"
- t.index ["project_user_id"], name: "index_monthly_reports_on_project_user_id"
+ t.index ["organization_id"], name: "index_monthly_reports_on_organization_id"
+ t.index ["organization_user_id"], name: "index_monthly_reports_on_organization_user_id"
end
create_table "notifications", id: :integer, charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t|
@@ -507,65 +507,34 @@
t.index ["noticeable_type", "noticeable_id"], name: "index_notifications_on_noticeable_type_and_noticeable_id"
end
- create_table "payments", charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t|
- t.integer "amount_cents", null: false
- t.datetime "created_at", null: false
- t.string "currency", default: "usd", null: false
- t.string "failure_code"
- t.string "failure_message"
- t.bigint "payable_id", null: false
- t.string "payable_type", null: false
- t.bigint "payer_id", null: false
- t.string "payer_type", null: false
- t.string "status", null: false
- t.string "stripe_charge_id"
- t.json "stripe_metadata"
- t.string "stripe_payment_intent_id", null: false
- t.datetime "updated_at", null: false
- t.index ["payable_type", "payable_id", "status"], name: "index_payments_on_payable_type_and_payable_id_and_status"
- t.index ["payable_type", "payable_id"], name: "index_payments_on_payable"
- t.index ["payable_type", "payable_id"], name: "index_payments_on_payable_type_and_payable_id"
- t.index ["payer_type", "payer_id"], name: "index_payments_on_payer"
- t.index ["payer_type", "payer_id"], name: "index_payments_on_payer_type_and_payer_id"
- t.index ["stripe_charge_id"], name: "index_payments_on_stripe_charge_id"
- t.index ["stripe_payment_intent_id"], name: "index_payments_on_stripe_payment_intent_id", unique: true
- end
-
- create_table "permissions", id: :integer, charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t|
- t.datetime "created_at", precision: nil, null: false
- t.integer "legacy_id"
- t.string "security_cat"
- t.datetime "updated_at", precision: nil, null: false
- end
-
- create_table "project_obligations", id: :integer, charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t|
+ create_table "organization_obligations", id: :integer, charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t|
t.datetime "created_at", precision: nil, null: false
t.string "name"
t.datetime "updated_at", precision: nil, null: false
end
- create_table "project_statuses", id: :integer, charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t|
+ create_table "organization_statuses", id: :integer, charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t|
t.datetime "created_at", precision: nil, null: false
t.string "name"
t.datetime "updated_at", precision: nil, null: false
end
- create_table "project_users", id: :integer, charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t|
- t.integer "agency_id"
+ create_table "organization_users", id: :integer, charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t|
t.datetime "created_at", precision: nil, null: false
t.string "filemaker_code"
t.boolean "inactive", default: false, null: false
+ t.integer "organization_agency_id"
+ t.integer "organization_id"
t.integer "position"
- t.integer "project_id"
t.string "title"
t.datetime "updated_at", precision: nil, null: false
t.integer "user_id"
- t.index ["agency_id"], name: "index_project_users_on_agency_id"
- t.index ["project_id"], name: "index_project_users_on_project_id"
- t.index ["user_id"], name: "index_project_users_on_user_id"
+ t.index ["organization_agency_id"], name: "index_organization_users_on_organization_agency_id"
+ t.index ["organization_id"], name: "index_organization_users_on_organization_id"
+ t.index ["user_id"], name: "index_organization_users_on_user_id"
end
- create_table "projects", id: :integer, charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t|
+ create_table "organizations", id: :integer, charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t|
t.string "agency_type"
t.string "agency_type_other"
t.datetime "created_at", precision: nil, null: false
@@ -580,14 +549,45 @@
t.string "mission_vision_values"
t.string "name"
t.text "notes", size: :long
- t.integer "project_status_id"
+ t.integer "organization_status_id"
t.date "start_date"
t.datetime "updated_at", precision: nil, null: false
t.string "website_url"
t.integer "windows_type_id"
- t.index ["location_id"], name: "index_projects_on_location_id"
- t.index ["project_status_id"], name: "index_projects_on_project_status_id"
- t.index ["windows_type_id"], name: "index_projects_on_windows_type_id"
+ t.index ["location_id"], name: "index_organizations_on_location_id"
+ t.index ["organization_status_id"], name: "index_organizations_on_organization_status_id"
+ t.index ["windows_type_id"], name: "index_organizations_on_windows_type_id"
+ end
+
+ create_table "payments", charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t|
+ t.integer "amount_cents", null: false
+ t.datetime "created_at", null: false
+ t.string "currency", default: "usd", null: false
+ t.string "failure_code"
+ t.string "failure_message"
+ t.bigint "payable_id", null: false
+ t.string "payable_type", null: false
+ t.bigint "payer_id", null: false
+ t.string "payer_type", null: false
+ t.string "status", null: false
+ t.string "stripe_charge_id"
+ t.json "stripe_metadata"
+ t.string "stripe_payment_intent_id", null: false
+ t.datetime "updated_at", null: false
+ t.index ["payable_type", "payable_id", "status"], name: "index_payments_on_payable_type_and_payable_id_and_status"
+ t.index ["payable_type", "payable_id"], name: "index_payments_on_payable"
+ t.index ["payable_type", "payable_id"], name: "index_payments_on_payable_type_and_payable_id"
+ t.index ["payer_type", "payer_id"], name: "index_payments_on_payer"
+ t.index ["payer_type", "payer_id"], name: "index_payments_on_payer_type_and_payer_id"
+ t.index ["stripe_charge_id"], name: "index_payments_on_stripe_charge_id"
+ t.index ["stripe_payment_intent_id"], name: "index_payments_on_stripe_payment_intent_id", unique: true
+ end
+
+ create_table "permissions", id: :integer, charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t|
+ t.datetime "created_at", precision: nil, null: false
+ t.integer "legacy_id"
+ t.string "security_cat"
+ t.datetime "updated_at", precision: nil, null: false
end
create_table "quotable_item_quotes", id: :integer, charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t|
@@ -638,10 +638,10 @@
t.integer "form_file_file_size"
t.datetime "form_file_updated_at", precision: nil
t.boolean "has_attachment", default: false
+ t.integer "organization_id"
t.string "other_description"
t.integer "owner_id"
t.string "owner_type"
- t.integer "project_id"
t.integer "rating", default: 0
t.integer "teens_first_time", default: 0
t.integer "teens_ongoing", default: 0
@@ -651,7 +651,7 @@
t.integer "windows_type_id"
t.integer "workshop_id"
t.string "workshop_name"
- t.index ["project_id"], name: "index_reports_on_project_id"
+ t.index ["organization_id"], name: "index_reports_on_organization_id"
t.index ["user_id"], name: "index_reports_on_user_id"
t.index ["windows_type_id"], name: "index_reports_on_windows_type_id"
end
@@ -709,8 +709,8 @@
t.integer "created_by_id", null: false
t.string "external_workshop_title"
t.boolean "featured", default: false, null: false
+ t.integer "organization_id"
t.boolean "permission_given"
- t.integer "project_id"
t.boolean "public", default: false, null: false
t.boolean "public_featured", default: false, null: false
t.boolean "published", default: false, null: false
@@ -724,7 +724,7 @@
t.integer "workshop_id"
t.string "youtube_url"
t.index ["created_by_id"], name: "index_stories_on_created_by_id"
- t.index ["project_id"], name: "index_stories_on_project_id"
+ t.index ["organization_id"], name: "index_stories_on_organization_id"
t.index ["published"], name: "index_stories_on_published"
t.index ["spotlighted_facilitator_id"], name: "index_stories_on_spotlighted_facilitator_id"
t.index ["story_idea_id"], name: "index_stories_on_story_idea_id"
@@ -738,8 +738,8 @@
t.datetime "created_at", null: false
t.integer "created_by_id", null: false
t.string "external_workshop_title"
+ t.integer "organization_id", null: false
t.boolean "permission_given"
- t.integer "project_id", null: false
t.string "publish_preferences"
t.string "title"
t.datetime "updated_at", null: false
@@ -748,7 +748,7 @@
t.integer "workshop_id"
t.string "youtube_url"
t.index ["created_by_id"], name: "index_story_ideas_on_created_by_id"
- t.index ["project_id"], name: "index_story_ideas_on_project_id"
+ t.index ["organization_id"], name: "index_story_ideas_on_organization_id"
t.index ["updated_by_id"], name: "index_story_ideas_on_updated_by_id"
t.index ["windows_type_id"], name: "index_story_ideas_on_windows_type_id"
t.index ["workshop_id"], name: "index_story_ideas_on_workshop_id"
@@ -939,7 +939,7 @@
t.boolean "lead_similar"
t.integer "num_participants_first_time", default: 0
t.integer "num_participants_on_going", default: 0
- t.integer "project_id"
+ t.integer "organization_id"
t.text "questions", size: :long
t.integer "rating", default: 0
t.text "reaction", size: :long
@@ -949,7 +949,7 @@
t.datetime "updated_at", precision: nil, null: false
t.integer "user_id"
t.integer "workshop_id"
- t.index ["project_id"], name: "index_workshop_logs_on_project_id"
+ t.index ["organization_id"], name: "index_workshop_logs_on_organization_id"
t.index ["user_id"], name: "index_workshop_logs_on_user_id"
t.index ["workshop_id"], name: "index_workshop_logs_on_workshop_id"
end
@@ -1094,7 +1094,7 @@
add_foreign_key "bookmark_annotations", "bookmarks"
add_foreign_key "bookmarks", "users"
add_foreign_key "categories", "category_types"
- add_foreign_key "community_news", "projects"
+ add_foreign_key "community_news", "organizations"
add_foreign_key "community_news", "users", column: "author_id"
add_foreign_key "community_news", "users", column: "created_by_id"
add_foreign_key "community_news", "users", column: "updated_by_id"
@@ -1110,20 +1110,20 @@
add_foreign_key "form_field_answer_options", "form_fields"
add_foreign_key "form_fields", "forms"
add_foreign_key "forms", "form_builders"
- add_foreign_key "monthly_reports", "project_users"
- add_foreign_key "monthly_reports", "projects"
- add_foreign_key "project_users", "projects"
- add_foreign_key "project_users", "projects", column: "agency_id"
- add_foreign_key "project_users", "users"
- add_foreign_key "projects", "locations"
- add_foreign_key "projects", "project_statuses"
- add_foreign_key "projects", "windows_types"
+ add_foreign_key "monthly_reports", "organization_users"
+ add_foreign_key "monthly_reports", "organizations"
+ add_foreign_key "organization_users", "organizations"
+ add_foreign_key "organization_users", "organizations", column: "organization_agency_id"
+ add_foreign_key "organization_users", "users"
+ add_foreign_key "organizations", "locations"
+ add_foreign_key "organizations", "organization_statuses"
+ add_foreign_key "organizations", "windows_types"
add_foreign_key "quotable_item_quotes", "quotes"
add_foreign_key "quotes", "workshops"
add_foreign_key "report_form_field_answers", "answer_options"
add_foreign_key "report_form_field_answers", "form_fields"
add_foreign_key "report_form_field_answers", "reports"
- add_foreign_key "reports", "projects"
+ add_foreign_key "reports", "organizations"
add_foreign_key "reports", "users"
add_foreign_key "reports", "windows_types"
add_foreign_key "resources", "users"
@@ -1131,13 +1131,13 @@
add_foreign_key "resources", "workshops"
add_foreign_key "sectorable_items", "sectors"
add_foreign_key "stories", "facilitators", column: "spotlighted_facilitator_id"
- add_foreign_key "stories", "projects"
+ add_foreign_key "stories", "organizations"
add_foreign_key "stories", "story_ideas"
add_foreign_key "stories", "users", column: "created_by_id"
add_foreign_key "stories", "users", column: "updated_by_id"
add_foreign_key "stories", "windows_types"
add_foreign_key "stories", "workshops"
- add_foreign_key "story_ideas", "projects"
+ add_foreign_key "story_ideas", "organizations"
add_foreign_key "story_ideas", "users", column: "created_by_id"
add_foreign_key "story_ideas", "users", column: "updated_by_id"
add_foreign_key "story_ideas", "windows_types"
@@ -1149,13 +1149,13 @@
add_foreign_key "user_permissions", "permissions"
add_foreign_key "user_permissions", "users"
add_foreign_key "users", "facilitators"
- add_foreign_key "users", "projects", column: "agency_id"
+ add_foreign_key "users", "organizations", column: "agency_id"
add_foreign_key "workshop_age_ranges", "age_ranges"
add_foreign_key "workshop_age_ranges", "workshops"
add_foreign_key "workshop_ideas", "users", column: "created_by_id"
add_foreign_key "workshop_ideas", "users", column: "updated_by_id"
add_foreign_key "workshop_ideas", "windows_types"
- add_foreign_key "workshop_logs", "projects"
+ add_foreign_key "workshop_logs", "organizations"
add_foreign_key "workshop_logs", "users"
add_foreign_key "workshop_logs", "workshops"
add_foreign_key "workshop_resources", "resources"
diff --git a/spec/decorators/organization_decorator_spec.rb b/spec/decorators/organization_decorator_spec.rb
new file mode 100644
index 000000000..77b6aa688
--- /dev/null
+++ b/spec/decorators/organization_decorator_spec.rb
@@ -0,0 +1,4 @@
+require 'rails_helper'
+
+RSpec.describe OrganizationDecorator do
+end
diff --git a/spec/decorators/organization_status_decorator_spec.rb b/spec/decorators/organization_status_decorator_spec.rb
new file mode 100644
index 000000000..2c3f06b36
--- /dev/null
+++ b/spec/decorators/organization_status_decorator_spec.rb
@@ -0,0 +1,4 @@
+require 'rails_helper'
+
+RSpec.describe OrganizationStatusDecorator do
+end
diff --git a/spec/decorators/project_decorator_spec.rb b/spec/decorators/project_decorator_spec.rb
deleted file mode 100644
index ad38d2eb4..000000000
--- a/spec/decorators/project_decorator_spec.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'rails_helper'
-
-RSpec.describe ProjectDecorator do
-end
diff --git a/spec/decorators/project_status_decorator_spec.rb b/spec/decorators/project_status_decorator_spec.rb
deleted file mode 100644
index 9f88999eb..000000000
--- a/spec/decorators/project_status_decorator_spec.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'rails_helper'
-
-RSpec.describe ProjectStatusDecorator do
-end
diff --git a/spec/factories/addresses.rb b/spec/factories/addresses.rb
index 5385decd5..df7813b93 100644
--- a/spec/factories/addresses.rb
+++ b/spec/factories/addresses.rb
@@ -1,6 +1,6 @@
FactoryBot.define do
factory :address do
- association :addressable, factory: :project
+ association :addressable, factory: :organization
street_address { Faker::Address.street_address }
city { Faker::Address.city }
diff --git a/spec/factories/community_news.rb b/spec/factories/community_news.rb
index 23d12c64e..3493ab9c0 100644
--- a/spec/factories/community_news.rb
+++ b/spec/factories/community_news.rb
@@ -3,8 +3,8 @@
title { "MyString" }
published { true }
featured { false }
- reference_url { "" }
- youtube_url { "" }
+ # reference_url { nil }
+ # youtube_url { nil }
association :author, factory: :user
association :created_by, factory: :user
association :updated_by, factory: :user
@@ -17,8 +17,8 @@
featured { true }
end
- trait :with_project do
- association :project
+ trait :with_organization do
+ association :organization
end
trait :with_windows_type do
diff --git a/spec/factories/project_obligations.rb b/spec/factories/organization_obligations.rb
similarity index 63%
rename from spec/factories/project_obligations.rb
rename to spec/factories/organization_obligations.rb
index e9315b669..ff1444fab 100644
--- a/spec/factories/project_obligations.rb
+++ b/spec/factories/organization_obligations.rb
@@ -1,5 +1,5 @@
FactoryBot.define do
- factory :project_obligation do
+ factory :organization_obligation do
name { "Current Grant Funded" }
end
end
diff --git a/spec/factories/project_statuses.rb b/spec/factories/organization_statuses.rb
similarity index 68%
rename from spec/factories/project_statuses.rb
rename to spec/factories/organization_statuses.rb
index 0c459743c..27e2264e7 100644
--- a/spec/factories/project_statuses.rb
+++ b/spec/factories/organization_statuses.rb
@@ -1,5 +1,5 @@
FactoryBot.define do
- factory :project_status do
+ factory :organization_status do
sequence(:name) { |n| "Status #{n}" }
end
end
diff --git a/spec/factories/project_users.rb b/spec/factories/organization_users.rb
similarity index 56%
rename from spec/factories/project_users.rb
rename to spec/factories/organization_users.rb
index 5db0f5344..302ca42e3 100644
--- a/spec/factories/project_users.rb
+++ b/spec/factories/organization_users.rb
@@ -1,6 +1,6 @@
FactoryBot.define do
- factory :project_user do
- association :project
+ factory :organization_user do
+ association :organization
association :user
position { :default }
diff --git a/spec/factories/projects.rb b/spec/factories/organizations.rb
similarity index 68%
rename from spec/factories/projects.rb
rename to spec/factories/organizations.rb
index 778741fb5..b122c35b7 100644
--- a/spec/factories/projects.rb
+++ b/spec/factories/organizations.rb
@@ -1,8 +1,8 @@
FactoryBot.define do
- factory :project do
+ factory :organization do
name { Faker::Company.name.gsub("'", " ") }
# association :windows_type
# association :location
- association :project_status
+ association :organization_status
end
end
diff --git a/spec/factories/reports.rb b/spec/factories/reports.rb
index 505689d25..423280e2b 100644
--- a/spec/factories/reports.rb
+++ b/spec/factories/reports.rb
@@ -2,7 +2,7 @@
factory :report do
# Associations
association :user
- association :project
+ association :organization
association :windows_type # Needed by callbacks/logic
# Polymorphic association: belongs_to :owner (can be nil or another model like FormBuilder)
owner { nil } # Default owner
diff --git a/spec/factories/stories.rb b/spec/factories/stories.rb
index 7d5cac796..8ba4be7a0 100644
--- a/spec/factories/stories.rb
+++ b/spec/factories/stories.rb
@@ -1,7 +1,7 @@
FactoryBot.define do
factory :story do
association :windows_type
- association :project
+ association :organization
association :workshop
title { Faker::Lorem.sentence }
rhino_body { "
My Body
" }
diff --git a/spec/factories/story_ideas.rb b/spec/factories/story_ideas.rb
index 865e5ab75..ff6084bfc 100644
--- a/spec/factories/story_ideas.rb
+++ b/spec/factories/story_ideas.rb
@@ -1,7 +1,7 @@
FactoryBot.define do
factory :story_idea do
association :windows_type
- association :project
+ association :organization
association :workshop
title { "My Title" }
body { "My Body" }
@@ -17,7 +17,7 @@
body: story_idea.body,
workshop: story_idea.workshop,
windows_type: story_idea.windows_type,
- project: story_idea.project,
+ project: story_idea.organization,
created_by: story_idea.created_by,
story_idea: story_idea)
end
diff --git a/spec/lib/domain_theme_spec.rb b/spec/lib/domain_theme_spec.rb
index d6c18b4da..a90552168 100644
--- a/spec/lib/domain_theme_spec.rb
+++ b/spec/lib/domain_theme_spec.rb
@@ -31,7 +31,7 @@
end
it "defines a color for every taggable dashboard type" do
- # Tag::TAGGABLE_META keys: workshops, resources, community_news, stories, events, facilitators, projects, quotes
+ # Tag::TAGGABLE_META keys: workshops, resources, community_news, stories, events, facilitators, organizations, quotes
expect(DomainTheme::COLORS.keys)
.to include(*Tag::TAGGABLE_META.keys)
end
@@ -43,7 +43,7 @@
end
it "symbolizes string keys" do
- expect(DomainTheme.color_for("projects")).to eq(:emerald)
+ expect(DomainTheme.color_for("organizations")).to eq(:emerald)
end
it "returns gray for unknown keys" do
diff --git a/spec/models/location_spec.rb b/spec/models/location_spec.rb
index 0c21e12dc..cfaaf0877 100644
--- a/spec/models/location_spec.rb
+++ b/spec/models/location_spec.rb
@@ -4,7 +4,7 @@
# let(:location) { build(:location) } # Keep if needed
describe 'associations' do
- # it { should have_many(:projects) } # Model missing has_many
+ # it { should have_many(:organizations) } # Model missing has_many
end
describe 'validations' do
diff --git a/spec/models/monthly_report_spec.rb b/spec/models/monthly_report_spec.rb
index d14eeb535..a9a7e30c7 100644
--- a/spec/models/monthly_report_spec.rb
+++ b/spec/models/monthly_report_spec.rb
@@ -18,7 +18,7 @@
it 'is valid with valid attributes' do
# Note: Factory needs associations uncommented for create (from Report factory)
# expect(build(:monthly_report)).to be_valid
- # pending("Requires functional user/project/windows_type factories and associations")
+ # pending("Requires functional user/organization/windows_type factories and associations")
end
# Add tests specific to MonthlyReport if any
diff --git a/spec/models/project_obligation_spec.rb b/spec/models/organization_obligation_spec.rb
similarity index 61%
rename from spec/models/project_obligation_spec.rb
rename to spec/models/organization_obligation_spec.rb
index e2984b595..313c0b22e 100644
--- a/spec/models/project_obligation_spec.rb
+++ b/spec/models/organization_obligation_spec.rb
@@ -1,18 +1,18 @@
require 'rails_helper'
-RSpec.describe ProjectObligation do
+RSpec.describe OrganizationObligation do
describe 'associations' do
- # Add association tests if any (e.g., has_many :projects?)
+ # Add association tests if any (e.g., has_many :organizations?)
end
describe 'validations' do
# Assuming name should be present and unique
- subject { build(:project_obligation) }
+ subject { build(:organization_obligation) }
# it { should validate_presence_of(:name) } # Model missing validation
# it { should validate_uniqueness_of(:name) } # Requires create
end
it 'is valid with valid attributes' do
- expect(build(:project_obligation)).to be_valid
+ expect(build(:organization_obligation)).to be_valid
end
end
diff --git a/spec/models/project_spec.rb b/spec/models/organization_spec.rb
similarity index 65%
rename from spec/models/project_spec.rb
rename to spec/models/organization_spec.rb
index 2e8333d97..3cea841d9 100644
--- a/spec/models/project_spec.rb
+++ b/spec/models/organization_spec.rb
@@ -1,29 +1,29 @@
require 'rails_helper'
-RSpec.describe Project do
+RSpec.describe Organization do
# pending "add some examples to (or delete) #{__FILE__}"
describe 'associations' do
it { should belong_to(:location).optional }
it { should belong_to(:windows_type).optional }
- it { should belong_to(:project_status) }
- it { should have_many(:project_users) }
- it { should have_many(:users).through(:project_users) }
+ it { should belong_to(:organization_status) }
+ it { should have_many(:organization_users) }
+ it { should have_many(:users).through(:organization_users) }
it { should have_many(:reports).through(:users) }
it { should have_many(:workshop_logs).through(:users) }
end
describe 'validations' do
# Add validation tests if any (e.g., presence of name, associations)
- subject { build(:project) } # Requires associations
+ subject { build(:organization) } # Requires associations
it { should validate_presence_of(:name) }
# it { should validate_presence_of(:location) }
# it { should validate_presence_of(:windows_type) }
- it { should validate_presence_of(:project_status_id) }
+ it { should validate_presence_of(:organization_status_id) }
end
it 'is valid with valid attributes' do
# Note: Factory needs associations uncommented for create
- # expect(build(:project)).to be_valid
+ # expect(build(:organization)).to be_valid
end
end
diff --git a/spec/models/project_status_spec.rb b/spec/models/organization_status_spec.rb
similarity index 52%
rename from spec/models/project_status_spec.rb
rename to spec/models/organization_status_spec.rb
index 7ab2e2cae..5f8f1c12a 100644
--- a/spec/models/project_status_spec.rb
+++ b/spec/models/organization_status_spec.rb
@@ -1,14 +1,14 @@
require 'rails_helper'
-RSpec.describe ProjectStatus do
+RSpec.describe OrganizationStatus do
describe 'associations' do
end
describe 'validations' do
- subject { build(:project_status) }
+ subject { build(:organization_status) }
end
it 'is valid with valid attributes' do
- expect(build(:project_status)).to be_valid
+ expect(build(:organization_status)).to be_valid
end
end
diff --git a/spec/models/project_user_spec.rb b/spec/models/organization_user_spec.rb
similarity index 51%
rename from spec/models/project_user_spec.rb
rename to spec/models/organization_user_spec.rb
index 1bfcad0ff..8ec22f92f 100644
--- a/spec/models/project_user_spec.rb
+++ b/spec/models/organization_user_spec.rb
@@ -1,16 +1,16 @@
require 'rails_helper'
-RSpec.describe ProjectUser do
+RSpec.describe OrganizationUser do
describe 'associations' do
- it { should belong_to(:project) }
+ it { should belong_to(:organization) }
it { should belong_to(:user) }
end
describe 'validations' do
subject do
- build(:project_user, project: create(:project), user: create(:user))
+ build(:organization_user, organization: create(:organization), user: create(:user))
end
- it { should validate_presence_of(:project_id) }
+ it { should validate_presence_of(:organization_id) }
end
describe 'enums' do
@@ -19,7 +19,7 @@
it 'is valid with valid attributes' do
# Note: Factory needs associations uncommented for create
- # expect(build(:project_user)).to be_valid
- # pending("Requires functional project/user factories and associations uncommented")
+ # expect(build(:organization_user)).to be_valid
+ # pending("Requires functional organization/user factories and associations uncommented")
end
end
diff --git a/spec/models/report_spec.rb b/spec/models/report_spec.rb
index 356644b55..df5af7b71 100644
--- a/spec/models/report_spec.rb
+++ b/spec/models/report_spec.rb
@@ -3,7 +3,7 @@
RSpec.describe Report do
describe "associations" do
it { should belong_to(:user) }
- it { should belong_to(:project) }
+ it { should belong_to(:organization) }
it { should belong_to(:windows_type) }
it { should belong_to(:owner).optional }
it { should have_one(:form) }
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index 2bd17fce6..bfb3f9638 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -18,14 +18,14 @@
it { should have_many(:bookmarked_workshops).through(:bookmarks).source(:bookmarkable) }
it { should have_many(:bookmarked_resources).through(:bookmarks).source(:bookmarkable) }
it { should have_many(:bookmarked_events).through(:bookmarks).source(:bookmarkable) }
- it { should have_many(:project_users).dependent(:destroy) }
- it { should have_many(:projects).through(:project_users) }
- it { should have_many(:windows_types).through(:projects) }
+ it { should have_many(:organization_users).dependent(:destroy) }
+ it { should have_many(:organizations).through(:organization_users) }
+ it { should have_many(:windows_types).through(:organizations) }
it { should have_many(:resources) }
it { should have_many(:user_forms).dependent(:destroy) }
it { should have_many(:user_form_form_fields).through(:user_forms).dependent(:destroy) }
# Custom scope/select for colleagues might interfere
- # it { should have_many(:colleagues).through(:projects).source(:project_users) }
+ # it { should have_many(:colleagues).through(:organizations).source(:organization_users) }
it { should have_many(:notifications) } # As :noticeable
# Paperclip avatar
@@ -33,7 +33,7 @@
# Nested Attributes
it { should accept_nested_attributes_for(:user_forms) }
- it { should accept_nested_attributes_for(:project_users).allow_destroy(true) }
+ it { should accept_nested_attributes_for(:organization_users).allow_destroy(true) }
end
describe "validations" do
diff --git a/spec/models/workshop_log_spec.rb b/spec/models/workshop_log_spec.rb
index 673103194..3d5691443 100644
--- a/spec/models/workshop_log_spec.rb
+++ b/spec/models/workshop_log_spec.rb
@@ -11,7 +11,7 @@
# Explicitly defined here
it { should belong_to(:workshop) }
it { should belong_to(:user) } # Inherited via Report but also explicit?
- it { should belong_to(:project) } # Inherited via Report but also explicit?
+ it { should belong_to(:organization) } # Inherited via Report but also explicit?
it { should have_many(:media_files) }
# Inherited from Report
diff --git a/spec/requests/community_news_spec.rb b/spec/requests/community_news_spec.rb
index 2464dd4ac..f318e4065 100644
--- a/spec/requests/community_news_spec.rb
+++ b/spec/requests/community_news_spec.rb
@@ -26,7 +26,7 @@
featured: false,
author_id: admin.id,
reference_url: "www.google.com",
- project: nil,
+ organization: nil,
windows_type: nil,
created_by_id: admin.id,
updated_by_id: admin.id
diff --git a/spec/requests/organization_statuses_spec.rb b/spec/requests/organization_statuses_spec.rb
new file mode 100644
index 000000000..d76d406d4
--- /dev/null
+++ b/spec/requests/organization_statuses_spec.rb
@@ -0,0 +1,118 @@
+require "rails_helper"
+
+RSpec.describe "OrganizationStatuses", type: :request do
+ let(:admin) { create(:user, :admin) }
+ let(:regular_user) { create(:user) }
+ let!(:status) { create(:organization_status, name: "Active") }
+
+ let(:valid_params) { { organization_status: { name: "New Status" } } }
+ let(:invalid_params) { { organization_status: { name: nil } } }
+
+ # --------------------------------------------------
+ # ADMIN ACCESS
+ # --------------------------------------------------
+ describe "admin access" do
+ before { sign_in admin }
+
+ it "loads index" do
+ get organization_statuses_path
+ expect(response).to have_http_status(:ok)
+ end
+
+ it "loads show" do
+ get organization_status_path(status)
+ expect(response).to have_http_status(:ok)
+ end
+
+ it "loads new" do
+ get new_organization_status_path
+ expect(response).to have_http_status(:ok)
+ end
+
+ it "loads edit" do
+ get edit_organization_status_path(status)
+ expect(response).to have_http_status(:ok)
+ end
+
+ it "creates record" do
+ expect {
+ post organization_statuses_path, params: valid_params
+ }.to change(OrganizationStatus, :count).by(1)
+
+ expect(response).to redirect_to(organization_statuses_path)
+ end
+
+ it "rejects invalid create" do
+ post organization_statuses_path, params: invalid_params
+ expect(response).to have_http_status(:unprocessable_content)
+ end
+
+ it "updates record" do
+ patch organization_status_path(status),
+ params: { organization_status: { name: "Updated" } }
+
+ expect(response).to redirect_to(organization_statuses_path)
+ expect(status.reload.name).to eq("Updated")
+ end
+
+ it "destroys record" do
+ expect {
+ delete organization_status_path(status)
+ }.to change(OrganizationStatus, :count).by(-1)
+
+ expect(response).to redirect_to(organization_statuses_path)
+ end
+ end
+
+ # --------------------------------------------------
+ # REGULAR USER BLOCKED
+ # --------------------------------------------------
+ describe "regular user restrictions" do
+ before { sign_in regular_user }
+
+ it "cannot access index" do
+ get organization_statuses_path
+ expect(response).to redirect_to(root_path)
+ end
+
+ it "cannot access show" do
+ get organization_status_path(status)
+ expect(response).to redirect_to(root_path)
+ end
+
+ it "cannot access new" do
+ get new_organization_status_path
+ expect(response).to redirect_to(root_path)
+ end
+
+ it "cannot create" do
+ post organization_statuses_path, params: valid_params
+ expect(response).to redirect_to(root_path)
+ end
+
+ it "cannot access edit" do
+ get edit_organization_status_path(status)
+ expect(response).to redirect_to(root_path)
+ end
+
+ it "cannot update" do
+ patch organization_status_path(status), params: valid_params
+ expect(response).to redirect_to(root_path)
+ end
+
+ it "cannot destroy" do
+ delete organization_status_path(status)
+ expect(response).to redirect_to(root_path)
+ end
+ end
+
+ # --------------------------------------------------
+ # GUEST BLOCKED
+ # --------------------------------------------------
+ describe "unauthenticated access" do
+ it "redirects to sign in" do
+ get organization_statuses_path
+ expect(response).to redirect_to(new_user_session_path)
+ end
+ end
+end
diff --git a/spec/requests/organizations_spec.rb b/spec/requests/organizations_spec.rb
new file mode 100644
index 000000000..6c6e33ba1
--- /dev/null
+++ b/spec/requests/organizations_spec.rb
@@ -0,0 +1,143 @@
+require "rails_helper"
+
+RSpec.describe "/organizations", type: :request do
+ let(:user) { create(:user) }
+ let(:admin) { create(:user, :admin) }
+
+ let!(:location) { create(:location) }
+ let!(:organization_status) { create(:organization_status, name: "Active") }
+
+ let(:valid_attributes) do
+ {
+ name: "Healing Through Art",
+ description: "A community program supporting trauma-informed workshops.",
+ start_date: Date.today - 6.months,
+ end_date: Date.today + 6.months,
+ organization_status_id: organization_status.id,
+ inactive: false,
+ notes: "Runs bi-weekly at community centers."
+ }
+ end
+
+ let(:invalid_attributes) do
+ {
+ name: "", # required field missing
+ description: nil,
+ organization_status_id: nil,
+ windows_type_id: nil
+ }
+ end
+
+ before do
+ sign_in admin
+ end
+
+ describe "GET /index" do
+ it "renders a successful response" do
+ Organization.create!(valid_attributes)
+ get organizations_url
+ expect(response).to be_successful
+ end
+ end
+
+ describe "GET /show" do
+ it "renders a successful response" do
+ organization = Organization.create!(valid_attributes)
+ get organization_url(organization)
+ expect(response).to be_successful
+ end
+ end
+
+ describe "GET /new" do
+ it "renders a successful response" do
+ get new_organization_url
+ expect(response).to be_successful
+ end
+ end
+
+ describe "GET /edit" do
+ it "renders a successful response" do
+ organization = Organization.create!(valid_attributes)
+ get edit_organization_url(organization)
+ expect(response).to be_successful
+ end
+ end
+
+ describe "POST /create" do
+ context "with valid parameters" do
+ it "creates a new Organization" do
+ expect {
+ post organizations_url, params: { organization: valid_attributes }
+ }.to change(Organization, :count).by(1)
+ end
+
+ it "redirects to the organizations index" do
+ post organizations_url, params: { organization: valid_attributes }
+ expect(response).to redirect_to(organizations_url)
+ end
+ end
+
+ context "with invalid parameters" do
+ it "does not create a new Organization" do
+ expect {
+ post organizations_url, params: { organization: invalid_attributes }
+ }.not_to change(Organization, :count)
+ end
+
+ it "renders a response with 422 status (i.e. to display the 'new' template)" do
+ post organizations_url, params: { organization: invalid_attributes }
+ expect(response).to have_http_status(:unprocessable_content)
+ end
+ end
+ end
+
+ describe "PATCH /update" do
+ context "with valid parameters" do
+ let(:new_attributes) do
+ {
+ name: "Updated Healing Organization",
+ description: "Updated description for testing.",
+ inactive: true
+ }
+ end
+
+ it "updates the requested organization" do
+ organization = Organization.create!(valid_attributes)
+ patch organization_url(organization), params: { organization: new_attributes }
+ organization.reload
+ expect(organization.name).to eq("Updated Healing Organization")
+ expect(organization.description).to eq("Updated description for testing.")
+ expect(organization.inactive).to be(true)
+ end
+
+ it "redirects to the organizations index" do
+ organization = Organization.create!(valid_attributes)
+ patch organization_url(organization), params: { organization: new_attributes }
+ expect(response).to redirect_to(organizations_url)
+ end
+ end
+
+ context "with invalid parameters" do
+ it "renders a response with 422 status (i.e. to display the 'edit' template)" do
+ organization = Organization.create!(valid_attributes)
+ patch organization_url(organization), params: { organization: invalid_attributes }
+ expect(response).to have_http_status(:unprocessable_content)
+ end
+ end
+ end
+
+ describe "DELETE /destroy" do
+ it "destroys the requested organization" do
+ organization = Organization.create!(valid_attributes)
+ expect {
+ delete organization_url(organization)
+ }.to change(Organization, :count).by(-1)
+ end
+
+ it "redirects to the organizations list" do
+ organization = Organization.create!(valid_attributes)
+ delete organization_url(organization)
+ expect(response).to redirect_to(organizations_url)
+ end
+ end
+end
diff --git a/spec/requests/project_statuses_spec.rb b/spec/requests/project_statuses_spec.rb
deleted file mode 100644
index e1e277c37..000000000
--- a/spec/requests/project_statuses_spec.rb
+++ /dev/null
@@ -1,153 +0,0 @@
-require "rails_helper"
-
-RSpec.describe "/project_statuses", type: :request do
- let(:admin) { create(:user, :admin) }
- let(:regular_user) { create(:user) }
-
- let(:valid_attributes) do
- { name: "Active" }
- end
-
- let(:invalid_attributes) do
- { name: nil }
- end
-
- # --------------------------------------------------
- # ADMIN ACCESS
- # --------------------------------------------------
- describe "admin access" do
- before { sign_in admin }
-
- describe "GET /index" do
- it "renders successfully" do
- get project_statuses_url
- expect(response).to be_successful
- end
- end
-
- describe "GET /show" do
- it "renders successfully" do
- project_status = ProjectStatus.create!(valid_attributes)
- get project_status_url(project_status)
- expect(response).to be_successful
- end
- end
-
- describe "GET /new" do
- it "renders successfully" do
- get new_project_status_url
- expect(response).to be_successful
- end
- end
-
- describe "GET /edit" do
- it "renders successfully" do
- project_status = ProjectStatus.create!(valid_attributes)
- get edit_project_status_url(project_status)
- expect(response).to be_successful
- end
- end
-
- describe "POST /create" do
- context "with valid params" do
- it "creates a ProjectStatus" do
- expect {
- post project_statuses_url, params: { project_status: valid_attributes }
- }.to change(ProjectStatus, :count).by(1)
- end
-
- it "redirects to index" do
- post project_statuses_url, params: { project_status: valid_attributes }
- expect(response).to redirect_to(project_statuses_url)
- end
- end
-
- context "with invalid params" do
- it "does not create a ProjectStatus" do
- expect {
- post project_statuses_url, params: { project_status: invalid_attributes }
- }.not_to change(ProjectStatus, :count)
- end
-
- it "returns 422" do
- post project_statuses_url, params: { project_status: invalid_attributes }
- expect(response).to have_http_status(:unprocessable_content)
- end
- end
- end
-
- describe "PATCH /update" do
- it "updates and redirects" do
- project_status = ProjectStatus.create!(valid_attributes)
-
- patch project_status_url(project_status),
- params: { project_status: { name: "Updated" } }
-
- expect(response).to redirect_to(project_statuses_url)
- expect(project_status.reload.name).to eq("Updated")
- end
- end
-
- describe "DELETE /destroy" do
- it "destroys and redirects" do
- project_status = ProjectStatus.create!(valid_attributes)
-
- expect {
- delete project_status_url(project_status)
- }.to change(ProjectStatus, :count).by(-1)
-
- expect(response).to redirect_to(project_statuses_url)
- end
- end
- end
-
- # --------------------------------------------------
- # REGULAR USER ACCESS (BLOCKED)
- # --------------------------------------------------
- describe "regular user restrictions" do
- before { sign_in regular_user }
-
- it "cannot access index" do
- get project_statuses_url
- expect(response).to redirect_to(root_path)
- end
-
- it "cannot access show" do
- ps = ProjectStatus.create!(valid_attributes)
- get project_status_url(ps)
- expect(response).to redirect_to(root_path)
- end
-
- it "cannot access new" do
- get new_project_status_url
- expect(response).to redirect_to(root_path)
- end
-
- it "cannot create" do
- post project_statuses_url, params: { project_status: valid_attributes }
- expect(response).to redirect_to(root_path)
- end
-
- it "cannot edit" do
- ps = ProjectStatus.create!(valid_attributes)
- get edit_project_status_url(ps)
- expect(response).to redirect_to(root_path)
- end
-
- it "cannot destroy" do
- ps = ProjectStatus.create!(valid_attributes)
- delete project_status_url(ps)
- expect(response).to redirect_to(root_path)
- end
- end
-
- # --------------------------------------------------
- # UNAUTHENTICATED ACCESS (BLOCKED)
- # --------------------------------------------------
- describe "unauthenticated access" do
- it "redirects to sign-in" do
- get project_statuses_url
- expect(response).to redirect_to(new_user_session_path)
- end
- end
-end
diff --git a/spec/requests/projects_spec.rb b/spec/requests/projects_spec.rb
deleted file mode 100644
index 6fe484e63..000000000
--- a/spec/requests/projects_spec.rb
+++ /dev/null
@@ -1,143 +0,0 @@
-require "rails_helper"
-
-RSpec.describe "/projects", type: :request do
- let(:user) { create(:user) }
- let(:admin) { create(:user, :admin) }
-
- let!(:location) { create(:location) }
- let!(:project_status) { create(:project_status, name: "Active") }
-
- let(:valid_attributes) do
- {
- name: "Healing Through Art",
- description: "A community program supporting trauma-informed workshops.",
- start_date: Date.today - 6.months,
- end_date: Date.today + 6.months,
- project_status_id: project_status.id,
- inactive: false,
- notes: "Runs bi-weekly at community centers."
- }
- end
-
- let(:invalid_attributes) do
- {
- name: "", # required field missing
- description: nil,
- project_status_id: nil,
- windows_type_id: nil
- }
- end
-
- before do
- sign_in admin
- end
-
- describe "GET /index" do
- it "renders a successful response" do
- Project.create!(valid_attributes)
- get projects_url
- expect(response).to be_successful
- end
- end
-
- describe "GET /show" do
- it "renders a successful response" do
- project = Project.create!(valid_attributes)
- get project_url(project)
- expect(response).to be_successful
- end
- end
-
- describe "GET /new" do
- it "renders a successful response" do
- get new_project_url
- expect(response).to be_successful
- end
- end
-
- describe "GET /edit" do
- it "renders a successful response" do
- project = Project.create!(valid_attributes)
- get edit_project_url(project)
- expect(response).to be_successful
- end
- end
-
- describe "POST /create" do
- context "with valid parameters" do
- it "creates a new Project" do
- expect {
- post projects_url, params: { project: valid_attributes }
- }.to change(Project, :count).by(1)
- end
-
- it "redirects to the projects index" do
- post projects_url, params: { project: valid_attributes }
- expect(response).to redirect_to(projects_url)
- end
- end
-
- context "with invalid parameters" do
- it "does not create a new Project" do
- expect {
- post projects_url, params: { project: invalid_attributes }
- }.not_to change(Project, :count)
- end
-
- it "renders a response with 422 status (i.e. to display the 'new' template)" do
- post projects_url, params: { project: invalid_attributes }
- expect(response).to have_http_status(:unprocessable_content)
- end
- end
- end
-
- describe "PATCH /update" do
- context "with valid parameters" do
- let(:new_attributes) do
- {
- name: "Updated Healing Project",
- description: "Updated description for testing.",
- inactive: true
- }
- end
-
- it "updates the requested project" do
- project = Project.create!(valid_attributes)
- patch project_url(project), params: { project: new_attributes }
- project.reload
- expect(project.name).to eq("Updated Healing Project")
- expect(project.description).to eq("Updated description for testing.")
- expect(project.inactive).to be(true)
- end
-
- it "redirects to the projects index" do
- project = Project.create!(valid_attributes)
- patch project_url(project), params: { project: new_attributes }
- expect(response).to redirect_to(projects_url)
- end
- end
-
- context "with invalid parameters" do
- it "renders a response with 422 status (i.e. to display the 'edit' template)" do
- project = Project.create!(valid_attributes)
- patch project_url(project), params: { project: invalid_attributes }
- expect(response).to have_http_status(:unprocessable_content)
- end
- end
- end
-
- describe "DELETE /destroy" do
- it "destroys the requested project" do
- project = Project.create!(valid_attributes)
- expect {
- delete project_url(project)
- }.to change(Project, :count).by(-1)
- end
-
- it "redirects to the projects list" do
- project = Project.create!(valid_attributes)
- delete project_url(project)
- expect(response).to redirect_to(projects_url)
- end
- end
-end
diff --git a/spec/requests/resources_spec.rb b/spec/requests/resources_spec.rb
index ebd289767..4c4e6dacd 100644
--- a/spec/requests/resources_spec.rb
+++ b/spec/requests/resources_spec.rb
@@ -3,7 +3,7 @@
RSpec.describe "/resources", type: :request do
let(:user) { create(:user, super_user: true) }
let(:windows_type) { create(:windows_type) }
- let(:project) { create(:project) }
+ let(:organization) { create(:organization) }
let(:valid_attributes) do
{
diff --git a/spec/requests/stories_spec.rb b/spec/requests/stories_spec.rb
index 311c09d71..bb9933d1c 100644
--- a/spec/requests/stories_spec.rb
+++ b/spec/requests/stories_spec.rb
@@ -19,7 +19,7 @@
let(:user) { create(:user) }
let(:windows_type) { create(:windows_type) }
let(:workshop) { create(:workshop) }
- let(:project) { create(:project) }
+ let(:organization) { create(:organization) }
let(:valid_attributes) do
{
@@ -30,7 +30,7 @@
published: true,
windows_type_id: windows_type.id,
workshop_id: workshop.id,
- project_id: project.id,
+ organization_id: organization.id,
created_by_id: user.id,
updated_by_id: user.id
}
diff --git a/spec/requests/story_ideas_spec.rb b/spec/requests/story_ideas_spec.rb
index 911e498fd..0bf73cd74 100644
--- a/spec/requests/story_ideas_spec.rb
+++ b/spec/requests/story_ideas_spec.rb
@@ -21,7 +21,7 @@
let(:windows_type) { create(:windows_type) }
let(:workshop) { create(:workshop) }
- let(:project) { create(:project) }
+ let(:organization) { create(:organization) }
let(:valid_attributes) do
{
@@ -31,7 +31,7 @@
permission_given: true,
windows_type_id: windows_type.id,
workshop_id: workshop.id,
- project_id: project.id,
+ organization_id: organization.id,
created_by_id: user.id,
updated_by_id: user.id
}
diff --git a/spec/requests/workshop_logs_spec.rb b/spec/requests/workshop_logs_spec.rb
index 2646e372f..afbb531c1 100644
--- a/spec/requests/workshop_logs_spec.rb
+++ b/spec/requests/workshop_logs_spec.rb
@@ -6,13 +6,13 @@
let(:user) { create(:user) }
let(:windows_type) { create(:windows_type) }
let(:workshop) { create(:workshop) }
- let(:project) { create(:project) }
+ let(:organization) { create(:organization) }
let(:valid_attributes) do
{
date: Date.current,
workshop_id: workshop.id,
- project_id: project.id,
+ organization_id: organization.id,
windows_type_id: windows_type.id,
user_id: user.id,
diff --git a/spec/routing/organization_statuses_routing_spec.rb b/spec/routing/organization_statuses_routing_spec.rb
new file mode 100644
index 000000000..615fab3a1
--- /dev/null
+++ b/spec/routing/organization_statuses_routing_spec.rb
@@ -0,0 +1,38 @@
+require "rails_helper"
+
+RSpec.describe OrganizationStatusesController, type: :routing do
+ describe "routing" do
+ it "routes to #index" do
+ expect(get: "/organization_statuses").to route_to("organization_statuses#index")
+ end
+
+ it "routes to #new" do
+ expect(get: "/organization_statuses/new").to route_to("organization_statuses#new")
+ end
+
+ it "routes to #show" do
+ expect(get: "/organization_statuses/1").to route_to("organization_statuses#show", id: "1")
+ end
+
+ it "routes to #edit" do
+ expect(get: "/organization_statuses/1/edit").to route_to("organization_statuses#edit", id: "1")
+ end
+
+
+ it "routes to #create" do
+ expect(post: "/organization_statuses").to route_to("organization_statuses#create")
+ end
+
+ it "routes to #update via PUT" do
+ expect(put: "/organization_statuses/1").to route_to("organization_statuses#update", id: "1")
+ end
+
+ it "routes to #update via PATCH" do
+ expect(patch: "/organization_statuses/1").to route_to("organization_statuses#update", id: "1")
+ end
+
+ it "routes to #destroy" do
+ expect(delete: "/organization_statuses/1").to route_to("organization_statuses#destroy", id: "1")
+ end
+ end
+end
diff --git a/spec/routing/organizations_routing_spec.rb b/spec/routing/organizations_routing_spec.rb
new file mode 100644
index 000000000..8a6c631ab
--- /dev/null
+++ b/spec/routing/organizations_routing_spec.rb
@@ -0,0 +1,38 @@
+require "rails_helper"
+
+RSpec.describe OrganizationsController, type: :routing do
+ describe "routing" do
+ it "routes to #index" do
+ expect(get: "/organizations").to route_to("organizations#index")
+ end
+
+ it "routes to #new" do
+ expect(get: "/organizations/new").to route_to("organizations#new")
+ end
+
+ it "routes to #show" do
+ expect(get: "/organizations/1").to route_to("organizations#show", id: "1")
+ end
+
+ it "routes to #edit" do
+ expect(get: "/organizations/1/edit").to route_to("organizations#edit", id: "1")
+ end
+
+
+ it "routes to #create" do
+ expect(post: "/organizations").to route_to("organizations#create")
+ end
+
+ it "routes to #update via PUT" do
+ expect(put: "/organizations/1").to route_to("organizations#update", id: "1")
+ end
+
+ it "routes to #update via PATCH" do
+ expect(patch: "/organizations/1").to route_to("organizations#update", id: "1")
+ end
+
+ it "routes to #destroy" do
+ expect(delete: "/organizations/1").to route_to("organizations#destroy", id: "1")
+ end
+ end
+end
diff --git a/spec/routing/project_statuses_routing_spec.rb b/spec/routing/project_statuses_routing_spec.rb
deleted file mode 100644
index 62a654b04..000000000
--- a/spec/routing/project_statuses_routing_spec.rb
+++ /dev/null
@@ -1,38 +0,0 @@
-require "rails_helper"
-
-RSpec.describe ProjectStatusesController, type: :routing do
- describe "routing" do
- it "routes to #index" do
- expect(get: "/project_statuses").to route_to("project_statuses#index")
- end
-
- it "routes to #new" do
- expect(get: "/project_statuses/new").to route_to("project_statuses#new")
- end
-
- it "routes to #show" do
- expect(get: "/project_statuses/1").to route_to("project_statuses#show", id: "1")
- end
-
- it "routes to #edit" do
- expect(get: "/project_statuses/1/edit").to route_to("project_statuses#edit", id: "1")
- end
-
-
- it "routes to #create" do
- expect(post: "/project_statuses").to route_to("project_statuses#create")
- end
-
- it "routes to #update via PUT" do
- expect(put: "/project_statuses/1").to route_to("project_statuses#update", id: "1")
- end
-
- it "routes to #update via PATCH" do
- expect(patch: "/project_statuses/1").to route_to("project_statuses#update", id: "1")
- end
-
- it "routes to #destroy" do
- expect(delete: "/project_statuses/1").to route_to("project_statuses#destroy", id: "1")
- end
- end
-end
diff --git a/spec/routing/projects_routing_spec.rb b/spec/routing/projects_routing_spec.rb
deleted file mode 100644
index 19b9fe1cb..000000000
--- a/spec/routing/projects_routing_spec.rb
+++ /dev/null
@@ -1,38 +0,0 @@
-require "rails_helper"
-
-RSpec.describe ProjectsController, type: :routing do
- describe "routing" do
- it "routes to #index" do
- expect(get: "/projects").to route_to("projects#index")
- end
-
- it "routes to #new" do
- expect(get: "/projects/new").to route_to("projects#new")
- end
-
- it "routes to #show" do
- expect(get: "/projects/1").to route_to("projects#show", id: "1")
- end
-
- it "routes to #edit" do
- expect(get: "/projects/1/edit").to route_to("projects#edit", id: "1")
- end
-
-
- it "routes to #create" do
- expect(post: "/projects").to route_to("projects#create")
- end
-
- it "routes to #update via PUT" do
- expect(put: "/projects/1").to route_to("projects#update", id: "1")
- end
-
- it "routes to #update via PATCH" do
- expect(patch: "/projects/1").to route_to("projects#update", id: "1")
- end
-
- it "routes to #destroy" do
- expect(delete: "/projects/1").to route_to("projects#destroy", id: "1")
- end
- end
-end
diff --git a/spec/views/community_news/edit.html.erb_spec.rb b/spec/views/community_news/edit.html.erb_spec.rb
index 822b42e82..d9da12080 100644
--- a/spec/views/community_news/edit.html.erb_spec.rb
+++ b/spec/views/community_news/edit.html.erb_spec.rb
@@ -12,7 +12,7 @@
featured: false,
author: create(:user),
reference_url: "MyString",
- project: nil,
+ organization: nil,
windows_type: nil,
created_by: create(:user),
updated_by: create(:user),
@@ -43,7 +43,9 @@
assert_select "textarea[name=?]", "community_news[reference_url]"
- assert_select "select[name=?]", "community_news[project_id]"
+ assert_select "select[name=?]", "community_news[organization_id]"
+
+ assert_select "select[name=?]", "community_news[windows_type_id]"
end
end
end
diff --git a/spec/views/community_news/index.html.erb_spec.rb b/spec/views/community_news/index.html.erb_spec.rb
new file mode 100644
index 000000000..f2f9c3e4f
--- /dev/null
+++ b/spec/views/community_news/index.html.erb_spec.rb
@@ -0,0 +1,50 @@
+require 'rails_helper'
+
+RSpec.describe "community_news/index", type: :view do
+ let(:admin) { create(:user, :admin) }
+
+ let(:community_news1) { CommunityNews.create!(
+ title: "Title1",
+ body: "MyText",
+ youtube_url: "Youtube Url",
+ published: false,
+ featured: false,
+ author: create(:user),
+ reference_url: "Reference Url",
+ organization: nil,
+ windows_type: nil,
+ created_by: create(:user),
+ updated_by: create(:user),
+ ) }
+ let(:community_news2) { CommunityNews.create!(
+ title: "Title2",
+ body: "MyText",
+ youtube_url: "Youtube Url",
+ published: false,
+ featured: false,
+ author: create(:user),
+ reference_url: "Reference Url",
+ organization: nil,
+ windows_type: nil,
+ created_by: create(:user),
+ updated_by: create(:user),
+ ) }
+
+ before(:each) do
+ sign_in admin
+ assign(:community_news,
+ CommunityNewsDecorator.decorate_collection(
+ paginated([ community_news1, community_news2 ])))
+ end
+
+ it "renders a list of community_news" do
+ render
+ expect(rendered).to include(community_news1.title, community_news2.title)
+ end
+
+ it "renders a friendly message when no community_news exist" do
+ assign(:community_news, paginated([]))
+ render
+ expect(rendered).to match(/No community news yet/)
+ end
+end
diff --git a/spec/views/community_news/new.html.erb_spec.rb b/spec/views/community_news/new.html.erb_spec.rb
index ef3cac146..18dfc7d95 100644
--- a/spec/views/community_news/new.html.erb_spec.rb
+++ b/spec/views/community_news/new.html.erb_spec.rb
@@ -15,7 +15,7 @@
featured: false,
author: create(:user),
reference_url: "MyString",
- project: nil,
+ organization: nil,
windows_type: nil,
created_by: create(:user),
updated_by: create(:user),
@@ -46,7 +46,7 @@
assert_select "textarea[name=?]", "community_news[reference_url]"
- assert_select "select[name=?]", "community_news[project_id]"
+ assert_select "select[name=?]", "community_news[organization_id]"
end
end
diff --git a/spec/views/community_news/show.html.erb_spec.rb b/spec/views/community_news/show.html.erb_spec.rb
index a3d886eb3..ad933d586 100644
--- a/spec/views/community_news/show.html.erb_spec.rb
+++ b/spec/views/community_news/show.html.erb_spec.rb
@@ -16,7 +16,7 @@
featured: false,
author: create(:user),
reference_url: "Reference Url",
- project: nil,
+ organization: nil,
windows_type: nil,
created_by: create(:user),
updated_by: create(:user),
diff --git a/spec/views/organization_statuses/edit.html.erb_spec.rb b/spec/views/organization_statuses/edit.html.erb_spec.rb
new file mode 100644
index 000000000..e84b53e81
--- /dev/null
+++ b/spec/views/organization_statuses/edit.html.erb_spec.rb
@@ -0,0 +1,19 @@
+require 'rails_helper'
+
+RSpec.describe "organization_statuses/edit", type: :view do
+ let(:admin) { create(:user, :admin) }
+ let(:organization_status) { create(:organization_status) }
+
+ before(:each) do
+ sign_in admin
+ assign(:organization_status, organization_status)
+ end
+
+ it "renders the edit organization_status form" do
+ render
+
+ assert_select "form[action=?][method=?]", organization_status_path(organization_status), "post" do
+ assert_select "input[name=?]", "organization_status[name]"
+ end
+ end
+end
diff --git a/spec/views/organization_statuses/index.html.erb_spec.rb b/spec/views/organization_statuses/index.html.erb_spec.rb
new file mode 100644
index 000000000..a9865031f
--- /dev/null
+++ b/spec/views/organization_statuses/index.html.erb_spec.rb
@@ -0,0 +1,23 @@
+require 'rails_helper'
+
+RSpec.describe "organization_statuses/index", type: :view do
+ let(:admin) { create(:user, :admin) }
+ let(:organization_status1) { create(:organization_status, name: "Active") }
+ let(:organization_status2) { create(:organization_status, name: "Suspended") }
+
+ before(:each) do
+ assign(:organization_statuses, paginated([ organization_status1, organization_status2 ]))
+ allow(view).to receive(:current_user).and_return(admin)
+ end
+
+ it "renders a list of organization_statuses" do
+ render
+ expect(rendered).to include(organization_status1.name, organization_status2.name)
+ end
+
+ it "renders a friendly message when no organization_statuses exist" do
+ assign(:organization_statuses, paginated([]))
+ render
+ expect(rendered).to match(/No organization statuses found/)
+ end
+end
diff --git a/spec/views/organization_statuses/new.html.erb_spec.rb b/spec/views/organization_statuses/new.html.erb_spec.rb
new file mode 100644
index 000000000..28c674179
--- /dev/null
+++ b/spec/views/organization_statuses/new.html.erb_spec.rb
@@ -0,0 +1,19 @@
+require 'rails_helper'
+
+RSpec.describe "organization_statuses/new", type: :view do
+ let(:admin) { create(:user, :admin) }
+ let(:organization_status) { build(:organization_status) }
+
+ before do
+ allow(view).to receive(:current_user).and_return(admin)
+ assign(:organization_status, organization_status)
+ end
+
+ it "renders new organization_status form" do
+ render
+
+ assert_select "form[action=?]", organization_statuses_path do
+ assert_select "input[name=?]", "organization_status[name]"
+ end
+ end
+end
diff --git a/spec/views/project_statuses/show.html.erb_spec.rb b/spec/views/organization_statuses/show.html.erb_spec.rb
similarity index 56%
rename from spec/views/project_statuses/show.html.erb_spec.rb
rename to spec/views/organization_statuses/show.html.erb_spec.rb
index c898a21a7..696c646a6 100644
--- a/spec/views/project_statuses/show.html.erb_spec.rb
+++ b/spec/views/organization_statuses/show.html.erb_spec.rb
@@ -1,11 +1,11 @@
require 'rails_helper'
-RSpec.describe "project_statuses/show", type: :view do
+RSpec.describe "organization_statuses/show", type: :view do
let(:admin) { create(:user, :admin) }
- let(:project_status) { create(:project_status, name: "Name") }
+ let(:organization_status) { create(:organization_status, name: "Name") }
before(:each) do
- assign(:project_status, project_status)
+ assign(:organization_status, organization_status)
allow(view).to receive(:current_user).and_return(admin)
end
diff --git a/spec/views/organizations/edit.html.erb_spec.rb b/spec/views/organizations/edit.html.erb_spec.rb
new file mode 100644
index 000000000..2f22862e4
--- /dev/null
+++ b/spec/views/organizations/edit.html.erb_spec.rb
@@ -0,0 +1,43 @@
+require 'rails_helper'
+
+RSpec.describe "organizations/edit", type: :view do
+ let(:user) { create(:user) }
+ let(:admin) { create(:user, :admin) }
+
+ let(:organization_status) { create(:organization_status) }
+ let(:windows_type) { create(:windows_type) }
+
+ let(:organization) {
+ Organization.create!(
+ windows_type: windows_type,
+ organization_status: organization_status,
+ location: nil,
+ name: "MyString",
+ description: "MyString",
+ inactive: false,
+ notes: "MyText"
+ )
+ }
+
+ before(:each) do
+ assign(:organization, organization)
+ allow(view).to receive(:current_user).and_return(admin)
+ render
+ end
+
+ it "renders the edit organization form" do
+ assert_select "form[action=?][method=?]", organization_path(organization), "post" do
+ assert_select "select[name=?]", "organization[windows_type_id]"
+
+ assert_select "textarea[name=?]", "organization[name]"
+
+ assert_select "textarea[name=?]", "organization[description]"
+
+ assert_select "select[name=?]", "organization[organization_status_id]"
+
+ assert_select "input[name=?]", "organization[inactive]"
+
+ assert_select "textarea[name=?]", "organization[notes]"
+ end
+ end
+end
diff --git a/spec/views/organizations/index.html.erb_spec.rb b/spec/views/organizations/index.html.erb_spec.rb
new file mode 100644
index 000000000..654a53f64
--- /dev/null
+++ b/spec/views/organizations/index.html.erb_spec.rb
@@ -0,0 +1,25 @@
+require "rails_helper"
+
+RSpec.describe "organizations/index", type: :view do
+ let(:user) { create(:user) }
+ let(:admin) { create(:user, :admin) }
+
+ let!(:organization1) { create(:organization, name: "Organization 1") }
+ let!(:organization2) { create(:organization, name: "Organization 2") }
+
+ let!(:organization_status1) { create(:organization_status, name: "Active") }
+ let!(:organization_status2) { create(:organization_status, name: "Suspended") }
+ let!(:organization_status3) { create(:organization_status, name: "Inactive") }
+
+ before(:each) do
+ assign(:organizations, paginated([ organization1, organization2 ]))
+ assign(:organization_statuses, [ organization_status1, organization_status2, organization_status3 ])
+ allow(view).to receive(:current_user).and_return(user)
+ render
+ end
+
+ it "renders a list of organizations" do
+ expect(rendered).to match(organization1.name)
+ expect(rendered).to match(organization2.name)
+ end
+end
diff --git a/spec/views/organizations/new.html.erb_spec.rb b/spec/views/organizations/new.html.erb_spec.rb
new file mode 100644
index 000000000..9b76f5321
--- /dev/null
+++ b/spec/views/organizations/new.html.erb_spec.rb
@@ -0,0 +1,28 @@
+require 'rails_helper'
+
+RSpec.describe "organizations/new", type: :view do
+ let(:user) { create(:user) }
+ let(:admin) { create(:user, :admin) }
+
+ before do
+ assign(:organization, Organization.new)
+ allow(view).to receive(:current_user).and_return(admin)
+ render
+ end
+
+ it "renders new organization form" do
+ assert_select "form[action=?][method=?]", organizations_path, "post" do
+ assert_select "select[name=?]", "organization[windows_type_id]"
+
+ assert_select "textarea[name=?]", "organization[name]"
+
+ assert_select "textarea[name=?]", "organization[description]"
+
+ assert_select "select[name=?]", "organization[organization_status_id]"
+
+ assert_select "input[name=?]", "organization[inactive]"
+
+ assert_select "textarea[name=?]", "organization[notes]"
+ end
+ end
+end
diff --git a/spec/views/projects/show.html.erb_spec.rb b/spec/views/organizations/show.html.erb_spec.rb
similarity index 51%
rename from spec/views/projects/show.html.erb_spec.rb
rename to spec/views/organizations/show.html.erb_spec.rb
index 734f53245..89141f1fa 100644
--- a/spec/views/projects/show.html.erb_spec.rb
+++ b/spec/views/organizations/show.html.erb_spec.rb
@@ -1,18 +1,18 @@
require "rails_helper"
-RSpec.describe "projects/show", type: :view do
+RSpec.describe "organizations/show", type: :view do
let(:user) { create(:user) }
let(:admin) { create(:user, :admin) }
- let!(:project) { create(:project, name: "Project 1") }
+ let!(:organization) { create(:organization, name: "Organization 1") }
before do
- assign(:project, project)
+ assign(:organization, organization)
allow(view).to receive(:current_user).and_return(user)
render
end
it "renders attributes" do
- expect(rendered).to match(project.name)
+ expect(rendered).to match(organization.name)
end
end
diff --git a/spec/views/project_statuses/edit.html.erb_spec.rb b/spec/views/project_statuses/edit.html.erb_spec.rb
deleted file mode 100644
index bd170cfc8..000000000
--- a/spec/views/project_statuses/edit.html.erb_spec.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-require 'rails_helper'
-
-RSpec.describe "project_statuses/edit", type: :view do
- let(:admin) { create(:user, :admin) }
- let(:project_status) { create(:project_status) }
-
- before(:each) do
- sign_in admin
- assign(:project_status, project_status)
- end
-
- it "renders the edit project_status form" do
- render
-
- assert_select "form[action=?][method=?]", project_status_path(project_status), "post" do
- assert_select "input[name=?]", "project_status[name]"
- end
- end
-end
diff --git a/spec/views/project_statuses/index.html.erb_spec.rb b/spec/views/project_statuses/index.html.erb_spec.rb
deleted file mode 100644
index 5b08f3e94..000000000
--- a/spec/views/project_statuses/index.html.erb_spec.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-require 'rails_helper'
-
-RSpec.describe "project_statuses/index", type: :view do
- let(:admin) { create(:user, :admin) }
- let(:project_status1) { create(:project_status, name: "Active") }
- let(:project_status2) { create(:project_status, name: "Suspended") }
-
- before(:each) do
- assign(:project_statuses, paginated([ project_status1, project_status2 ]))
- allow(view).to receive(:current_user).and_return(admin)
- end
-
- it "renders a list of project_statuses" do
- render
- expect(rendered).to include(project_status1.name, project_status2.name)
- end
-
- it "renders a friendly message when no project_statuses exist" do
- assign(:project_statuses, paginated([]))
- render
- expect(rendered).to match(/No project statuses found/)
- end
-end
diff --git a/spec/views/project_statuses/new.html.erb_spec.rb b/spec/views/project_statuses/new.html.erb_spec.rb
deleted file mode 100644
index d8c52a904..000000000
--- a/spec/views/project_statuses/new.html.erb_spec.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-require 'rails_helper'
-
-RSpec.describe "project_statuses/new", type: :view do
- let(:admin) { create(:user, :admin) }
- let(:project_status) { build(:project_status) }
-
- before do
- allow(view).to receive(:current_user).and_return(admin)
- assign(:project_status, project_status)
- end
-
- it "renders new project_status form" do
- render
-
- assert_select "form[action=?]", project_statuses_path do
- assert_select "input[name=?]", "project_status[name]"
- end
- end
-end
diff --git a/spec/views/projects/edit.html.erb_spec.rb b/spec/views/projects/edit.html.erb_spec.rb
deleted file mode 100644
index 720c78192..000000000
--- a/spec/views/projects/edit.html.erb_spec.rb
+++ /dev/null
@@ -1,43 +0,0 @@
-require 'rails_helper'
-
-RSpec.describe "projects/edit", type: :view do
- let(:user) { create(:user) }
- let(:admin) { create(:user, :admin) }
-
- let(:project_status) { create(:project_status) }
- let(:windows_type) { create(:windows_type) }
-
- let(:project) {
- Project.create!(
- windows_type: windows_type,
- project_status: project_status,
- location: nil,
- name: "MyString",
- description: "MyString",
- inactive: false,
- notes: "MyText"
- )
- }
-
- before(:each) do
- assign(:project, project)
- allow(view).to receive(:current_user).and_return(admin)
- render
- end
-
- it "renders the edit project form" do
- assert_select "form[action=?][method=?]", project_path(project), "post" do
- assert_select "select[name=?]", "project[windows_type_id]"
-
- assert_select "textarea[name=?]", "project[name]"
-
- assert_select "textarea[name=?]", "project[description]"
-
- assert_select "select[name=?]", "project[project_status_id]"
-
- assert_select "input[name=?]", "project[inactive]"
-
- assert_select "textarea[name=?]", "project[notes]"
- end
- end
-end
diff --git a/spec/views/projects/index.html.erb_spec.rb b/spec/views/projects/index.html.erb_spec.rb
deleted file mode 100644
index 7c9ec23a9..000000000
--- a/spec/views/projects/index.html.erb_spec.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-require "rails_helper"
-
-RSpec.describe "projects/index", type: :view do
- let(:user) { create(:user) }
- let(:admin) { create(:user, :admin) }
-
- let!(:project1) { create(:project, name: "Project 1") }
- let!(:project2) { create(:project, name: "Project 2") }
-
- let!(:project_status1) { create(:project_status, name: "Active") }
- let!(:project_status2) { create(:project_status, name: "Suspended") }
- let!(:project_status3) { create(:project_status, name: "Inactive") }
-
- before(:each) do
- assign(:projects, paginated([ project1, project2 ]))
- assign(:project_statuses, [ project_status1, project_status2, project_status3 ])
- allow(view).to receive(:current_user).and_return(user)
- render
- end
-
- it "renders a list of projects" do
- expect(rendered).to match(project1.name)
- expect(rendered).to match(project2.name)
- end
-end
diff --git a/spec/views/projects/new.html.erb_spec.rb b/spec/views/projects/new.html.erb_spec.rb
deleted file mode 100644
index f9baf4ab8..000000000
--- a/spec/views/projects/new.html.erb_spec.rb
+++ /dev/null
@@ -1,28 +0,0 @@
-require 'rails_helper'
-
-RSpec.describe "projects/new", type: :view do
- let(:user) { create(:user) }
- let(:admin) { create(:user, :admin) }
-
- before do
- assign(:project, Project.new)
- allow(view).to receive(:current_user).and_return(admin)
- render
- end
-
- it "renders new project form" do
- assert_select "form[action=?][method=?]", projects_path, "post" do
- assert_select "select[name=?]", "project[windows_type_id]"
-
- assert_select "textarea[name=?]", "project[name]"
-
- assert_select "textarea[name=?]", "project[description]"
-
- assert_select "select[name=?]", "project[project_status_id]"
-
- assert_select "input[name=?]", "project[inactive]"
-
- assert_select "textarea[name=?]", "project[notes]"
- end
- end
-end
diff --git a/spec/views/stories/edit.html.erb_spec.rb b/spec/views/stories/edit.html.erb_spec.rb
index 89a44d935..858104b7f 100644
--- a/spec/views/stories/edit.html.erb_spec.rb
+++ b/spec/views/stories/edit.html.erb_spec.rb
@@ -8,7 +8,7 @@
assign(:story, story.decorate)
assign(:windows_types, [])
assign(:workshops, [])
- assign(:projects, [])
+ assign(:organizations, [])
assign(:users, [])
allow(view).to receive(:current_user).and_return(user)
end
@@ -19,7 +19,7 @@
assert_select "form[action=?][method=?]", story_path(story), "post" do
assert_select "select[name=?]", "story[windows_type_id]"
- assert_select "select[name=?]", "story[project_id]"
+ assert_select "select[name=?]", "story[organization_id]"
assert_select "select[name=?]", "story[workshop_id]"
diff --git a/spec/views/stories/new.html.erb_spec.rb b/spec/views/stories/new.html.erb_spec.rb
index b0b658b7c..efa081ce9 100644
--- a/spec/views/stories/new.html.erb_spec.rb
+++ b/spec/views/stories/new.html.erb_spec.rb
@@ -7,7 +7,7 @@
assign(:story, Story.new)
assign(:windows_types, [])
assign(:workshops, [])
- assign(:projects, [])
+ assign(:organizations, [])
assign(:users, [])
allow(view).to receive(:current_user).and_return(user)
end
@@ -18,7 +18,7 @@
assert_select "form[action=?][method=?]", stories_path, "post" do
assert_select "select[name=?]", "story[windows_type_id]"
- assert_select "select[name=?]", "story[project_id]"
+ assert_select "select[name=?]", "story[organization_id]"
assert_select "select[name=?]", "story[workshop_id]"
diff --git a/spec/views/stories/show.html.erb_spec.rb b/spec/views/stories/show.html.erb_spec.rb
index 51ea077bf..f32251cdb 100644
--- a/spec/views/stories/show.html.erb_spec.rb
+++ b/spec/views/stories/show.html.erb_spec.rb
@@ -13,7 +13,7 @@
it "renders attributes in
" do
render
- expect(rendered).to match(story.project.name)
+ expect(rendered).to match(story.organization.name)
expect(rendered).to match(story.workshop.name)
expect(rendered).to match(/MyBody/)
expect(rendered).to match(user.full_name)
diff --git a/spec/views/stories/show_with_story_idea.html.erb_spec.rb b/spec/views/stories/show_with_story_idea.html.erb_spec.rb
index ae0796130..a4389ae1d 100644
--- a/spec/views/stories/show_with_story_idea.html.erb_spec.rb
+++ b/spec/views/stories/show_with_story_idea.html.erb_spec.rb
@@ -15,7 +15,7 @@
it "renders attributes in
" do
render
- expect(rendered).to match(story_idea.project.name)
+ expect(rendered).to match(story_idea.organization.name)
expect(rendered).to match(story_idea.workshop.name)
expect(rendered).to match(/My Body/)
expect(rendered).to match(story_idea.created_by.full_name)
diff --git a/spec/views/story_ideas/edit.html.erb_spec.rb b/spec/views/story_ideas/edit.html.erb_spec.rb
index 8b5bb3c08..907cfc2f3 100644
--- a/spec/views/story_ideas/edit.html.erb_spec.rb
+++ b/spec/views/story_ideas/edit.html.erb_spec.rb
@@ -9,7 +9,7 @@
assign(:story_idea, story_idea)
assign(:windows_types, [])
assign(:workshops, [])
- assign(:projects, [])
+ assign(:organizations, [])
assign(:users, [])
allow(view).to receive(:current_user).and_return(user)
render
@@ -19,7 +19,7 @@
it "renders the edit story_idea form without created_by_id field" do
assert_select "form[action=?][method=?]", story_idea_path(story_idea), "post" do
assert_select "select[name=?]", "story_idea[windows_type_id]"
- assert_select "select[name=?]", "story_idea[project_id]"
+ assert_select "select[name=?]", "story_idea[organization_id]"
assert_select "select[name=?]", "story_idea[workshop_id]"
assert_select "textarea[name=?]", "story_idea[body]"
assert_select "textarea[name=?]", "story_idea[youtube_url]"
diff --git a/spec/views/story_ideas/new.html.erb_spec.rb b/spec/views/story_ideas/new.html.erb_spec.rb
index 329d84514..3fa7689d2 100644
--- a/spec/views/story_ideas/new.html.erb_spec.rb
+++ b/spec/views/story_ideas/new.html.erb_spec.rb
@@ -8,7 +8,7 @@
assign(:story_idea, StoryIdea.new)
assign(:windows_types, [])
assign(:workshops, [])
- assign(:projects, [])
+ assign(:organizations, [])
assign(:users, [])
end
@@ -22,7 +22,7 @@
assert_select "form[action=?][method=?]", story_ideas_path, "post" do
assert_select "select[name=?]", "story_idea[windows_type_id]"
- assert_select "select[name=?]", "story_idea[project_id]"
+ assert_select "select[name=?]", "story_idea[organization_id]"
assert_select "select[name=?]", "story_idea[workshop_id]"
assert_select "textarea[name=?]", "story_idea[body]"
assert_select "textarea[name=?]", "story_idea[youtube_url]"
diff --git a/spec/views/story_ideas/show.html.erb_spec.rb b/spec/views/story_ideas/show.html.erb_spec.rb
index 04acdb3c6..a7c54a600 100644
--- a/spec/views/story_ideas/show.html.erb_spec.rb
+++ b/spec/views/story_ideas/show.html.erb_spec.rb
@@ -10,7 +10,7 @@
it "renders attributes in
" do
render
- expect(rendered).to match(story_idea.project.name)
+ expect(rendered).to match(story_idea.organization.name)
expect(rendered).to match(story_idea.workshop.name)
expect(rendered).to match(/MyBody/)
expect(rendered).to match(user.full_name)
diff --git a/spec/views/users/show.html.erb_spec.rb b/spec/views/users/show.html.erb_spec.rb
index 6b4685ef6..610c3dae8 100644
--- a/spec/views/users/show.html.erb_spec.rb
+++ b/spec/views/users/show.html.erb_spec.rb
@@ -1,37 +1,96 @@
-require 'rails_helper'
+require "rails_helper"
RSpec.describe "users/show", type: :view do
let(:user) do
- create(:user,
- email: "Email@example.com",
- comment: "MyText",
- notes: "MyText")
+ create(
+ :user,
+ name: "Jane Artist",
+ email: "Email@example.com",
+ phone: "555-1234",
+ super_user: false,
+ sign_in_count: 3,
+ current_sign_in_at: 1.day.ago,
+ last_sign_in_at: 2.days.ago
+ )
end
- let(:admin) { create(:user, :admin) }
- let(:windows_type) { create(:windows_type, name: "Adult Windows") }
- let!(:workshop) { create(:workshop, title: "Mindful Art", user: user, windows_type: windows_type) }
-
- let!(:project) { create(:project, name: "Healing Arts") }
- let!(:project_user) { create(:project_user, project: project, title: "Title", user: user, position: :leader) }
-
before do
assign(:user, user)
- allow(view).to receive(:current_user).and_return(admin)
end
- it "renders facilitator attributes" do
- render
- expect(rendered).to include("email@example.com")
+ # --------------------------------------------------
+ # ADMIN VIEW
+ # --------------------------------------------------
+ context "when current user is a super user" do
+ let(:admin) { create(:user, :admin) }
+
+ before do
+ allow(view).to receive(:current_user).and_return(admin)
+ render
+ end
+
+ it "shows navigation buttons" do
+ expect(rendered).to have_link("Users", href: users_path)
+ expect(rendered).to have_link("Edit", href: edit_user_path(user))
+ end
+
+ it "renders identity info" do
+ expect(rendered).to include("Jane Artist")
+ expect(rendered).to include("Email@example.com")
+ expect(rendered).to include("555-1234")
+ end
+
+ it "renders account status section" do
+ expect(rendered).to include("Account status")
+ expect(rendered).to include("Active")
+ expect(rendered).to include("Super user")
+ end
+
+ it "renders authentication data when available" do
+ expect(rendered).to include("Sign-in count")
+ expect(rendered).to include("3")
+
+ expect(rendered).to include("Current sign-in")
+ expect(rendered).to include(I18n.l(user.current_sign_in_at, format: :long))
+ end
+
+ it "renders audit timestamps" do
+ expect(rendered).to include("Created at")
+ expect(rendered).to include(I18n.l(user.updated_at, format: :long))
+ end
end
- it "renders devise data" do
- render
- expect(rendered).to include("Current sign-in")
+ # --------------------------------------------------
+ # NON-ADMIN VIEW
+ # --------------------------------------------------
+ context "when current user is not a super user" do
+ let(:regular_user) { create(:user) }
+
+ before do
+ allow(view).to receive(:current_user).and_return(regular_user)
+ render
+ end
+
+ it "does not show admin buttons" do
+ expect(rendered).not_to have_link("Users")
+ expect(rendered).not_to have_link("Edit")
+ end
end
- it "renders audit data" do
- render
- expect(rendered).to include(I18n.l(user.updated_at, format: :long))
+ # --------------------------------------------------
+ # FACILITATOR ASSOCIATION
+ # --------------------------------------------------
+ context "when user has no facilitator" do
+ let(:admin) { create(:user, :admin) }
+
+ before do
+ allow(view).to receive(:current_user).and_return(admin)
+ render
+ end
+
+ it "shows facilitator creation prompt" do
+ expect(rendered).to include("Not associated with a facilitator")
+ expect(rendered).to have_link("Create facilitator")
+ end
end
end
From cacbfebc2ffb3d8a08a1b7bdfe572f8f21f7f983 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Tue, 20 Jan 2026 01:19:20 +0000
Subject: [PATCH 05/10] Changes before error encountered
Co-authored-by: maebeale <7607813+maebeale@users.noreply.github.com>
---
app/controllers/monthly_reports_controller.rb | 18 +++++++-------
app/controllers/reports_controller.rb | 12 +++++-----
app/controllers/workshop_logs_controller.rb | 24 +++++++++----------
app/models/user.rb | 12 +++++-----
4 files changed, 33 insertions(+), 33 deletions(-)
diff --git a/app/controllers/monthly_reports_controller.rb b/app/controllers/monthly_reports_controller.rb
index 1aff7c7e2..aed686694 100644
--- a/app/controllers/monthly_reports_controller.rb
+++ b/app/controllers/monthly_reports_controller.rb
@@ -38,7 +38,7 @@ def create
@form_builder = FormBuilder.find(@report.owner_id)
build_month_and_year
load_agencies
- @agency_id = report_params["project_id"]
+ @agency_id = report_params["organization_id"]
flash[:alert] = "There was a problem submitting your form: " +
"#{@report.errors.full_messages.join(" ")}"
@@ -61,7 +61,7 @@ def edit
build_month_and_year
find_form_builder
@report = Report.find(params[:id])
- @agencies = current_user.projects.
+ @agencies = current_user.organizations.
where(windows_type_id: @report.windows_type_id)
@month = @report.date.month
@year = @report.date.year
@@ -85,7 +85,7 @@ def update
flash[:notice] = "Thanks for reporting on a update report. "
redirect_to root_path
else
- @agencies = current_user.projects.
+ @agencies = current_user.organizations.
where(windows_type_id: @report.windows_type_id)
flash[:alert] = "ERROR!!!!!!!!!!!!!!"
@@ -102,7 +102,7 @@ def show
@answers = @monthly_report.report_form_field_answers
if @monthly_report
- if current_user.super_user? || (@monthly_report.project && current_user.project_ids.include?(@monthly_report.project.id))
+ if current_user.super_user? || (@monthly_report.organization && current_user.organization_ids.include?(@monthly_report.organization.id))
render :show
else
redirect_to root_path, error: "You do not have permission to view this page."
@@ -116,7 +116,7 @@ def show
private
def load_agencies
- @agencies = current_user.projects.
+ @agencies = current_user.organizations.
where(windows_type_id: @form_builder.windows_type_id).uniq
end
@@ -143,7 +143,7 @@ def find_form_builder
.decorate
end
- agency = params[:agency_id] ? Project.find(params[:agency_id]) : current_user.projects.where(windows_type_id: @form_builder.windows_type).first
+ agency = params[:agency_id] ? Organization.find(params[:agency_id]) : current_user.organizations.where(windows_type_id: @form_builder.windows_type).first
@agency_id = agency.id unless agency.nil?
end
@@ -196,7 +196,7 @@ def build_report_form_fields
end
def find_workshop_logs
- @workshop_logs = current_user.project_monthly_workshop_logs(
+ @workshop_logs = current_user.organization_monthly_workshop_logs(
@report.date, @report.windows_type
)
@@ -207,7 +207,7 @@ def find_workshop_logs
def find_combined_workshop_logs(agency_id)
combined_windows_type = WindowsType.where(short_name: "COMBINED").first
- @combined_workshop_logs = current_user.project_workshop_logs(
+ @combined_workshop_logs = current_user.organization_workshop_logs(
@report.date, combined_windows_type, agency_id)
end
@@ -225,7 +225,7 @@ def report_params
end
params.require(:report).permit(
- :type, :project_id, :date, :owner_id, :workshop_id,
+ :type, :organization_id, :date, :owner_id, :workshop_id,
:owner_type, :windows_type_id, :other_description,
media_files_attributes: [ :file ],
report_form_field_answers_attributes:
diff --git a/app/controllers/reports_controller.rb b/app/controllers/reports_controller.rb
index 0e75dac83..1490ed1b1 100644
--- a/app/controllers/reports_controller.rb
+++ b/app/controllers/reports_controller.rb
@@ -27,7 +27,7 @@ def share_story
@report.owner_type = "FormBuilder"
@report.owner_id = 7
- @agencies = current_user.projects
+ @agencies = current_user.organizations
end
def render_form
@@ -46,7 +46,7 @@ def edit
build_month_and_year
find_form_builder
@report = current_user.submitted_monthly_report(@date, @form_builder.windows_type)
- @agencies = current_user.projects.
+ @agencies = current_user.organizations.
where(windows_type_id: @report.windows_type_id)
@month = @report.date.month
@year = @report.date.year
@@ -60,7 +60,7 @@ def edit_story
.order(title: :asc)
@report = Report.find(params[:id])
- @agencies = current_user.projects.
+ @agencies = current_user.organizations.
where(windows_type_id: @report.windows_type_id)
end
@@ -159,7 +159,7 @@ def create_story
@report.windows_type_id = Workshop.find(@report.workshop_id).windows_type_id
else
@report.workshop_id = nil
- @report.windows_type_id = @report.project.windows_type_id
+ @report.windows_type_id = @report.organization.windows_type_id
end
if @report.save
@@ -233,7 +233,7 @@ def build_report_form_fields
end
def find_workshop_logs
- @workshop_logs = current_user.project_monthly_workshop_logs(
+ @workshop_logs = current_user.organization_monthly_workshop_logs(
@report.date, @report.windows_type
)
@@ -256,7 +256,7 @@ def report_params
end
params.require(:report).permit(
- :image, :form_file, :type, :project_id, :date, :workshop_name, :owner_id, :workshop_id,
+ :image, :form_file, :type, :organization_id, :date, :workshop_name, :owner_id, :workshop_id,
:owner_type, :windows_type_id, report_form_field_answers_attributes:
[ :form_field_id, :answer_option_id, :answer, :_create ],
media_files_attributes: [ :file ],
diff --git a/app/controllers/workshop_logs_controller.rb b/app/controllers/workshop_logs_controller.rb
index 888ac75d2..c4be57d8c 100644
--- a/app/controllers/workshop_logs_controller.rb
+++ b/app/controllers/workshop_logs_controller.rb
@@ -9,7 +9,7 @@ def index
WorkshopLog.all
else
WorkshopLog.where(created_by_id: current_user.id)
- .or(WorkshopLog.project_id(current_user.project_ids))
+ .or(WorkshopLog.organization_id(current_user.organization_ids))
end
@workshop_logs_unpaginated = permitted_logs.includes(:workshop, :user, :windows_type)
.search(params)
@@ -83,7 +83,7 @@ def show
@answers = @workshop_log.report_form_field_answers
if @workshop_log
- if current_user.super_user? || (@workshop_log.project && current_user.project_ids.include?(@workshop_log.project.id))
+ if current_user.super_user? || (@workshop_log.organization && current_user.organization_ids.include?(@workshop_log.organization.id))
render :show
else
redirect_to root_path, error: "You do not have permission to view this page."
@@ -104,7 +104,7 @@ def edit
def validate_new
@date = Date.new(params[:year].to_i, params[:month].to_i)
@windows_type = WindowsType.find(params[:windows_type])
- @report = current_user.submitted_monthly_report(@date, @windows_type, params[:project_id])
+ @report = current_user.submitted_monthly_report(@date, @windows_type, params[:organization_id])
render json: { validate: @report.nil? }.to_json
end
@@ -125,10 +125,10 @@ def set_index_variables # needs to not be private
.distinct
.order(:last_name, :first_name)
@projects = if current_user.super_user?
- # Project.where(id: @workshop_logs_unpaginated.pluck(:project_id)).order(:name)
- Project.active.order(:name)
+ # Organization.where(id: @workshop_logs_unpaginated.pluck(:organization_id)).order(:name)
+ Organization.active.order(:name)
else
- current_user.projects.order(:name)
+ current_user.organizations.order(:name)
end
@workshops = Workshop.where(id: @workshop_logs_unpaginated.select(:workshop_id).distinct)
.order(:title)
@@ -182,11 +182,11 @@ def set_form_variables
end
@agencies =
- Project.where(id: current_user.projects.select(:id))
- .or(Project.where(id: @workshop_log.project_id))
- .distinct
- .order(:name)
- agency = params[:agency_id].present? ? Project.where(id: params[:agency_id]).last : @agencies.first
+ Organization.where(id: current_user.organizations.select(:id))
+ .or(Organization.where(id: @workshop_log.organization_id))
+ .distinct
+ .order(:name)
+ agency = params[:agency_id].present? ? Organization.where(id: params[:agency_id]).last : @agencies.first
@agency_id = agency.id if agency
end
@@ -210,7 +210,7 @@ def set_workshop
def workshop_log_params
params.require(:workshop_log).permit(
:children_ongoing, :children_first_time, :teens_ongoing, :teens_first_time,
- :adults_ongoing, :adults_first_time, :owner_id, :owner_type, :user_id, :project_id, :date,
+ :adults_ongoing, :adults_first_time, :owner_id, :owner_type, :user_id, :organization_id, :date,
:workshop_name, :workshop_id, :windows_type_id, :other_description, # :user,
quotable_item_quotes_attributes: [
:id, :quotable_type, :quotable_id, :_destroy,
diff --git a/app/models/user.rb b/app/models/user.rb
index 669c18e28..ba269ca88 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -123,11 +123,11 @@ def recent_activity(activity_limit = 10)
recent.sort_by { |item| item.try(:updated_at) || item.created_at }.reverse.first(activity_limit * 8)
end
- def project_monthly_workshop_logs(date, *windows_type)
+ def organization_monthly_workshop_logs(date, *windows_type)
where = windows_type.map { |wt| "windows_type_id = ?" }
- logs = projects.map do |project|
- project.workshop_logs.where(where.join(" OR "), *windows_type)
+ logs = organizations.map do |organization|
+ organization.workshop_logs.where(where.join(" OR "), *windows_type)
end.flatten
logs = logs.select do |log|
log.date && log.date.month == date.month.to_i &&
@@ -136,9 +136,9 @@ def project_monthly_workshop_logs(date, *windows_type)
logs.uniq.group_by { |log| log.date }
end
- def project_workshop_logs(date, windows_type, project_id)
- if project_id
- logs = workshop_logs.where(project_id: project_id, windows_type_id: windows_type.id)
+ def organization_workshop_logs(date, windows_type, organization_id)
+ if organization_id
+ logs = workshop_logs.where(organization_id: organization_id, windows_type_id: windows_type.id)
logs = logs.select do |log|
log.date && log.date.month == date.month.to_i &&
log.date.year == date.year.to_i
From 4f97d72c00201a345aaef2137f3478dc2c1f14f0 Mon Sep 17 00:00:00 2001
From: maebeale
Date: Tue, 3 Feb 2026 21:03:30 -0500
Subject: [PATCH 06/10] More conversion of project -> organization
---
app/controllers/admin/analytics_controller.rb | 10 +++++-----
app/controllers/community_news_controller.rb | 6 +++---
app/controllers/facilitators_controller.rb | 2 +-
app/controllers/reports_controller.rb | 4 ++--
app/controllers/stories_controller.rb | 8 ++++----
app/controllers/story_ideas_controller.rb | 6 +++---
app/controllers/taggings_controller.rb | 2 +-
.../workshop_log_creation_wizard_controller.rb | 6 +++---
app/controllers/workshop_logs_controller.rb | 2 +-
app/controllers/workshops_controller.rb | 4 ++--
app/decorators/facilitator_decorator.rb | 2 +-
app/decorators/workshop_decorator.rb | 2 +-
app/decorators/workshop_idea_decorator.rb | 2 +-
app/helpers/admin_cards_helper.rb | 2 +-
app/models/bookmark.rb | 10 +++++-----
app/models/facilitator.rb | 10 +++++-----
app/models/organization.rb | 2 +-
app/models/report.rb | 4 ++--
app/models/story.rb | 6 +++---
app/models/tag.rb | 6 +++---
app/models/user.rb | 6 +++---
app/services/facilitator_from_user_service.rb | 4 ++--
app/services/tagging_search_service.rb | 4 ++--
app/views/admin/analytics/index.html.erb | 4 ++--
.../community_news/_community_news_results.html.erb | 2 +-
app/views/community_news/_form.html.erb | 4 ++--
app/views/community_news/_results_skeleton.html.erb | 2 +-
app/views/community_news/show.html.erb | 2 +-
app/views/facilitators/_search_boxes.html.erb | 6 +++---
app/views/facilitators/index.html.erb | 8 ++++----
app/views/facilitators/show.html.erb | 6 +++---
app/views/monthly_reports/_form.html.erb | 4 ++--
app/views/monthly_reports/edit.html.erb | 8 ++++----
app/views/monthly_reports/new.html.erb | 2 +-
app/views/monthly_reports/show.html.erb | 2 +-
app/views/reports/_form.html.erb | 4 ++--
app/views/reports/edit.html.erb | 4 ++--
app/views/reports/edit_story.html.erb | 4 ++--
app/views/reports/fill_out_form.html.erb | 2 +-
app/views/reports/new.html.erb | 2 +-
app/views/reports/share_story.html.erb | 2 +-
app/views/reports/show.html.erb | 2 +-
app/views/shared/_navbar_menu.html.erb | 2 +-
app/views/shared/_navbar_menu_mobile.html.erb | 2 +-
app/views/shared/_navbar_user.html.erb | 8 ++++----
app/views/stories/_form.html.erb | 8 ++++----
app/views/stories/_results_skeleton.html.erb | 2 +-
app/views/stories/_story_results.html.erb | 2 +-
app/views/stories/show.html.erb | 2 +-
app/views/story_ideas/_form.html.erb | 6 +++---
app/views/story_ideas/index.html.erb | 4 ++--
.../_workshop_log_fields.html.erb | 2 +-
app/views/workshop_logs/_form.html.erb | 6 +++---
app/views/workshop_logs/_index.html.erb | 2 +-
app/views/workshop_logs/_search_boxes.html.erb | 6 +++---
app/views/workshop_logs/new_old.html.erb | 12 ++++++------
app/views/workshop_logs/show.html.erb | 2 +-
57 files changed, 123 insertions(+), 123 deletions(-)
diff --git a/app/controllers/admin/analytics_controller.rb b/app/controllers/admin/analytics_controller.rb
index 4ab57c745..1e02d86d5 100644
--- a/app/controllers/admin/analytics_controller.rb
+++ b/app/controllers/admin/analytics_controller.rb
@@ -14,7 +14,7 @@ def index
@most_viewed_stories = decorate_with_counts(most_viewed_for_model(Story, time_scope), :view_count)
@most_viewed_quotes = decorate_with_counts(most_viewed_for_model(Quote, time_scope), :view_count)
@most_viewed_tutorials = decorate_with_counts(most_viewed_for_model(Tutorial, time_scope), :view_count)
- @most_viewed_projects = decorate_with_counts(most_viewed_for_model(Project, time_scope), :view_count)
+ @most_viewed_organizations = decorate_with_counts(most_viewed_for_model(Organization, time_scope), :view_count)
@most_viewed_events = decorate_with_counts(most_viewed_for_model(Event, time_scope), :view_count)
@most_viewed_facilitators = decorate_with_counts(most_viewed_for_model(Facilitator, time_scope), :view_count)
@@ -25,7 +25,7 @@ def index
# @most_printed_workshop_variations = decorate_with_counts(most_printed_for_model(WorkshopVariation, time_scope), :print_count)
# @most_printed_quotes = decorate_with_counts(most_printed_for_model(Quote, time_scope), :print_count)
# @most_printed_tutorials = decorate_with_counts(most_printed_for_model(Tutorial, time_scope), :print_count)
- # @most_printed_projects = decorate_with_counts(most_printed_for_model(Project, time_scope), :print_count)
+ # @most_printed_organizations = decorate_with_counts(most_printed_for_model(Organization, time_scope), :print_count)
# @most_printed_events = decorate_with_counts(most_printed_for_model(Event, time_scope), :print_count)
@most_downloaded_resources = decorate_with_counts(most_downloaded_for_model(Resource, time_scope), :download_count)
@@ -67,9 +67,9 @@ def index
views: view_count_for_model(Tutorial, time_scope),
prints: print_count_for_model(Tutorial, time_scope)
},
- projects: {
- views: view_count_for_model(Project, time_scope),
- prints: print_count_for_model(Project, time_scope)
+ organizations: {
+ views: view_count_for_model(Organization, time_scope),
+ prints: print_count_for_model(Organization, time_scope)
},
facilitators: {
views: view_count_for_model(Facilitator, time_scope)
diff --git a/app/controllers/community_news_controller.rb b/app/controllers/community_news_controller.rb
index 759b53138..e900d51e4 100644
--- a/app/controllers/community_news_controller.rb
+++ b/app/controllers/community_news_controller.rb
@@ -7,7 +7,7 @@ def index
per_page = params[:number_of_items_per_page].presence || 12
unfiltered = current_user.super_user? ? CommunityNews.all : CommunityNews.published
filtered = unfiltered.search_by_params(params)
- @community_news = filtered&.includes([ :bookmarks, :primary_asset, :author, :project, author: :facilitator ])
+ @community_news = filtered&.includes([ :bookmarks, :primary_asset, :author, :organization, author: :facilitator ])
&.paginate(page: params[:page], per_page: per_page)&.decorate
@count_display = if filtered.count == unfiltered.count
@@ -79,7 +79,7 @@ def destroy
# Optional hooks for setting variables for forms or index
def set_form_variables
- @organizations = Project.pluck(:name, :id).sort_by(&:first)
+ @organizations = Organization.pluck(:name, :id).sort_by(&:first)
@authors = User.active.or(User.where(id: @community_news.author_id))
.map { |u| [ u.full_name, u.id ] }.sort_by(&:first)
end
@@ -95,7 +95,7 @@ def community_news_params
params.require(:community_news).permit(
:title, :rhino_body, :published, :featured, :public, :public_featured,
:reference_url, :youtube_url,
- :project_id,
+ :organization_id,
:author_id, :created_by_id, :updated_by_id
)
end
diff --git a/app/controllers/facilitators_controller.rb b/app/controllers/facilitators_controller.rb
index 72c8e4594..7da35082b 100644
--- a/app/controllers/facilitators_controller.rb
+++ b/app/controllers/facilitators_controller.rb
@@ -7,7 +7,7 @@ def index
facilitators = Facilitator
.searchable
.search_by_params(params.to_unsafe_h)
- .includes(:user, :avatar_attachment, :sectorable_items, user: [ :avatar_attachment, :projects ]).references(:user)
+ .includes(:user, :avatar_attachment, :sectorable_items, user: [ :avatar_attachment, :organizations ]).references(:user)
.order(:first_name, :last_name)
@count_display = facilitators.size
@facilitators = facilitators.paginate(page: params[:page], per_page: per_page)
diff --git a/app/controllers/reports_controller.rb b/app/controllers/reports_controller.rb
index 1490ed1b1..b52fcc83e 100644
--- a/app/controllers/reports_controller.rb
+++ b/app/controllers/reports_controller.rb
@@ -79,7 +79,7 @@ def update_story
flash[:notice] = "Thanks for reporting on a update report. "
redirect_to root_path
else
- @agencies = current_user.projects.
+ @agencies = current_user.organizations.
where(windows_type_id: @report.windows_type_id)
flash[:alert] = "ERROR!!!!!!!!!!!!!!"
@@ -105,7 +105,7 @@ def update
flash[:notice] = "Thanks for reporting on a update report. "
redirect_to root_path
else
- @agencies = current_user.projects.
+ @agencies = current_user.organizations.
where(windows_type_id: @report.windows_type_id)
flash[:alert] = "ERROR!!!!!!!!!!!!!!"
diff --git a/app/controllers/stories_controller.rb b/app/controllers/stories_controller.rb
index 63ca6e7ca..5f7042106 100644
--- a/app/controllers/stories_controller.rb
+++ b/app/controllers/stories_controller.rb
@@ -6,7 +6,7 @@ def index
if turbo_frame_request?
per_page = params[:number_of_items_per_page].presence || 12
unpaginated = current_user.super_user? ? Story.all : Story.published
- filtered = unpaginated.includes(:windows_type, :project, :workshop, :created_by, :bookmarks, :primary_asset)
+ filtered = unpaginated.includes(:windows_type, :organization, :workshop, :created_by, :bookmarks, :primary_asset)
.search_by_params(params)
.order(created_at: :desc)
@stories = filtered.paginate(page: params[:page], per_page: per_page).decorate
@@ -90,7 +90,7 @@ def destroy
def set_form_variables
@story_idea = StoryIdea.find(params[:story_idea_id]) if params[:story_idea_id].present?
@user = User.find(params[:user_id]) if params[:user_id].present?
- @projects = (@user || current_user).projects.order(:name)
+ @organizations = (@user || current_user).organizations.order(:name)
@story_ideas = StoryIdea.includes(:created_by)
.references(:users)
.order(:created_at)
@@ -111,7 +111,7 @@ def set_story
def story_params
params.require(:story).permit(
:title, :rhino_body, :featured, :published, :public, :public_featued, :youtube_url, :website_url,
- :windows_type_id, :project_id, :workshop_id, :external_workshop_title,
+ :windows_type_id, :organization_id, :workshop_id, :external_workshop_title,
:created_by_id, :updated_by_id, :story_idea_id, :spotlighted_facilitator_id
)
end
@@ -119,7 +119,7 @@ def story_params
def set_story_attributes_from(idea)
{
rhino_body: idea.body,
- project_id: idea.project.id,
+ organization_id: idea.organization.id,
workshop_id: idea.workshop_id,
external_workshop_title: idea.external_workshop_title,
windows_type_id: idea.windows_type_id,
diff --git a/app/controllers/story_ideas_controller.rb b/app/controllers/story_ideas_controller.rb
index ff58bfa9e..77dc75824 100644
--- a/app/controllers/story_ideas_controller.rb
+++ b/app/controllers/story_ideas_controller.rb
@@ -6,7 +6,7 @@ def index
per_page = params[:number_of_items_per_page].presence || 25
- story_ideas = StoryIdea.includes(:windows_type, :project, :workshop, :created_by, :updated_by)
+ story_ideas = StoryIdea.includes(:windows_type, :organization, :workshop, :created_by, :updated_by)
@story_ideas = story_ideas.order(created_at: :desc)
.paginate(page: params[:page], per_page: per_page).decorate
@@ -64,7 +64,7 @@ def destroy
# Optional hooks for setting variables for forms or index
def set_form_variables
@user = User.find(params[:user_id]) if params[:user_id].present?
- @projects = (@user || current_user).projects.order(:name)
+ @organizations = (@user || current_user).organizations.order(:name)
@windows_types = WindowsType.all
@workshops = Workshop.all.order(:title)
@users = User.active.or(User.where(id: @story_idea.created_by_id))
@@ -82,7 +82,7 @@ def story_idea_params
params.require(:story_idea).permit(
:title, :body, :youtube_url,
:permission_given, :publish_preferences, :promoted_to_story,
- :windows_type_id, :project_id, :workshop_id, :external_workshop_title,
+ :windows_type_id, :organization_id, :workshop_id, :external_workshop_title,
:created_by_id, :updated_by_id,
)
end
diff --git a/app/controllers/taggings_controller.rb b/app/controllers/taggings_controller.rb
index c5c192d79..6252eb5f0 100644
--- a/app/controllers/taggings_controller.rb
+++ b/app/controllers/taggings_controller.rb
@@ -13,7 +13,7 @@ def index
community_news: params[:community_news_page],
events: params[:events_page],
facilitators: params[:facilitators_page],
- projects: params[:projects_page],
+ organizations: params[:organizations_page],
quotes: params[:quotes_page]
}
diff --git a/app/controllers/workshop_log_creation_wizard_controller.rb b/app/controllers/workshop_log_creation_wizard_controller.rb
index b07a34106..bd8980769 100644
--- a/app/controllers/workshop_log_creation_wizard_controller.rb
+++ b/app/controllers/workshop_log_creation_wizard_controller.rb
@@ -6,7 +6,7 @@ class WorkshopLogCreationWizardController < ApplicationController
def show
@user = current_user
- @agencies = current_user.projects
+ @agencies = current_user.organizations
windows_type_id = params[:windows_type_id] || WindowsType.where(short_name: "COMBINED")
@windows_type = WindowsType.find(windows_type_id) if windows_type_id
send(step)
@@ -15,7 +15,7 @@ def show
def update
@user = current_user
- @agencies = current_user.projects
+ @agencies = current_user.organizations
windows_type_id = params["workshop"]["workshop_logs_attributes"].values[0]["windows_type_id"]
@windows_type = WindowsType.find(windows_type_id)
send("update_#{step}")
@@ -155,7 +155,7 @@ def workshop_params
:title, :date, :windows_type_id,
workshop_logs_attributes: [ :user_id, :rating, :reaction, :similarities, :is_embodied_art_workshop,
:successes, :challenges, :differences, :date,
- :suggestions, :questions, :lead_similar, :project_id,
+ :suggestions, :questions, :lead_similar, :organization_id,
:num_participants_on_going, :num_participants_first_time,
report_form_field_answers_attributes:
[ :form_field_id, :answer_option_id, :answer, :_create ]
diff --git a/app/controllers/workshop_logs_controller.rb b/app/controllers/workshop_logs_controller.rb
index c4be57d8c..bef8e0228 100644
--- a/app/controllers/workshop_logs_controller.rb
+++ b/app/controllers/workshop_logs_controller.rb
@@ -124,7 +124,7 @@ def set_index_variables # needs to not be private
.joins(:workshop_logs)
.distinct
.order(:last_name, :first_name)
- @projects = if current_user.super_user?
+ @organizations = if current_user.super_user?
# Organization.where(id: @workshop_logs_unpaginated.pluck(:organization_id)).order(:name)
Organization.active.order(:name)
else
diff --git a/app/controllers/workshops_controller.rb b/app/controllers/workshops_controller.rb
index 6b4bd05c9..6953dbcff 100644
--- a/app/controllers/workshops_controller.rb
+++ b/app/controllers/workshops_controller.rb
@@ -34,7 +34,7 @@ def summary
types = reports.map do |r|
r.windows_type
end
- @workshop_logs = current_user.project_monthly_workshop_logs(
+ @workshop_logs = current_user.organization_monthly_workshop_logs(
reports.first.date, *types,
)
@@ -43,7 +43,7 @@ def summary
@total_first_time = logs.reduce(0) { |sum, l| sum += l.num_first_time }
combined_windows_type = WindowsType.where(short_name: "COMBINED").first
- @combined_workshop_logs = current_user.project_workshop_logs(
+ @combined_workshop_logs = current_user.organization_workshop_logs(
@report.date, combined_windows_type, current_user.agency_id
)
end
diff --git a/app/decorators/facilitator_decorator.rb b/app/decorators/facilitator_decorator.rb
index c0fb138b6..8ddbbabfb 100644
--- a/app/decorators/facilitator_decorator.rb
+++ b/app/decorators/facilitator_decorator.rb
@@ -4,7 +4,7 @@ def title
end
def detail(length: nil)
- text = user.project_users.active.map { |pu| "#{pu.title.presence || pu.position}, #{pu.project.name}" }.join(", ") if user
+ text = user.organization_users.active.map { |pu| "#{pu.title.presence || pu.position}, #{pu.organization.name}" }.join(", ") if user
length ? text&.truncate(length) : text
end
diff --git a/app/decorators/workshop_decorator.rb b/app/decorators/workshop_decorator.rb
index e04655de4..9d91fb57b 100644
--- a/app/decorators/workshop_decorator.rb
+++ b/app/decorators/workshop_decorator.rb
@@ -143,7 +143,7 @@ def labels_spanish
creation_spanish: "Creación",
closing_spanish: "Clausura",
misc_instructions_spanish: "Instrucciones de misceláneos",
- project_spanish: "Projecto",
+ organization_spanish: "Organización",
description_spanish: "Descripción",
notes_spanish: "Notas",
tips_spanish: "Consejos",
diff --git a/app/decorators/workshop_idea_decorator.rb b/app/decorators/workshop_idea_decorator.rb
index 1a9d09081..477d7fd89 100644
--- a/app/decorators/workshop_idea_decorator.rb
+++ b/app/decorators/workshop_idea_decorator.rb
@@ -33,7 +33,7 @@ def labels_spanish
creation_spanish: "Creación",
closing_spanish: "Clausura",
misc_instructions_spanish: "Instrucciones de misceláneos",
- project_spanish: "Projecto",
+ organization_spanish: "Organización",
description_spanish: "Descripción",
notes_spanish: "Notas",
tips_spanish: "Consejos"
diff --git a/app/helpers/admin_cards_helper.rb b/app/helpers/admin_cards_helper.rb
index aa91949e0..74584ff6a 100644
--- a/app/helpers/admin_cards_helper.rb
+++ b/app/helpers/admin_cards_helper.rb
@@ -50,7 +50,7 @@ def reference_cards
intensity: 100,
title: "Service populations",
params: { published_search: true }),
- custom_card("Project statuses", project_statuses_path, icon: "🧮", color: :emerald, intensity: 100),
+ custom_card("Organization statuses", project_statuses_path, icon: "🧮", color: :emerald, intensity: 100),
custom_card("Windows types", windows_types_path, icon: "🪟")
]
end
diff --git a/app/models/bookmark.rb b/app/models/bookmark.rb
index 80e6ee0bf..9bca85ad3 100644
--- a/app/models/bookmark.rb
+++ b/app/models/bookmark.rb
@@ -2,7 +2,7 @@ class Bookmark < ApplicationRecord
belongs_to :user
belongs_to :bookmarkable, polymorphic: true
- BOOKMARKABLE_MODELS = [ "CommunityNews", "Event", "Facilitator", "Project", "Resource", "Story", "StoryIdea",
+ BOOKMARKABLE_MODELS = [ "CommunityNews", "Event", "Facilitator", "Organization", "Resource", "Story", "StoryIdea",
"Workshop", "WorkshopIdea", "WorkshopLog", "WorkshopVariation" ]
scope :for_workshops, -> { where(bookmarkable_type: "Workshop") }
@@ -55,7 +55,7 @@ def self.sort_by_title
LEFT JOIN community_news ON community_news.id = bookmarks.bookmarkable_id AND bookmarks.bookmarkable_type = 'CommunityNews'
LEFT JOIN events ON events.id = bookmarks.bookmarkable_id AND bookmarks.bookmarkable_type = 'Event'
LEFT JOIN facilitators ON facilitators.id = bookmarks.bookmarkable_id AND bookmarks.bookmarkable_type = 'Facilitator'
- LEFT JOIN projects ON projects.id = bookmarks.bookmarkable_id AND bookmarks.bookmarkable_type = 'Project'
+ LEFT JOIN organizations ON organizations.id = bookmarks.bookmarkable_id AND bookmarks.bookmarkable_type = 'Organization'
LEFT JOIN resources ON resources.id = bookmarks.bookmarkable_id AND bookmarks.bookmarkable_type = 'Resource'
LEFT JOIN stories ON stories.id = bookmarks.bookmarkable_id AND bookmarks.bookmarkable_type = 'Story'
LEFT JOIN story_ideas ON story_ideas.id = bookmarks.bookmarkable_id AND bookmarks.bookmarkable_type = 'StoryIdea'
@@ -70,7 +70,7 @@ def self.sort_by_title
community_news.title,
events.title,
CONCAT(facilitators.first_name, ' ', facilitators.last_name),
- projects.name,
+ organizations.name,
resources.title,
stories.title,
story_ideas.title,
@@ -93,7 +93,7 @@ def self.title(title)
LEFT JOIN community_news ON community_news.id = bookmarks.bookmarkable_id AND bookmarks.bookmarkable_type = 'CommunityNews'
LEFT JOIN events ON events.id = bookmarks.bookmarkable_id AND bookmarks.bookmarkable_type = 'Event'
LEFT JOIN facilitators ON facilitators.id = bookmarks.bookmarkable_id AND bookmarks.bookmarkable_type = 'Facilitator'
- LEFT JOIN projects ON projects.id = bookmarks.bookmarkable_id AND bookmarks.bookmarkable_type = 'Project'
+ LEFT JOIN organizations ON organizations.id = bookmarks.bookmarkable_id AND bookmarks.bookmarkable_type = 'Organization'
LEFT JOIN resources ON resources.id = bookmarks.bookmarkable_id AND bookmarks.bookmarkable_type = 'Resource'
LEFT JOIN stories ON stories.id = bookmarks.bookmarkable_id AND bookmarks.bookmarkable_type = 'Story'
LEFT JOIN story_ideas ON story_ideas.id = bookmarks.bookmarkable_id AND bookmarks.bookmarkable_type = 'StoryIdea'
@@ -105,7 +105,7 @@ def self.title(title)
bookmarks.where(
"community_news.title LIKE :title OR events.title LIKE :title OR facilitators.first_name LIKE :title OR
- facilitators.last_name LIKE :title OR projects.name LIKE :title OR resources.title LIKE :title OR
+ facilitators.last_name LIKE :title OR organizations.name LIKE :title OR resources.title LIKE :title OR
stories.title LIKE :title OR workshops.title LIKE :title OR workshop_ideas.title LIKE :title OR
story_ideas.body LIKE :title OR -- searching body for story ideas (title exists but isn't used in UI)
DATE_FORMAT(workshop_logs.date, '%Y-%m-%d') LIKE :title OR -- no title on workshop_logs
diff --git a/app/models/facilitator.rb b/app/models/facilitator.rb
index 51e4834ea..6ce5f5614 100644
--- a/app/models/facilitator.rb
+++ b/app/models/facilitator.rb
@@ -57,10 +57,10 @@ class Facilitator < ApplicationRecord
scope :published, -> { active.searchable }
scope :published, ->(published = nil) { published ? active.searchable(published) : active.searchable }
scope :searchable, ->(searchable = nil) { searchable ? where(profile_is_searchable: searchable) : where(profile_is_searchable: true) }
- scope :project_name, ->(project_name) {
- return all if project_name.blank?
- left_joins(user: { project_users: :project })
- .where("projects.name LIKE ?", "%#{sanitize_sql_like(project_name)}%")
+ scope :organization_name, ->(organization_name) {
+ return all if organization_name.blank?
+ left_joins(user: { organization_users: :organization })
+ .where("organizations.name LIKE ?", "%#{sanitize_sql_like(organization_name)}%")
.distinct }
scope :category_names, ->(names) { tag_names(:categories, names) }
scope :sector_names, ->(names) { tag_names(:sectors, names) }
@@ -70,7 +70,7 @@ def self.search_by_params(params)
results = results.search(params[:contact_info]) if params[:contact_info].present?
results = results.sector_names(params[:sector_names]) if params[:sector_names].present?
results = results.sector_names(params[:category_names]) if params[:category_names].present?
- results = results.project_name(params[:project_name]) if params[:project_name].present?
+ results = results.organization_name(params[:organization_name]) if params[:organization_name].present?
results = results.windows_type_name(params[:windows_type_name]) if params[:windows_type_name].present?
results
end
diff --git a/app/models/organization.rb b/app/models/organization.rb
index 03ffdf416..50fe80d1a 100644
--- a/app/models/organization.rb
+++ b/app/models/organization.rb
@@ -1,5 +1,5 @@
class Organization < ApplicationRecord
- include TagFilterable, Trendable, ViewCountable, WindowsTypeFilterable
+ include TagFilterable, Trendable, WindowsTypeFilterable
belongs_to :organization_status
belongs_to :organization_obligation, optional: true
diff --git a/app/models/report.rb b/app/models/report.rb
index 3a9c5bf85..a7261d851 100644
--- a/app/models/report.rb
+++ b/app/models/report.rb
@@ -152,8 +152,8 @@ def set_has_attachment
end
def set_windows_type
- return unless project && windows_type.nil?
- update(windows_type_id: project.windows_type.id)
+ return unless organization && windows_type.nil?
+ update(windows_type_id: organization.windows_type.id)
end
def create_notification
diff --git a/app/models/story.rb b/app/models/story.rb
index 0e394745f..35072ba95 100644
--- a/app/models/story.rb
+++ b/app/models/story.rb
@@ -73,15 +73,15 @@ def name
end
def organization_name
- project&.name
+ organization&.name
end
def organization_locality
- project&.organization_locality
+ organization&.organization_locality
end
def organization_description
- project&.organization_description
+ organization&.organization_description
end
def attach_assets_from_idea!
diff --git a/app/models/tag.rb b/app/models/tag.rb
index e2d60052e..afbb6b258 100644
--- a/app/models/tag.rb
+++ b/app/models/tag.rb
@@ -30,10 +30,10 @@ class Tag
path: -> { Rails.application.routes.url_helpers.facilitators_path },
klass: Facilitator
},
- projects: {
+ organizations: {
icon: "🏫",
- path: -> { Rails.application.routes.url_helpers.projects_path },
- klass: ::Project
+ path: -> { Rails.application.routes.url_helpers.organizations_path },
+ klass: Organization
},
quotes: {
icon: "💬",
diff --git a/app/models/user.rb b/app/models/user.rb
index ba269ca88..b86f1c8df 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -49,7 +49,7 @@ class User < ApplicationRecord
# Validations
validates :email, presence: true, uniqueness: { case_sensitive: false }
- validates_associated :project_users
+ validates_associated :organization_users
# Search Cop
include SearchCop
@@ -100,8 +100,8 @@ def devise_email_name
facilitator&.first_name.presence || first_name.presence || email
end
- def submitted_monthly_report(submitted_date = Date.today, windows_type, project_id)
- Report.where(project_id: project_id, type: "MonthlyReport", date: submitted_date,
+ def submitted_monthly_report(submitted_date = Date.today, windows_type, organization_id)
+ Report.where(organization_id: organization_id, type: "MonthlyReport", date: submitted_date,
windows_type: windows_type).last
end
diff --git a/app/services/facilitator_from_user_service.rb b/app/services/facilitator_from_user_service.rb
index 1e6976817..e1c57a69c 100644
--- a/app/services/facilitator_from_user_service.rb
+++ b/app/services/facilitator_from_user_service.rb
@@ -12,7 +12,7 @@ def call
hydrate_facilitator
hydrate_addresses
hydrate_contact_methods
- hydrate_projects
+ hydrate_organizations
facilitator
end
@@ -30,7 +30,7 @@ def hydrate_facilitator
)
end
- def hydrate_projects
+ def hydrate_organizations
# t.integer "agency_id"
end
diff --git a/app/services/tagging_search_service.rb b/app/services/tagging_search_service.rb
index 0c3eabfe7..1f4a35bde 100644
--- a/app/services/tagging_search_service.rb
+++ b/app/services/tagging_search_service.rb
@@ -61,13 +61,13 @@ def self.call(sector_names:, category_names: nil,
.paginate(page: pages[:facilitators] || 1, per_page: number_of_items_per_page)
.decorate,
- projects: Project
+ organizations: Organization
.includes(:sectors)
.published
.sector_names(sector_names)
.category_names(category_names)
.order(:name)
- .paginate(page: pages[:projects] || 1, per_page: number_of_items_per_page)
+ .paginate(page: pages[:organizations] || 1, per_page: number_of_items_per_page)
.decorate,
quotes: Quote
diff --git a/app/views/admin/analytics/index.html.erb b/app/views/admin/analytics/index.html.erb
index 67a2638a1..c3387d7ca 100644
--- a/app/views/admin/analytics/index.html.erb
+++ b/app/views/admin/analytics/index.html.erb
@@ -162,8 +162,8 @@
<%= render "admin/analytics/popular_list",
- title: "Projects",
- records: @most_viewed_projects,
+ title: "Organizations",
+ records: @most_viewed_organizations,
path_method: :project_path,
metric: :view_count,
color: :projects
diff --git a/app/views/community_news/_community_news_results.html.erb b/app/views/community_news/_community_news_results.html.erb
index b5f8d60df..8b7bf21ef 100644
--- a/app/views/community_news/_community_news_results.html.erb
+++ b/app/views/community_news/_community_news_results.html.erb
@@ -6,7 +6,7 @@
| Title |
Author |
- Project |
+ Organization |
Updated |
Actions |
diff --git a/app/views/community_news/_form.html.erb b/app/views/community_news/_form.html.erb
index ed1ba1048..aa8428318 100644
--- a/app/views/community_news/_form.html.erb
+++ b/app/views/community_news/_form.html.erb
@@ -37,12 +37,12 @@
- <%= f.input :project_id,
+ <%= f.input :organization_id,
as: :select,
label: "Organization",
required: false,
collection: @organizations,
- selected: f.object.project_id,
+ selected: f.object.organization_id,
input_html: { class: "block w-full rounded-md border-gray-300 shadow-sm focus:ring-blue-500 focus:border-blue-500 sm:text-sm" } %>
<%= f.input :author_id,
diff --git a/app/views/community_news/_results_skeleton.html.erb b/app/views/community_news/_results_skeleton.html.erb
index e73f60884..6b23fda73 100644
--- a/app/views/community_news/_results_skeleton.html.erb
+++ b/app/views/community_news/_results_skeleton.html.erb
@@ -50,7 +50,7 @@
-
+
|
diff --git a/app/views/community_news/show.html.erb b/app/views/community_news/show.html.erb
index 68ece7f22..7ce096730 100644
--- a/app/views/community_news/show.html.erb
+++ b/app/views/community_news/show.html.erb
@@ -35,7 +35,7 @@
By: <%= @community_news.created_by.full_name %>
-
Organization Name: <%= @community_news.project&.name %>
+
Organization Name: <%= @community_news.organization&.name %>
diff --git a/app/views/facilitators/_search_boxes.html.erb b/app/views/facilitators/_search_boxes.html.erb
index ac3a7d45f..928170e11 100644
--- a/app/views/facilitators/_search_boxes.html.erb
+++ b/app/views/facilitators/_search_boxes.html.erb
@@ -34,11 +34,11 @@