chore: remove examples models and views

main
Nelson Jovel 2 years ago
parent 0f525cf2e8
commit e97b39ec48

@ -1,60 +0,0 @@
module Dashboard
class ExamplesController < ApplicationController
before_action :set_example, only: %i[ show edit update destroy ]
# GET /examples
def index
@examples = Example.all
end
# GET /examples/1
def show
end
# GET /examples/new
def new
@example = Example.new
end
# GET /examples/1/edit
def edit
end
# POST /examples
def create
@example = Example.new(example_params)
if @example.save
redirect_to @example, notice: "Example was successfully created."
else
render :new, status: :unprocessable_entity
end
end
# PATCH/PUT /examples/1
def update
if @example.update(example_params)
redirect_to @example, notice: "Example was successfully updated.", status: :see_other
else
render :edit, status: :unprocessable_entity
end
end
# DELETE /examples/1
def destroy
@example.destroy!
redirect_to examples_url, notice: "Example was successfully destroyed.", status: :see_other
end
private
# Use callbacks to share common setup or constraints between actions.
def set_example
@example = Example.find(params[:id])
end
# Only allow a list of trusted parameters through.
def example_params
params.require(:example).permit(:text, :body)
end
end
end

@ -1,4 +0,0 @@
module Dashboard
module ExamplesHelper
end
end

@ -1,12 +0,0 @@
<div id="<%= dom_id example %>">
<p>
<strong>Text:</strong>
<%= example.text %>
</p>
<p>
<strong>Body:</strong>
<%= example.body %>
</p>
</div>

@ -1,27 +0,0 @@
<%= form_with(model: example) do |form| %>
<% if example.errors.any? %>
<div style="color: red">
<h2><%= pluralize(example.errors.count, "error") %> prohibited this example from being saved:</h2>
<ul>
<% example.errors.each do |error| %>
<li><%= error.full_message %></li>
<% end %>
</ul>
</div>
<% end %>
<div>
<%= form.label :text, style: "display: block" %>
<%= form.text_field :text %>
</div>
<div>
<%= form.label :body, style: "display: block" %>
<%= form.text_area :body %>
</div>
<div>
<%= form.submit %>
</div>
<% end %>

@ -1,10 +0,0 @@
<h1>Editing example</h1>
<%= render "form", example: @example %>
<br>
<div>
<%= link_to "Show this example", @example %> |
<%= link_to "Back to examples", examples_path %>
</div>

@ -1,14 +0,0 @@
<p style="color: green"><%= notice %></p>
<h1>Examples</h1>
<div id="examples">
<% @examples.each do |example| %>
<%= render example %>
<p>
<%= link_to "Show this example", example %>
</p>
<% end %>
</div>
<%= link_to "New example", new_example_path %>

@ -1,9 +0,0 @@
<h1>New example</h1>
<%= render "form", example: @example %>
<br>
<div>
<%= link_to "Back to examples", examples_path %>
</div>

@ -1,10 +0,0 @@
<p style="color: green"><%= notice %></p>
<%= render @example %>
<div>
<%= link_to "Edit this example", edit_example_path(@example) %> |
<%= link_to "Back to examples", examples_path %>
<%= button_to "Destroy this example", @example, method: :delete %>
</div>

@ -1,4 +1,3 @@
Dashboard::Engine.routes.draw do Dashboard::Engine.routes.draw do
resources :examples
get "/welcome", to: "home#index" get "/welcome", to: "home#index"
end end

