-
Notifications
You must be signed in to change notification settings - Fork 4
Appointment requirements #178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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 AppointmentRequirementsController < ApplicationController | ||
| before_action :set_appointment_requirement, only: %i[ show edit update destroy ] | ||
|
|
||
| # GET /appointment_requirements or /appointment_requirements.json | ||
| def index | ||
| @appointment_requirements = AppointmentRequirement.all | ||
| end | ||
|
|
||
| # GET /appointment_requirements/1 or /appointment_requirements/1.json | ||
| def show | ||
| end | ||
|
|
||
| # GET /appointment_requirements/new | ||
| def new | ||
| @appointment_requirement = AppointmentRequirement.new | ||
| end | ||
|
|
||
| # GET /appointment_requirements/1/edit | ||
| def edit | ||
| end | ||
|
|
||
| # POST /appointment_requirements or /appointment_requirements.json | ||
| def create | ||
| @appointment_requirement = AppointmentRequirement.new(appointment_requirement_params) | ||
|
|
||
| respond_to do |format| | ||
| if @appointment_requirement.save | ||
| format.html { redirect_to @appointment_requirement, notice: "Appointment requirement was successfully created." } | ||
| format.json { render :show, status: :created, location: @appointment_requirement } | ||
| else | ||
| format.html { render :new, status: :unprocessable_content } | ||
| format.json { render json: @appointment_requirement.errors, status: :unprocessable_content } | ||
| end | ||
| end | ||
| end | ||
|
|
||
| # PATCH/PUT /appointment_requirements/1 or /appointment_requirements/1.json | ||
| def update | ||
| respond_to do |format| | ||
| if @appointment_requirement.update(appointment_requirement_params) | ||
| format.html { redirect_to @appointment_requirement, notice: "Appointment requirement was successfully updated.", status: :see_other } | ||
| format.json { render :show, status: :ok, location: @appointment_requirement } | ||
| else | ||
| format.html { render :edit, status: :unprocessable_content } | ||
| format.json { render json: @appointment_requirement.errors, status: :unprocessable_content } | ||
| end | ||
| end | ||
| end | ||
|
|
||
| # DELETE /appointment_requirements/1 or /appointment_requirements/1.json | ||
| def destroy | ||
| @appointment_requirement.destroy! | ||
|
|
||
| respond_to do |format| | ||
| format.html { redirect_to appointment_requirements_path, notice: "Appointment requirement was successfully destroyed.", status: :see_other } | ||
| format.json { head :no_content } | ||
| end | ||
| end | ||
|
|
||
| private | ||
| # Use callbacks to share common setup or constraints between actions. | ||
| def set_appointment_requirement | ||
| @appointment_requirement = AppointmentRequirement.find(params.expect(:id)) | ||
| end | ||
|
|
||
| # Only allow a list of trusted parameters through. | ||
| def appointment_requirement_params | ||
| params.expect(appointment_requirement: [ :name ]) | ||
| end | ||
| end |
This file contains hidden or 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 AppointmentRequirementsHelper | ||
| end |
This file contains hidden or 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,3 @@ | ||
| class AppointmentRequirement < ApplicationRecord | ||
| validates :name, presence: true | ||
| end | ||
7 changes: 7 additions & 0 deletions
7
app/views/appointment_requirements/_appointment_requirement.html.erb
This file contains hidden or 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 @@ | ||
| <div id="<%= dom_id appointment_requirement %>"> | ||
| <div> | ||
| <strong>Name:</strong> | ||
| <%= appointment_requirement.name %> | ||
| </div> | ||
|
|
||
| </div> |
2 changes: 2 additions & 0 deletions
2
app/views/appointment_requirements/_appointment_requirement.json.jbuilder
This file contains hidden or 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! appointment_requirement, :id, :name, :created_at, :updated_at | ||
| json.url appointment_requirement_url(appointment_requirement, format: :json) |
This file contains hidden or 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,22 @@ | ||
| <%= form_with(model: appointment_requirement) do |form| %> | ||
| <% if appointment_requirement.errors.any? %> | ||
| <div style="color: red"> | ||
| <h2><%= pluralize(appointment_requirement.errors.count, "error") %> prohibited this appointment_requirement from being saved:</h2> | ||
|
|
||
| <ul> | ||
| <% appointment_requirement.errors.each do |error| %> | ||
| <li><%= error.full_message %></li> | ||
| <% end %> | ||
| </ul> | ||
| </div> | ||
| <% end %> | ||
|
|
||
| <div> | ||
| <%= form.label :name, style: "display: block" %> | ||
| <%= form.text_field :name %> | ||
| </div> | ||
|
|
||
| <div> | ||
| <%= form.submit %> | ||
| </div> | ||
| <% end %> |
This file contains hidden or 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 @@ | ||
| <% content_for :title, "Editing appointment requirement" %> | ||
|
|
||
| <h1>Editing appointment requirement</h1> | ||
|
|
||
| <%= render "form", appointment_requirement: @appointment_requirement %> | ||
|
|
||
| <br> | ||
|
|
||
| <div> | ||
| <%= link_to "Show this appointment requirement", @appointment_requirement %> | | ||
| <%= link_to "Back to appointment requirements", appointment_requirements_path %> | ||
| </div> |
This file contains hidden or 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,17 @@ | ||
| <p style="color: green"><%= notice %></p> | ||
|
|
||
| <% content_for :title, "Appointment requirements" %> | ||
|
|
||
| <h1>Appointment requirements</h1> | ||
|
|
||
| <div id="appointment_requirements"> | ||
|
|
||
| <% @appointment_requirements.each do |appointment_requirement| %> | ||
| <%= render appointment_requirement %> | ||
| <p> | ||
| <%= link_to "Show this appointment requirement", appointment_requirement %> | ||
| </p> | ||
| <% end %> | ||
| </div> | ||
|
|
||
| <%= link_to "New appointment requirement", new_appointment_requirement_path %> |
This file contains hidden or 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! @appointment_requirements, partial: "appointment_requirements/appointment_requirement", as: :appointment_requirement |
This file contains hidden or 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 @@ | ||
| <% content_for :title, "New appointment requirement" %> | ||
|
|
||
| <h1>New appointment requirement</h1> | ||
|
|
||
| <%= render "form", appointment_requirement: @appointment_requirement %> | ||
|
|
||
| <br> | ||
|
|
||
| <div> | ||
| <%= link_to "Back to appointment requirements", appointment_requirements_path %> | ||
| </div> |
This file contains hidden or 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 @appointment_requirement %> | ||
|
|
||
| <div> | ||
| <%= link_to "Edit this appointment requirement", edit_appointment_requirement_path(@appointment_requirement) %> | | ||
| <%= link_to "Back to appointment requirements", appointment_requirements_path %> | ||
|
|
||
| <%= button_to "Destroy this appointment requirement", @appointment_requirement, method: :delete %> | ||
| </div> |
This file contains hidden or 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! "appointment_requirements/appointment_requirement", appointment_requirement: @appointment_requirement |
This file contains hidden or 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
This file contains hidden or 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 @@ | ||
| class CreateAppointmentRequirements < ActiveRecord::Migration[8.1] | ||
| def change | ||
| create_table :appointment_requirements do |t| | ||
| t.string :name | ||
|
|
||
| t.timestamps | ||
| end | ||
| end | ||
| end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
48 changes: 48 additions & 0 deletions
48
test/controllers/appointment_requirements_controller_test.rb
This file contains hidden or 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 AppointmentRequirementsControllerTest < ActionDispatch::IntegrationTest | ||
| setup do | ||
| @appointment_requirement = appointment_requirements(:one) | ||
| end | ||
|
|
||
| test "should get index" do | ||
| get appointment_requirements_url | ||
| assert_response :success | ||
| end | ||
|
|
||
| test "should get new" do | ||
| get new_appointment_requirement_url | ||
| assert_response :success | ||
| end | ||
|
|
||
| test "should create appointment_requirement" do | ||
| assert_difference("AppointmentRequirement.count") do | ||
| post appointment_requirements_url, params: { appointment_requirement: { name: @appointment_requirement.name } } | ||
| end | ||
|
|
||
| assert_redirected_to appointment_requirement_url(AppointmentRequirement.last) | ||
| end | ||
|
|
||
| test "should show appointment_requirement" do | ||
| get appointment_requirement_url(@appointment_requirement) | ||
| assert_response :success | ||
| end | ||
|
|
||
| test "should get edit" do | ||
| get edit_appointment_requirement_url(@appointment_requirement) | ||
| assert_response :success | ||
| end | ||
|
|
||
| test "should update appointment_requirement" do | ||
| patch appointment_requirement_url(@appointment_requirement), params: { appointment_requirement: { name: @appointment_requirement.name } } | ||
| assert_redirected_to appointment_requirement_url(@appointment_requirement) | ||
| end | ||
|
|
||
| test "should destroy appointment_requirement" do | ||
| assert_difference("AppointmentRequirement.count", -1) do | ||
| delete appointment_requirement_url(@appointment_requirement) | ||
| end | ||
|
|
||
| assert_redirected_to appointment_requirements_url | ||
| end | ||
| end |
This file contains hidden or 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 @@ | ||
| # Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html | ||
|
|
||
| one: | ||
| name: MyString | ||
|
|
||
| two: | ||
| name: MyString |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.