- <%= 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 8aae4d0ae720086335e8e1fcc1021e46f8433cc8 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 4/5] Remove old Project files and update factories/specs
Co-authored-by: maebeale <7607813+maebeale@users.noreply.github.com>
---
.../project_statuses_controller.rb | 68 ---------
app/controllers/project_users_controller.rb | 13 --
app/controllers/projects_controller.rb | 137 -----------------
app/decorators/project_decorator.rb | 29 ----
app/decorators/project_status_decorator.rb | 3 -
app/decorators/project_user_decorator.rb | 5 -
app/models/project.rb | 107 -------------
app/models/project_obligation.rb | 5 -
app/models/project_status.rb | 7 -
app/models/project_user.rb | 17 ---
.../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 | 2 +-
...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.rb => organization_statuses_spec.rb} | 70 ++++-----
spec/requests/organizations_spec.rb | 143 ++++++++++++++++++
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 | 4 +-
.../community_news/index.html.erb_spec.rb | 4 +-
.../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 | 4 +-
71 files changed, 497 insertions(+), 888 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
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%)
rename spec/requests/{project_statuses_spec.rb => organization_statuses_spec.rb} (54%)
create mode 100644 spec/requests/organizations_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/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/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 3342756eb..000000000
--- a/app/controllers/projects_controller.rb
+++ /dev/null
@@ -1,137 +0,0 @@
-class ProjectsController < ApplicationController
- before_action :set_project, only: [ :show, :edit, :update, :destroy ]
-
- def index
- per_page = params[:number_of_items_per_page].presence || 25
- unpaginated = Project.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
- @project.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[:project_id] = @project.id # Inject context so the WorkshopLogsController#index scopes properly
- workshop_logs_controller.params = params
- workshop_logs_controller.index
-
- 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)
- @facilitators = User.active.or(User.where(id: @workshop_logs_unpaginated.pluck(:user_id)))
- .joins(:workshop_logs)
- .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.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 7e978c83f..000000000
--- a/app/models/project.rb
+++ /dev/null
@@ -1,107 +0,0 @@
-class Project < ApplicationRecord
- include TagFilterable, Trendable, ViewCountable, 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 :by_most_viewed, ->(limit = 10) { order(view_count: :desc).limit(limit) }
- 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 d68313262..000000000
--- a/app/models/project_user.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-class ProjectUser < ApplicationRecord
- belongs_to :project
- belongs_to :user
-
- # Validations
- validates_presence_of :project_id
-
- # 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/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 538fb839b..e63d6f07d 100644
--- a/spec/factories/community_news.rb
+++ b/spec/factories/community_news.rb
@@ -8,7 +8,7 @@
inactive { false }
author { "MyString" }
reference_url { "MyString" }
- project { nil }
+ organization { nil }
windows_type { nil }
workshop { nil }
created_by { nil }
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 7c429cf2a..6abc7a8af 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 }
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 9aa921665..0cf7b5dc4 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/project_statuses_spec.rb b/spec/requests/organization_statuses_spec.rb
similarity index 54%
rename from spec/requests/project_statuses_spec.rb
rename to spec/requests/organization_statuses_spec.rb
index e380eaf05..880fe4cd8 100644
--- a/spec/requests/project_statuses_spec.rb
+++ b/spec/requests/organization_statuses_spec.rb
@@ -1,6 +1,6 @@
require "rails_helper"
-RSpec.describe "/project_statuses", type: :request do
+RSpec.describe "/organization_statuses", type: :request do
let(:admin) { create(:user, :admin) }
let(:regular_user) { create(:user) }
@@ -20,57 +20,57 @@
describe "GET /index" do
it "renders successfully" do
- get project_statuses_url
+ get organization_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)
+ organization_status = OrganizationStatus.create!(valid_attributes)
+ get organization_status_url(organization_status)
expect(response).to be_successful
end
end
describe "GET /new" do
it "renders successfully" do
- get new_project_status_url
+ get new_organization_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)
+ organization_status = OrganizationStatus.create!(valid_attributes)
+ get edit_organization_status_url(organization_status)
expect(response).to be_successful
end
end
describe "POST /create" do
context "with valid params" do
- it "creates a ProjectStatus" do
+ it "creates a OrganizationStatus" do
expect {
- post project_statuses_url, params: { project_status: valid_attributes }
- }.to change(ProjectStatus, :count).by(1)
+ post organization_statuses_url, params: { organization_status: valid_attributes }
+ }.to change(OrganizationStatus, :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)
+ post organization_statuses_url, params: { organization_status: valid_attributes }
+ expect(response).to redirect_to(organization_statuses_url)
end
end
context "with invalid params" do
- it "does not create a ProjectStatus" do
+ it "does not create a OrganizationStatus" do
expect {
- post project_statuses_url, params: { project_status: invalid_attributes }
- }.not_to change(ProjectStatus, :count)
+ post organization_statuses_url, params: { organization_status: invalid_attributes }
+ }.not_to change(OrganizationStatus, :count)
end
it "returns 422" do
- post project_statuses_url, params: { project_status: invalid_attributes }
+ post organization_statuses_url, params: { organization_status: invalid_attributes }
expect(response).to have_http_status(:unprocessable_content)
end
end
@@ -78,25 +78,25 @@
describe "PATCH /update" do
it "updates and redirects" do
- project_status = ProjectStatus.create!(valid_attributes)
+ organization_status = OrganizationStatus.create!(valid_attributes)
- patch project_status_url(project_status),
- params: { project_status: { name: "Updated" } }
+ patch organization_status_url(organization_status),
+ params: { organization_status: { name: "Updated" } }
- expect(response).to redirect_to(project_statuses_url)
- expect(project_status.reload.name).to eq("Updated")
+ expect(response).to redirect_to(organization_statuses_url)
+ expect(organization_status.reload.name).to eq("Updated")
end
end
describe "DELETE /destroy" do
it "destroys and redirects" do
- project_status = ProjectStatus.create!(valid_attributes)
+ organization_status = OrganizationStatus.create!(valid_attributes)
expect {
- delete project_status_url(project_status)
- }.to change(ProjectStatus, :count).by(-1)
+ delete organization_status_url(organization_status)
+ }.to change(OrganizationStatus, :count).by(-1)
- expect(response).to redirect_to(project_statuses_url)
+ expect(response).to redirect_to(organization_statuses_url)
end
end
end
@@ -108,35 +108,35 @@
before { sign_in regular_user }
it "cannot access index" do
- get project_statuses_url
+ get organization_statuses_url
expect(response).to redirect_to(authenticated_root_path)
end
it "cannot access show" do
- ps = ProjectStatus.create!(valid_attributes)
- get project_status_url(ps)
+ os = OrganizationStatus.create!(valid_attributes)
+ get organization_status_url(os)
expect(response).to redirect_to(authenticated_root_path)
end
it "cannot access new" do
- get new_project_status_url
+ get new_organization_status_url
expect(response).to redirect_to(authenticated_root_path)
end
it "cannot create" do
- post project_statuses_url, params: { project_status: valid_attributes }
+ post organization_statuses_url, params: { organization_status: valid_attributes }
expect(response).to redirect_to(authenticated_root_path)
end
it "cannot edit" do
- ps = ProjectStatus.create!(valid_attributes)
- get edit_project_status_url(ps)
+ os = OrganizationStatus.create!(valid_attributes)
+ get edit_organization_status_url(os)
expect(response).to redirect_to(authenticated_root_path)
end
it "cannot destroy" do
- ps = ProjectStatus.create!(valid_attributes)
- delete project_status_url(ps)
+ os = OrganizationStatus.create!(valid_attributes)
+ delete organization_status_url(os)
expect(response).to redirect_to(authenticated_root_path)
end
end
@@ -146,7 +146,7 @@
# --------------------------------------------------
describe "unauthenticated access" do
it "redirects to sign-in" do
- get project_statuses_url
+ get organization_statuses_url
expect(response).to redirect_to(new_user_session_path)
end
end
diff --git a/spec/requests/organizations_spec.rb b/spec/requests/organizations_spec.rb
new file mode 100644
index 000000000..4c000b67a
--- /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, super_user: true) }
+
+ 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/projects_spec.rb b/spec/requests/projects_spec.rb
deleted file mode 100644
index 5cf5eaf05..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, super_user: true) }
-
- 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 6ccadb196..319f9c880 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) }
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 0fc8bc069..27ce60dde 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 e93837b23..01db97ecd 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),
@@ -45,7 +45,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]"
assert_select "select[name=?]", "community_news[windows_type_id]"
end
diff --git a/spec/views/community_news/index.html.erb_spec.rb b/spec/views/community_news/index.html.erb_spec.rb
index 01b0cf069..f2f9c3e4f 100644
--- a/spec/views/community_news/index.html.erb_spec.rb
+++ b/spec/views/community_news/index.html.erb_spec.rb
@@ -11,7 +11,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),
@@ -24,7 +24,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/community_news/new.html.erb_spec.rb b/spec/views/community_news/new.html.erb_spec.rb
index aa64a158e..c98c80a7e 100644
--- a/spec/views/community_news/new.html.erb_spec.rb
+++ b/spec/views/community_news/new.html.erb_spec.rb
@@ -17,7 +17,7 @@
featured: false,
author: create(:user),
reference_url: "MyString",
- project: nil,
+ organization: nil,
windows_type: nil,
created_by: create(:user),
updated_by: create(:user),
@@ -42,7 +42,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]"
assert_select "select[name=?]", "community_news[windows_type_id]"
end
diff --git a/spec/views/community_news/show.html.erb_spec.rb b/spec/views/community_news/show.html.erb_spec.rb
index 6606159fd..4986bf681 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 de070f318..61262714f 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 9364fa69d..3c22da7d5 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 b3a75c0a3..b38531c81 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 2b7fb3eec..4c9ccee2c 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(/MyBody/)
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 aa1fd0a55..542e32db5 100644
--- a/spec/views/users/show.html.erb_spec.rb
+++ b/spec/views/users/show.html.erb_spec.rb
@@ -15,8 +15,8 @@
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, user: user, position: :leader) }
+ let!(:project) { create(:organization, name: "Healing Arts") }
+ let!(:project_user) { create(:organization_user, organization: project, user: user, position: :leader) }
before do
assign(:user, user)
From bb1d6866436ec6038f3e0830092908cb2eb04ad8 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 5/5] 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 57fee3514..44409c647 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 authenticated_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 authenticated_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 85ff49c33..f8a86b9a9 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 86ad3e703..83d17b4c9 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 authenticated_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
@@ -124,10 +124,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.joins(:workshop_logs)
# .order(:title)
@@ -181,11 +181,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
@@ -209,7 +209,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 2ea550354..706d72f96 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -116,11 +116,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 &&
@@ -129,9 +129,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