@ -10,18 +10,10 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[7.1].define(version: 2024_01_05_041641) do ActiveRecord::Schema[7.1].define(version: 2024_01_04_192128) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"
create_table "children", force: :cascade do |t|
t.text "text"
t.bigint "parent_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["parent_id"], name: "index_children_on_parent_id"
end
create_table "dashboard_academic_years", force: :cascade do |t| create_table "dashboard_academic_years", force: :cascade do |t|
t.string "range" t.string "range"
t.datetime "created_at", null: false t.datetime "created_at", null: false
@ -45,14 +37,14 @@ ActiveRecord::Schema[7.1].define(version: 2024_01_05_041641) do
create_table "dashboard_admin_data_values", force: :cascade do |t| create_table "dashboard_admin_data_values", force: :cascade do |t|
t.float "likert_score" t.float "likert_score"
t.bigint "school_id", null: false t.bigint "dashboard_school_id", null: false
t.bigint "dashboard_admin_data_item_id", null: false t.bigint "dashboard_admin_data_item_id", null: false
t.bigint "dashboard_academic_year_id", null: false t.bigint "dashboard_academic_year_id", null: false
t.datetime "created_at", null: false t.datetime "created_at", null: false
t.datetime "updated_at", null: false t.datetime "updated_at", null: false
t.index ["dashboard_academic_year_id"], name: "idx_on_dashboard_academic_year_id_1de27231d5" t.index ["dashboard_academic_year_id"], name: "idx_on_dashboard_academic_year_id_1de27231d5"
t.index ["dashboard_admin_data_item_id"], name: "idx_on_dashboard_admin_data_item_id_edae2faad3" t.index ["dashboard_admin_data_item_id"], name: "idx_on_dashboard_admin_data_item_id_edae2faad3"
t.index ["school_id"], name: "index_dashboard_admin_data_values_on_school_id" t.index ["dashboard_school_id"], name: "index_dashboard_admin_data_values_on_dashboard_school_id"
end end
create_table "dashboard_categories", force: :cascade do |t| create_table "dashboard_categories", force: :cascade do |t|
@ -65,6 +57,14 @@ ActiveRecord::Schema[7.1].define(version: 2024_01_05_041641) do
t.datetime "updated_at", null: false t.datetime "updated_at", null: false
end end
create_table "dashboard_districts", force: :cascade do |t|
t.string "name"
t.string "slug"
t.integer "qualtrics_code"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "dashboard_ells", force: :cascade do |t| create_table "dashboard_ells", force: :cascade do |t|
t.string "designation" t.string "designation"
t.string "slug" t.string "slug"
@ -112,7 +112,7 @@ ActiveRecord::Schema[7.1].define(version: 2024_01_05_041641) do
end end
create_table "dashboard_respondents", force: :cascade do |t| create_table "dashboard_respondents", force: :cascade do |t|
t.bigint "school_id", null: false t.bigint "dashboard_school_id", null: false
t.bigint "dashboard_academic_year_id", null: false t.bigint "dashboard_academic_year_id", null: false
t.integer "total_students" t.integer "total_students"
t.float "total_teachers" t.float "total_teachers"
@ -133,20 +133,20 @@ ActiveRecord::Schema[7.1].define(version: 2024_01_05_041641) do
t.datetime "created_at", null: false t.datetime "created_at", null: false
t.datetime "updated_at", null: false t.datetime "updated_at", null: false
t.index ["dashboard_academic_year_id"], name: "index_dashboard_respondents_on_dashboard_academic_year_id" t.index ["dashboard_academic_year_id"], name: "index_dashboard_respondents_on_dashboard_academic_year_id"
t.index ["school_id"], name: "index_dashboard_respondents_on_school_id" t.index ["dashboard_school_id"], name: "index_dashboard_respondents_on_dashboard_school_id"
end end
create_table "dashboard_response_rates", force: :cascade do |t| create_table "dashboard_response_rates", force: :cascade do |t|
t.bigint "dashboard_subcategory_id", null: false t.bigint "dashboard_subcategory_id", null: false
t.bigint "school_id", null: false t.bigint "dashboard_school_id", null: false
t.bigint "dashboard_academic_year_id", null: false t.bigint "dashboard_academic_year_id", null: false
t.float "school_response_rate" t.float "school_response_rate"
t.float "teacher_response_rate" t.float "teacher_response_rate"
t.datetime "created_at", null: false t.datetime "created_at", null: false
t.datetime "updated_at", null: false t.datetime "updated_at", null: false
t.index ["dashboard_academic_year_id"], name: "index_dashboard_response_rates_on_dashboard_academic_year_id" t.index ["dashboard_academic_year_id"], name: "index_dashboard_response_rates_on_dashboard_academic_year_id"
t.index ["dashboard_school_id"], name: "index_dashboard_response_rates_on_dashboard_school_id"
t.index ["dashboard_subcategory_id"], name: "index_dashboard_response_rates_on_dashboard_subcategory_id" t.index ["dashboard_subcategory_id"], name: "index_dashboard_response_rates_on_dashboard_subcategory_id"
t.index ["school_id"], name: "index_dashboard_response_rates_on_school_id"
end end
create_table "dashboard_scales", force: :cascade do |t| create_table "dashboard_scales", force: :cascade do |t|
@ -157,6 +157,19 @@ ActiveRecord::Schema[7.1].define(version: 2024_01_05_041641) do
t.index ["dashboard_measure_id"], name: "index_dashboard_scales_on_dashboard_measure_id" t.index ["dashboard_measure_id"], name: "index_dashboard_scales_on_dashboard_measure_id"
end end
create_table "dashboard_schools", force: :cascade do |t|
t.string "name"
t.bigint "dashboard_district_id", null: false
t.text "description"
t.string "slug"
t.integer "qualtrics_code"
t.integer "dese_id"
t.boolean "is_hs"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["dashboard_district_id"], name: "index_dashboard_schools_on_dashboard_district_id"
end
create_table "dashboard_scores", force: :cascade do |t| create_table "dashboard_scores", force: :cascade do |t|
t.float "average" t.float "average"
t.boolean "meets_teacher_threshold" t.boolean "meets_teacher_threshold"
@ -201,7 +214,7 @@ ActiveRecord::Schema[7.1].define(version: 2024_01_05_041641) do
create_table "dashboard_survey_item_responses", force: :cascade do |t| create_table "dashboard_survey_item_responses", force: :cascade do |t|
t.integer "likert_score" t.integer "likert_score"
t.bigint "school_id", null: false t.bigint "dashboard_school_id", null: false
t.bigint "dashboard_survey_item_id", null: false t.bigint "dashboard_survey_item_id", null: false
t.bigint "dashboard_academic_year_id", null: false t.bigint "dashboard_academic_year_id", null: false
t.bigint "dashboard_student_id" t.bigint "dashboard_student_id"
@ -218,10 +231,10 @@ ActiveRecord::Schema[7.1].define(version: 2024_01_05_041641) do
t.index ["dashboard_ell_id"], name: "index_dashboard_survey_item_responses_on_dashboard_ell_id" t.index ["dashboard_ell_id"], name: "index_dashboard_survey_item_responses_on_dashboard_ell_id"
t.index ["dashboard_gender_id"], name: "index_dashboard_survey_item_responses_on_dashboard_gender_id" t.index ["dashboard_gender_id"], name: "index_dashboard_survey_item_responses_on_dashboard_gender_id"
t.index ["dashboard_income_id"], name: "index_dashboard_survey_item_responses_on_dashboard_income_id" t.index ["dashboard_income_id"], name: "index_dashboard_survey_item_responses_on_dashboard_income_id"
t.index ["dashboard_school_id"], name: "index_dashboard_survey_item_responses_on_dashboard_school_id"
t.index ["dashboard_sped_id"], name: "index_dashboard_survey_item_responses_on_dashboard_sped_id" t.index ["dashboard_sped_id"], name: "index_dashboard_survey_item_responses_on_dashboard_sped_id"
t.index ["dashboard_student_id"], name: "index_dashboard_survey_item_responses_on_dashboard_student_id" t.index ["dashboard_student_id"], name: "index_dashboard_survey_item_responses_on_dashboard_student_id"
t.index ["dashboard_survey_item_id"], name: "idx_on_dashboard_survey_item_id_3f6652fbc6" t.index ["dashboard_survey_item_id"], name: "idx_on_dashboard_survey_item_id_3f6652fbc6"
t.index ["school_id"], name: "index_dashboard_survey_item_responses_on_school_id"
end end
create_table "dashboard_survey_items", force: :cascade do |t| create_table "dashboard_survey_items", force: :cascade do |t|
@ -238,45 +251,18 @@ ActiveRecord::Schema[7.1].define(version: 2024_01_05_041641) do
t.index ["dashboard_scale_id"], name: "index_dashboard_survey_items_on_dashboard_scale_id" t.index ["dashboard_scale_id"], name: "index_dashboard_survey_items_on_dashboard_scale_id"
end end
create_table "districts", force: :cascade do |t|
t.string "name"
t.string "slug"
t.integer "qualtrics_code"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "parents", force: :cascade do |t|
t.text "text"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "schools", force: :cascade do |t|
t.string "name"
t.bigint "district_id", null: false
t.text "description"
t.string "slug"
t.integer "qualtrics_code"
t.integer "dese_id"
t.boolean "is_hs"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["district_id"], name: "index_schools_on_district_id"
end
add_foreign_key "children", "parents"
add_foreign_key "dashboard_admin_data_items", "dashboard_scales" add_foreign_key "dashboard_admin_data_items", "dashboard_scales"
add_foreign_key "dashboard_admin_data_values", "dashboard_academic_years" add_foreign_key "dashboard_admin_data_values", "dashboard_academic_years"
add_foreign_key "dashboard_admin_data_values", "dashboard_admin_data_items" add_foreign_key "dashboard_admin_data_values", "dashboard_admin_data_items"
add_foreign_key "dashboard_admin_data_values", "schools" add_foreign_key "dashboard_admin_data_values", "dashboard_schools"
add_foreign_key "dashboard_measures", "dashboard_subcategories" add_foreign_key "dashboard_measures", "dashboard_subcategories"
add_foreign_key "dashboard_respondents", "dashboard_academic_years" add_foreign_key "dashboard_respondents", "dashboard_academic_years"
add_foreign_key "dashboard_respondents", "schools" add_foreign_key "dashboard_respondents", "dashboard_schools"
add_foreign_key "dashboard_response_rates", "dashboard_academic_years" add_foreign_key "dashboard_response_rates", "dashboard_academic_years"
add_foreign_key "dashboard_response_rates", "dashboard_schools"
add_foreign_key "dashboard_response_rates", "dashboard_subcategories" add_foreign_key "dashboard_response_rates", "dashboard_subcategories"
add_foreign_key "dashboard_response_rates", "schools"
add_foreign_key "dashboard_scales", "dashboard_measures" add_foreign_key "dashboard_scales", "dashboard_measures"
add_foreign_key "dashboard_schools", "dashboard_districts"
add_foreign_key "dashboard_student_races", "dashboard_races" add_foreign_key "dashboard_student_races", "dashboard_races"
add_foreign_key "dashboard_student_races", "dashboard_students" add_foreign_key "dashboard_student_races", "dashboard_students"
add_foreign_key "dashboard_subcategories", "dashboard_categories", column: "dashboard_categories_id" add_foreign_key "dashboard_subcategories", "dashboard_categories", column: "dashboard_categories_id"
@ -284,10 +270,9 @@ ActiveRecord::Schema[7.1].define(version: 2024_01_05_041641) do
add_foreign_key "dashboard_survey_item_responses", "dashboard_ells" add_foreign_key "dashboard_survey_item_responses", "dashboard_ells"
add_foreign_key "dashboard_survey_item_responses", "dashboard_genders" add_foreign_key "dashboard_survey_item_responses", "dashboard_genders"
add_foreign_key "dashboard_survey_item_responses", "dashboard_incomes" add_foreign_key "dashboard_survey_item_responses", "dashboard_incomes"
add_foreign_key "dashboard_survey_item_responses", "dashboard_schools"
add_foreign_key "dashboard_survey_item_responses", "dashboard_speds" add_foreign_key "dashboard_survey_item_responses", "dashboard_speds"
add_foreign_key "dashboard_survey_item_responses", "dashboard_students" add_foreign_key "dashboard_survey_item_responses", "dashboard_students"
add_foreign_key "dashboard_survey_item_responses", "dashboard_survey_items" add_foreign_key "dashboard_survey_item_responses", "dashboard_survey_items"
add_foreign_key "dashboard_survey_item_responses", "schools"
add_foreign_key "dashboard_survey_items", "dashboard_scales" add_foreign_key "dashboard_survey_items", "dashboard_scales"
add_foreign_key "schools", "districts"
end end

