This repository has been archived by the owner on Oct 1, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #379 from CDCgov/help-page-admin-update
[SDPV-31] Help page update, admin panel changes
- Loading branch information
Showing
18 changed files
with
332 additions
and
41 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 |
---|---|---|
@@ -1,5 +1,24 @@ | ||
class SurveillanceProgramsController < ApplicationController | ||
authorize_resource only: [:create] | ||
|
||
def index | ||
render json: SurveillanceProgram.all | ||
end | ||
|
||
def create | ||
@surveillance_program = SurveillanceProgram.new(surveillance_program_params) | ||
if SurveillanceProgram.find_by(name: @surveillance_program.name) | ||
render json: { msg: "A surveillance program named #{@surveillance_program.name} already exists" }, status: :unprocessable_entity | ||
elsif @surveillance_program.save | ||
render json: SurveillanceProgram.all | ||
else | ||
render json: { msg: 'Error saving program - check format, name cannot be blank' }, status: :unprocessable_entity | ||
end | ||
end | ||
|
||
private | ||
|
||
def surveillance_program_params | ||
params.permit(:name, :description, :acronym) | ||
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 |
---|---|---|
@@ -1,5 +1,24 @@ | ||
class SurveillanceSystemsController < ApplicationController | ||
authorize_resource only: [:create] | ||
|
||
def index | ||
render json: SurveillanceSystem.all | ||
end | ||
|
||
def create | ||
@surveillance_system = SurveillanceSystem.new(surveillance_system_params) | ||
if SurveillanceSystem.find_by(name: @surveillance_system.name) | ||
render json: { msg: "A surveillance system named #{@surveillance_system.name} already exists" }, status: :unprocessable_entity | ||
elsif @surveillance_system.save | ||
render json: SurveillanceSystem.all | ||
else | ||
render json: { msg: 'Error saving system - check format, name cannot be blank' }, status: :unprocessable_entity | ||
end | ||
end | ||
|
||
private | ||
|
||
def surveillance_system_params | ||
params.permit(:name, :description, :acronym) | ||
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
class SurveillanceProgram < ApplicationRecord | ||
has_many :surveys | ||
validates :name, presence: true | ||
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
class SurveillanceSystem < ApplicationRecord | ||
has_many :surveys | ||
validates :name, presence: true | ||
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
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 |
---|---|---|
|
@@ -30,3 +30,38 @@ Feature: Admin Panel | |
And I should see "[email protected]" | ||
When I click on the "[email protected]" button | ||
Then I should not see "[email protected]" | ||
|
||
Scenario: Add program | ||
Given I am the admin test_author@gmail.com | ||
And there is an admin with the email admin@gmail.com | ||
When I go to the dashboard | ||
And I click on the "account-dropdown" link | ||
And I click on the "Admin Panel" link | ||
And I click on the "Program List" link | ||
And I fill in the "program-name" field with "New Program" | ||
And I click on the "submit-prog-sys" button | ||
And I fill in the "program-name" field with "Just clearing the text" | ||
Then I should see "New Program" | ||
|
||
Scenario: Add System | ||
Given I am the admin test_author@gmail.com | ||
And there is an admin with the email admin@gmail.com | ||
When I go to the dashboard | ||
And I click on the "account-dropdown" link | ||
And I click on the "Admin Panel" link | ||
And I click on the "System List" link | ||
And I fill in the "system-name" field with "New System" | ||
And I click on the "submit-prog-sys" button | ||
And I fill in the "system-name" field with "Just clearing the text" | ||
Then I should see "New System" | ||
|
||
Scenario: Add System with name error | ||
Given I am the admin test_author@gmail.com | ||
And there is an admin with the email admin@gmail.com | ||
When I go to the dashboard | ||
And I click on the "account-dropdown" link | ||
And I click on the "Admin Panel" link | ||
And I click on the "System List" link | ||
And I fill in the "system-description" field with "Trying to add system with no name" | ||
And I click on the "submit-prog-sys" button | ||
Then I should see "Error saving system - check format, name cannot be blank" |
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,8 +1,24 @@ | ||
require 'test_helper' | ||
|
||
class SurveillanceProgramsControllerTest < ActionDispatch::IntegrationTest | ||
include Devise::Test::IntegrationHelpers | ||
|
||
test 'should get index' do | ||
get surveillance_programs_url | ||
assert_response :success | ||
end | ||
|
||
test 'should not be allowed to create program' do | ||
post surveillance_programs_url, params: { name: 'test prog' } | ||
assert_response :forbidden | ||
end | ||
|
||
test 'should be allowed to create program' do | ||
@admin = users(:admin) | ||
@admin.add_role :admin | ||
@admin.save! | ||
sign_in @admin | ||
post surveillance_programs_url, params: { name: 'test prog' } | ||
assert_response :success | ||
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 |
---|---|---|
@@ -1,8 +1,24 @@ | ||
require 'test_helper' | ||
|
||
class SurveillanceSystemsControllerTest < ActionDispatch::IntegrationTest | ||
include Devise::Test::IntegrationHelpers | ||
|
||
test 'should get index' do | ||
get surveillance_systems_url | ||
assert_response :success | ||
end | ||
|
||
test 'should not be allowed to create system' do | ||
post surveillance_systems_url, params: { name: 'test sys' } | ||
assert_response :forbidden | ||
end | ||
|
||
test 'should be allowed to create system' do | ||
@admin = users(:admin) | ||
@admin.add_role :admin | ||
@admin.save! | ||
sign_in @admin | ||
post surveillance_systems_url, params: { name: 'test sys' } | ||
assert_response :success | ||
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
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
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
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
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
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
Oops, something went wrong.