Skip to content

Commit

Permalink
Merge pull request #4 from angiecstn/rsc_hospital_index
Browse files Browse the repository at this point in the history
RSC Can See List of Hospitals
  • Loading branch information
RhonGabriel committed Nov 2, 2018
2 parents 20ec1e4 + f40e77c commit d7e0a51
Show file tree
Hide file tree
Showing 15 changed files with 168 additions and 24 deletions.
5 changes: 5 additions & 0 deletions app/controllers/hospitals_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class HospitalsController < ApplicationController
def index
@hospitals = Hospital.all
end
end
53 changes: 50 additions & 3 deletions app/javascript/css/tailwind.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,55 @@

@tailwind utilities;

.card {
@apply w-full flex items-center justify-center bg-teal-lightest font-sans;
}

.inner-card {
@apply bg-white rounded shadow p-6 m-4 w-full;
}


.card-title {
@apply mb-4 text-grey-darkest;
}

.add-field {
@apply flex mb-4;
}

#list-item {
@apply flex mb-4 items-center;
}

#hosp-name {
@apply text-left w-full text-grey-darkest;
}

#hosp-button {
@apply text-right;
}

.add-field-placeholder {
@apply shadow appearance-none border rounded w-full py-2 px-3 mr-4 text-grey-darker;
}

.button {
@apply flex-no-shrink p-2 border-2 rounded text-teal border-teal;
}

.button:hover {
@apply text-white bg-teal ;
}

.grid-container {
display: grid;
height: 90vh;
grid-template-columns: 0.2fr 0.9fr 0.3fr;
grid-template-rows: 1fr;
grid-template-areas: "sidebar jobs shifts";
}

#header {
display: grid;
height: 15vh;
Expand All @@ -34,7 +75,7 @@
list-style-type: none;
}
}

#jobs {
grid-area: jobs;
h1{
Expand Down Expand Up @@ -64,5 +105,11 @@
}

.zdh-button {
@apply py-2 px-4 bg-blue text-white text-center my-4 mx-4 align-middle no-underline rounded ;
@apply py-2 px-4 bg-blue text-white text-center my-4 mx-4 align-middle no-underline rounded;
}

@screen lg {
.inner-card {
@apply max-w-lg;
}
}
3 changes: 3 additions & 0 deletions app/models/hospital.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Hospital < ApplicationRecord
validates_presence_of :name
end
13 changes: 13 additions & 0 deletions app/views/hospitals/index.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.card
.inner-card
.card-title
%h1 Hospitals
#list-item.flex
- @hospitals.each do |hospital|
#hospname
%p= hospital.name
#hosp-button
%button.button Remove
.add-field
%input.add-field-placeholder{placeholder: "Add Hospitals"}
%button.button Add
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Rails.application.routes.draw do
root controller: :jobs, action: :index
resources :hospitals, only: :index
scope '(:locale)', locale: /en|sv/ do
end
end
9 changes: 9 additions & 0 deletions db/migrate/20181101101117_create_hospitals.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class CreateHospitals < ActiveRecord::Migration[5.2]
def change
create_table :hospitals do |t|
t.string :name

t.timestamps
end
end
end
8 changes: 7 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,15 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 0) do
ActiveRecord::Schema.define(version: 2018_11_01_101117) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"

create_table "hospitals", force: :cascade do |t|
t.string "name"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end

end
15 changes: 8 additions & 7 deletions db/seeds.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Character.create(name: 'Luke', movie: movies.first)
Hospital.destroy_all

Hospital.create!(name: "Karolinska")
Hospital.create!(name: "Södersjukhuset")
Hospital.create!(name: "Martina Children's Hospital")
Hospital.create!(name: "Stockholms Sjukhem")
Hospital.create!(name: "GHP Arytmi Center Stockholm")

13 changes: 6 additions & 7 deletions features/rsc_can_see_a_dashboard.feature
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@ Feature: RSC Dashboard
Scenario: RSC can see the dashboard
Given I am on the dashboard page
Then I should see "RSC Dashboard"
And I should see "Jobs" within the "sidebar" section
And I should see "Hospitals" within the "sidebar" section
And I should see "Staffing Companies" within the "sidebar" section
And I should see "Jobs" within the "#sidebar" section
And I should see "Hospitals" within the "#sidebar" section
And I should see "Staffing Companies" within the "#sidebar" section
And I should see "Job 1"

Scenario: RSC can see the dashboard in swedish
Given I am on the dashboard page
Then I should see "RSC Dashboard"
And I click the "Svenska" link
Then I should see "Jobb" within the "sidebar" section
And I should see "Sjukhus" within the "sidebar" section
And I should see "Bemanningsföretag" within the "sidebar" section

Then I should see "Jobb" within the "#sidebar" section
And I should see "Sjukhus" within the "#sidebar" section
And I should see "Bemanningsföretag" within the "#sidebar" section
19 changes: 19 additions & 0 deletions features/rsc_can_see_list_of_hospitals.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@javascript
Feature: RSC Can See List of Hospitals
As an RSC,
In order to know what hospitals I have associations with,
I would like to be able to see a list of hospitals in my region.

Background:
Given the following hospitals exists
| name |
| Hospital 1 |
| Hospital 2 |

Scenario:
Given I am on the hospital page
Then I should see "Hospital 1" within the ".card" section
And I should not see "Hospital 3" within the ".card" section



18 changes: 17 additions & 1 deletion features/step_definitions/assertion_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,20 @@

Then("I click the {string} link") do |link|
click_link link
end
end

When("I click on the link {string}") do |button|
click_on button
end

Then("I should see {string} within the {string} section") do |content, section|
within("#{section}") {
expect(page).to have_content content
}
end

Then("I should not see {string} within the {string} section") do |content, section|
within("#{section}") {
expect(page).not_to have_content content
}
end
8 changes: 3 additions & 5 deletions features/step_definitions/basic_steps.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
Then("I should see {string} within the {string} section") do |content, section|
within("##{section}") {
expect(page).to have_content content
}
end
Given("I am on the hospital page") do
visit hospitals_path
end
5 changes: 5 additions & 0 deletions features/step_definitions/new_object_steps.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Given("the following hospitals exists") do |table|
table.hashes.each do |hospital|
create(:hospital, hospital)
end
end
5 changes: 5 additions & 0 deletions spec/factories/hospitals.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FactoryBot.define do
factory :hospital do
name { "MyString" }
end
end
17 changes: 17 additions & 0 deletions spec/models/hospital_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
require 'rails_helper'

RSpec.describe Hospital, type: :model do
describe 'DB table' do
it { is_expected.to have_db_column :name }
end

describe 'Validations' do
it { is_expected.to validate_presence_of :name }
end

describe 'Factory' do
it 'should have valid Factory' do
expect(create(:hospital)).to be_valid
end
end
end

0 comments on commit d7e0a51

Please sign in to comment.