@ -1,6 +0,0 @@
FactoryBot.define do
factory :example, class: "Dashboard::Example" do
text { "MyString" }
body { "MyText" }
end
end

@ -1,17 +0,0 @@
require 'rails_helper'
# Specs in this file have access to a helper object that includes
# the ExamplesHelper. For example:
#
# describe ExamplesHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# expect(helper.concat_strings("this","that")).to eq("this that")
# end
# end
# end
module Dashboard
RSpec.describe ExamplesHelper, type: :helper do
pending "add some examples to (or delete) #{__FILE__}"
end
end

@ -1,10 +0,0 @@
require "rails_helper"
module Dashboard
RSpec.describe Example, type: :model do
it "creates an example to test rspec and factorybot" do
create(:example)
expect(Example.count).to eq 1
end
end
end

@ -75,4 +75,6 @@ RSpec.configure do |config|
include Dashboard::Engine.routes.url_helpers include Dashboard::Engine.routes.url_helpers
end end
end end
config.include Dashboard::Engine.routes.url_helpers
end end

@ -1,138 +0,0 @@
require 'rails_helper'
# This spec was generated by rspec-rails when you ran the scaffold generator.
# It demonstrates how one might use RSpec to test the controller code that
# was generated by Rails when you ran the scaffold generator.
#
# It assumes that the implementation code is generated by the rails scaffold
# generator. If you are using any extension libraries to generate different
# controller code, this generated spec may or may not pass.
#
# It only uses APIs available in rails and/or rspec-rails. There are a number
# of tools you can use to make these specs even more expressive, but we're
# sticking to rails and rspec-rails APIs to keep things simple and stable.
module Dashboard
RSpec.describe "/examples", type: :request do
include Engine.routes.url_helpers
# This should return the minimal set of attributes required to create a valid
# Example. As you add validations to Example, be sure to
# adjust the attributes here as well.
let(:valid_attributes) {
skip("Add a hash of attributes valid for your model")
}
let(:invalid_attributes) {
skip("Add a hash of attributes invalid for your model")
}
describe "GET /index" do
it "renders a successful response" do
Example.create! valid_attributes
get examples_url
expect(response).to be_successful
end
end
describe "GET /show" do
it "renders a successful response" do
example = Example.create! valid_attributes
get example_url(example)
expect(response).to be_successful
end
end
describe "GET /new" do
it "renders a successful response" do
get new_example_url
expect(response).to be_successful
end
end
describe "GET /edit" do
it "renders a successful response" do
example = Example.create! valid_attributes
get edit_example_url(example)
expect(response).to be_successful
end
end
describe "POST /create" do
context "with valid parameters" do
it "creates a new Example" do
expect {
post examples_url, params: { example: valid_attributes }
}.to change(Example, :count).by(1)
end
it "redirects to the created example" do
post examples_url, params: { example: valid_attributes }
expect(response).to redirect_to(example_url(Example.last))
end
end
context "with invalid parameters" do
it "does not create a new Example" do
expect {
post examples_url, params: { example: invalid_attributes }
}.to change(Example, :count).by(0)
end
it "renders a response with 422 status (i.e. to display the 'new' template)" do
post examples_url, params: { example: invalid_attributes }
expect(response).to have_http_status(:unprocessable_entity)
end
end
end
describe "PATCH /update" do
context "with valid parameters" do
let(:new_attributes) {
skip("Add a hash of attributes valid for your model")
}
it "updates the requested example" do
example = Example.create! valid_attributes
patch example_url(example), params: { example: new_attributes }
example.reload
skip("Add assertions for updated state")
end
it "redirects to the example" do
example = Example.create! valid_attributes
patch example_url(example), params: { example: new_attributes }
example.reload
expect(response).to redirect_to(example_url(example))
end
end
context "with invalid parameters" do
it "renders a response with 422 status (i.e. to display the 'edit' template)" do
example = Example.create! valid_attributes
patch example_url(example), params: { example: invalid_attributes }
expect(response).to have_http_status(:unprocessable_entity)
end
end
end
describe "DELETE /destroy" do
it "destroys the requested example" do
example = Example.create! valid_attributes
expect {
delete example_url(example)
}.to change(Example, :count).by(-1)
end
it "redirects to the examples list" do
example = Example.create! valid_attributes
delete example_url(example)
expect(response).to redirect_to(examples_url)
end
end
end
end

