-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1 parent
c965c93
commit 68b36e5
Showing
18 changed files
with
269 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
class ProjectsController < ApplicationController | ||
before_action :set_project, only: %i[ show edit update destroy ] | ||
|
||
# GET /projects or /projects.json | ||
def index | ||
@projects = Project.all | ||
end | ||
|
||
# GET /projects/1 or /projects/1.json | ||
def show | ||
end | ||
|
||
# GET /projects/new | ||
def new | ||
@project = Project.new | ||
end | ||
|
||
# GET /projects/1/edit | ||
def edit | ||
end | ||
|
||
# POST /projects or /projects.json | ||
def create | ||
@project = Project.new(project_params) | ||
|
||
respond_to do |format| | ||
if @project.save | ||
format.html { redirect_to project_url(@project), notice: "Project was successfully created." } | ||
format.json { render :show, status: :created, location: @project } | ||
else | ||
format.html { render :new, status: :unprocessable_entity } | ||
format.json { render json: @project.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# PATCH/PUT /projects/1 or /projects/1.json | ||
def update | ||
respond_to do |format| | ||
if @project.update(project_params) | ||
format.html { redirect_to project_url(@project), notice: "Project was successfully updated." } | ||
format.json { render :show, status: :ok, location: @project } | ||
else | ||
format.html { render :edit, status: :unprocessable_entity } | ||
format.json { render json: @project.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# DELETE /projects/1 or /projects/1.json | ||
def destroy | ||
@project.destroy | ||
|
||
respond_to do |format| | ||
format.html { redirect_to projects_url, notice: "Project was successfully destroyed." } | ||
format.json { head :no_content } | ||
end | ||
end | ||
|
||
private | ||
# Use callbacks to share common setup or constraints between actions. | ||
def set_project | ||
@project = Project.find(params[:id]) | ||
end | ||
|
||
# Only allow a list of trusted parameters through. | ||
def project_params | ||
params.fetch(:project, {}) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module ProjectsHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
class Project < ApplicationRecord | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
<%= simple_form_for(@project) do |f| %> | ||
<%= f.error_notification %> | ||
<%= f.error_notification message: f.object.errors[:base].to_sentence if f.object.errors[:base].present? %> | ||
|
||
<div class="form-inputs"> | ||
</div> | ||
|
||
<div class="form-actions"> | ||
<%= f.button :submit %> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<div id="<%= dom_id project %>"> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
json.extract! project, :id, :created_at, :updated_at | ||
json.url project_url(project, format: :json) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<h1>Editing project</h1> | ||
|
||
<%= render "form", project: @project %> | ||
|
||
<br> | ||
|
||
<div> | ||
<%= link_to "Show this project", @project %> | | ||
<%= link_to "Back to projects", projects_path %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<p style="color: green"><%= notice %></p> | ||
|
||
<h1>Projects</h1> | ||
|
||
<div id="projects"> | ||
<% @projects.each do |project| %> | ||
<%= render project %> | ||
<p> | ||
<%= link_to "Show this project", project %> | ||
</p> | ||
<% end %> | ||
</div> | ||
|
||
<%= link_to "New project", new_project_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
json.array! @projects, partial: "projects/project", as: :project |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<h1>New project</h1> | ||
|
||
<%= render "form", project: @project %> | ||
|
||
<br> | ||
|
||
<div> | ||
<%= link_to "Back to projects", projects_path %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<p style="color: green"><%= notice %></p> | ||
|
||
<%= render @project %> | ||
|
||
<div> | ||
<%= link_to "Edit this project", edit_project_path(@project) %> | | ||
<%= link_to "Back to projects", projects_path %> | ||
|
||
<%= button_to "Destroy this project", @project, method: :delete %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
json.partial! "projects/project", project: @project |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
Rails.application.routes.draw do | ||
resources :projects | ||
|
||
resources :suppliers | ||
resources :part_numbers | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
class CreateProjects < ActiveRecord::Migration[7.0] | ||
def change | ||
create_table :projects do |t| | ||
t.string :name | ||
t.string :description | ||
t.string :status | ||
t.string :start_date | ||
t.string :end_date | ||
t.string :project_manager | ||
t.string :project_owner | ||
t.string :project_team | ||
t.string :project_budget | ||
t.string :project_risk | ||
t.string :project_milestones | ||
t.string :project_dependencies | ||
t.string :project_issues | ||
t.string :project_notes | ||
t.string :project_attachments | ||
t.string :project_tasks | ||
t.string :project_comments | ||
t.string :project_reports | ||
t.string :project_timesheets | ||
t.string :project_invoices | ||
t.string :project_expenses | ||
t.timestamps | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
require "test_helper" | ||
|
||
class ProjectsControllerTest < ActionDispatch::IntegrationTest | ||
setup do | ||
@project = projects(:one) | ||
end | ||
|
||
test "should get index" do | ||
get projects_url | ||
assert_response :success | ||
end | ||
|
||
test "should get new" do | ||
get new_project_url | ||
assert_response :success | ||
end | ||
|
||
test "should create project" do | ||
assert_difference("Project.count") do | ||
post projects_url, params: { project: { } } | ||
end | ||
|
||
assert_redirected_to project_url(Project.last) | ||
end | ||
|
||
test "should show project" do | ||
get project_url(@project) | ||
assert_response :success | ||
end | ||
|
||
test "should get edit" do | ||
get edit_project_url(@project) | ||
assert_response :success | ||
end | ||
|
||
test "should update project" do | ||
patch project_url(@project), params: { project: { } } | ||
assert_redirected_to project_url(@project) | ||
end | ||
|
||
test "should destroy project" do | ||
assert_difference("Project.count", -1) do | ||
delete project_url(@project) | ||
end | ||
|
||
assert_redirected_to projects_url | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html | ||
|
||
# This model initially had no columns defined. If you add columns to the | ||
# model remove the "{}" from the fixture names and add the columns immediately | ||
# below each fixture, per the syntax in the comments below | ||
# | ||
one: {} | ||
# column: value | ||
# | ||
two: {} | ||
# column: value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require "test_helper" | ||
|
||
class ProjectTest < ActiveSupport::TestCase | ||
# test "the truth" do | ||
# assert true | ||
# end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
require "application_system_test_case" | ||
|
||
class ProjectsTest < ApplicationSystemTestCase | ||
setup do | ||
@project = projects(:one) | ||
end | ||
|
||
test "visiting the index" do | ||
visit projects_url | ||
assert_selector "h1", text: "Projects" | ||
end | ||
|
||
test "should create project" do | ||
visit projects_url | ||
click_on "New project" | ||
|
||
click_on "Create Project" | ||
|
||
assert_text "Project was successfully created" | ||
click_on "Back" | ||
end | ||
|
||
test "should update Project" do | ||
visit project_url(@project) | ||
click_on "Edit this project", match: :first | ||
|
||
click_on "Update Project" | ||
|
||
assert_text "Project was successfully updated" | ||
click_on "Back" | ||
end | ||
|
||
test "should destroy Project" do | ||
visit project_url(@project) | ||
click_on "Destroy this project", match: :first | ||
|
||
assert_text "Project was successfully destroyed" | ||
end | ||
end |