@ -1,39 +0,0 @@
require "rails_helper"
module Dashboard
RSpec.describe ExamplesController, type: :routing do
describe "routing" do
it "routes to #index" do
expect(get: "dashboard/examples").to route_to("dashboard/examples#index")
end
it "routes to #new" do
expect(get: "dashboard/examples/new").to route_to("dashboard/examples#new")
end
it "routes to #show" do
expect(get: "dashboard/examples/1").to route_to("dashboard/examples#show", id: "1")
end
it "routes to #edit" do
expect(get: "/dashboard/examples/1/edit").to route_to("dashboard/examples#edit", id: "1")
end
it "routes to #create" do
expect(post: "/dashboard/examples").to route_to("dashboard/examples#create")
end
it "routes to #update via PUT" do
expect(put: "/dashboard/examples/1").to route_to("dashboard/examples#update", id: "1")
end
it "routes to #update via PATCH" do
expect(patch: "/dashboard/examples/1").to route_to("dashboard/examples#update", id: "1")
end
it "routes to #destroy" do
expect(delete: "/dashboard/examples/1").to route_to("dashboard/examples#destroy", id: "1")
end
end
end
end

@ -1,26 +0,0 @@
require "rails_helper"
module Dashboard
RSpec.xdescribe "dashboard/examples/edit", type: :view do
let(:example) do
Example.create!(
text: "MyString",
body: "MyText"
)
end
before(:each) do
assign(:example, example)
end
it "renders the edit example form" do
render
assert_select "form[action=?][method=?]", example_path(example), "post" do
assert_select "input[name=?]", "example[text]"
assert_select "textarea[name=?]", "example[body]"
end
end
end
end

@ -1,27 +0,0 @@
require "rails_helper"
require "nokogiri"
module Dashboard
include Engine.routes.url_helpers
RSpec.describe "/dashboard/examples/index", type: :view do
before(:each) do
assign(:examples, [
Example.create!(
text: "Word",
body: "Sentence"
),
Example.create!(
text: "Word",
body: "Sentence"
)
])
end
it "renders a list of examples" do
render
cell_selector = Rails::VERSION::STRING >= "7" ? "div>p" : "tr>td"
assert_select cell_selector, text: Regexp.new("Word".to_s), count: 2
assert_select cell_selector, text: Regexp.new("Sentence".to_s), count: 2
end
end
end

@ -1,23 +0,0 @@
require "rails_helper"
module Dashboard
include Engine.routes.url_helpers
RSpec.describe "dashboard/examples/new", type: :view do
before(:each) do
assign(:example, Example.new(
text: "MyString",
body: "MyText"
))
end
it "renders new example form" do
render
assert_select "form[action=?][method=?]", examples_path, "post" do
assert_select "input[name=?]", "example[text]"
assert_select "textarea[name=?]", "example[body]"
end
end
end
end

@ -1,18 +0,0 @@
require "rails_helper"
module Dashboard
RSpec.describe "dashboard/examples/show", type: :view do
before(:each) do
assign(:example, Example.create!(
text: "Word",
body: "Sentence"
))
end
it "renders attributes in <p>" do
render
expect(rendered).to match(/Word/)
expect(rendered).to match(/Sentence/)
end
end
end
Loading…
Cancel
Save