-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
242 additions
and
89 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
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
9 changes: 9 additions & 0 deletions
9
...generators/geoblacklight_admin/templates/btaa_sample_document_data_dictionary_entries.csv
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 @@ | ||
friendlier_id,field_name,field_type,values,definition,definition_source,parent_field_name | ||
35c8a641589c4e13b7aa11e37f3f00a1_0,AREA,Real,6,Area of polygon,Software generated, | ||
35c8a641589c4e13b7aa11e37f3f00a1_0,PERIMETER,Real,6,Perimeter of polygon,Software generated, | ||
35c8a641589c4e13b7aa11e37f3f00a1_0,NAME_U,String,10,County names in upper case letters,USGS 7.5-minute quadrangles, | ||
35c8a641589c4e13b7aa11e37f3f00a1_0,NAME_L,String,10,County names in upper and lower case letters,IGS standard, | ||
35c8a641589c4e13b7aa11e37f3f00a1_0,NCAPC,Integer,2,Numeric county alphabetic prefix code,Indiana Bureau of Motor Vehicles, | ||
35c8a641589c4e13b7aa11e37f3f00a1_0,Subtable A,String,A,Definition,Definition source,PERIMETER | ||
35c8a641589c4e13b7aa11e37f3f00a1_0,Subtable B,String,B,Definition,Definition Source,PERIMETER | ||
35c8a641589c4e13b7aa11e37f3f00a1_0,Subtable C,String,C,Definition,Definition Source,PERIMETER |
97 changes: 97 additions & 0 deletions
97
test/controllers/document_data_dictionaries_controller_test.rb
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,97 @@ | ||
require "test_helper" | ||
|
||
class DocumentDataDictionariesControllerTest < ActionDispatch::IntegrationTest | ||
setup do | ||
@document = documents(:ag) | ||
@document_data_dictionary = document_data_dictionaries(:one) | ||
@file = fixture_file_upload("btaa_sample_document_data_dictionary_entries.csv", "text/csv") | ||
|
||
get "/users/sign_in" | ||
sign_in_as users(:user_001) | ||
post user_session_url | ||
|
||
follow_redirect! | ||
assert_response :success | ||
end | ||
|
||
test "should get index" do | ||
get admin_document_document_data_dictionaries_url(@document) | ||
assert_response :success | ||
end | ||
|
||
test "should get new" do | ||
get new_admin_document_document_data_dictionary_url(@document) | ||
assert_response :success | ||
end | ||
|
||
test "should create document_data_dictionary" do | ||
skip("@TODO: add file upload to test") | ||
assert_difference("DocumentDataDictionary.count") do | ||
post admin_document_document_data_dictionaries_url(@document), params: { | ||
document_data_dictionary: { | ||
friendlier_id: "35c8a641589c4e13b7aa11e37f3f00a1_0", | ||
name: "Created Dictionary", | ||
description: "Created Description", | ||
staff_notes: "Created Staff Notes", | ||
tags: "tag1,tag2,tag3", | ||
csv_file: @file | ||
} | ||
} | ||
end | ||
|
||
assert_redirected_to admin_document_document_data_dictionaries_url(@document) | ||
end | ||
|
||
test "should show document_data_dictionary" do | ||
get admin_document_document_data_dictionary_url(@document, @document_data_dictionary) | ||
assert_response :success | ||
end | ||
|
||
test "should get edit" do | ||
get edit_admin_document_document_data_dictionary_url(@document, @document_data_dictionary) | ||
assert_response :success | ||
end | ||
|
||
test "should update document_data_dictionary" do | ||
skip("@TODO: add file upload to test") | ||
patch admin_document_document_data_dictionary_url(@document, @document_data_dictionary), params: { | ||
document_data_dictionary: { | ||
friendlier_id: "35c8a641589c4e13b7aa11e37f3f00a1_0", | ||
name: "Updated Dictionary", | ||
description: "Updated Description", | ||
staff_notes: "Updated Staff Notes", | ||
tags: "tag1,tag2,tag3", | ||
csv_file: @file | ||
} | ||
} | ||
assert_redirected_to admin_document_document_data_dictionaries_url(@document) | ||
end | ||
|
||
test "should destroy document_data_dictionary" do | ||
assert_difference("DocumentDataDictionary.count", -1) do | ||
delete admin_document_document_data_dictionary_url(@document, @document_data_dictionary) | ||
end | ||
|
||
assert_redirected_to admin_document_document_data_dictionaries_url(@document) | ||
end | ||
|
||
test "should import data dictionary successfully" do | ||
skip("@TODO: add file upload to test") | ||
post import_admin_document_document_data_dictionaries_url(@document), params: { | ||
document_id: @document.friendlier_id, | ||
document_data_dictionary: { | ||
data_dictionary: { | ||
file: @file | ||
} | ||
} | ||
} | ||
assert_redirected_to admin_document_document_data_dictionaries_path(@document) | ||
assert_equal "Data dictionary was created successfully.", flash[:notice] | ||
end | ||
|
||
test "should not import data dictionary with invalid file" do | ||
post import_admin_document_document_data_dictionaries_url(@document), params: {document_id: @document.friendlier_id, document_data_dictionary: {data_dictionary: {file: nil}}} | ||
assert_redirected_to admin_document_document_data_dictionaries_path(@document) | ||
assert_equal "Data dictionaries could not be created. File does not exist or is invalid.", flash[:notice] | ||
end | ||
end |
79 changes: 0 additions & 79 deletions
79
test/controllers/document_data_dictionary_controller_test.rb
This file was deleted.
Oops, something went wrong.
113 changes: 113 additions & 0 deletions
113
test/controllers/document_data_dictionary_entries_controller_test.rb
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,113 @@ | ||
# frozen_string_literal: true | ||
|
||
require "test_helper" | ||
|
||
module Admin | ||
class DocumentDataDictionaryEntriesControllerTest < ActionDispatch::IntegrationTest | ||
include Devise::Test::IntegrationHelpers | ||
|
||
setup do | ||
@document = documents(:ag) | ||
@document_data_dictionary = document_data_dictionaries(:one) | ||
@document_data_dictionary_entry = document_data_dictionary_entries(:one) | ||
|
||
get "/users/sign_in" | ||
sign_in_as users(:user_001) | ||
post user_session_url | ||
|
||
follow_redirect! | ||
assert_response :success | ||
end | ||
|
||
test "should get new" do | ||
get new_admin_document_document_data_dictionary_document_data_dictionary_entry_url( | ||
@document, | ||
@document_data_dictionary | ||
) | ||
assert_response :success | ||
end | ||
|
||
test "should create document_data_dictionary_entry" do | ||
assert_difference("DocumentDataDictionaryEntry.count") do | ||
post admin_document_document_data_dictionary_document_data_dictionary_entries_url( | ||
@document, | ||
@document_data_dictionary | ||
), params: { | ||
document_data_dictionary_entry: { | ||
document_data_dictionary_id: @document_data_dictionary.id, | ||
friendlier_id: @document.friendlier_id, | ||
field_name: "test_field", | ||
field_type: "string", | ||
values: "test_values", | ||
definition: "Test definition" | ||
} | ||
} | ||
end | ||
|
||
assert_redirected_to admin_document_document_data_dictionary_path(@document, @document_data_dictionary) | ||
end | ||
|
||
test "should get edit" do | ||
get edit_admin_document_document_data_dictionary_document_data_dictionary_entry_url( | ||
@document, | ||
@document_data_dictionary, | ||
@document_data_dictionary_entry | ||
) | ||
assert_response :success | ||
end | ||
|
||
test "should update document_data_dictionary_entry" do | ||
patch admin_document_document_data_dictionary_document_data_dictionary_entry_url( | ||
@document, | ||
@document_data_dictionary, | ||
@document_data_dictionary_entry | ||
), params: { | ||
document_data_dictionary_entry: { | ||
friendlier_id: @document.friendlier_id, | ||
field_name: "updated_field", | ||
field_type: "string", | ||
values: "updated_values" | ||
} | ||
} | ||
assert_redirected_to admin_document_document_data_dictionary_path(@document, @document_data_dictionary) | ||
end | ||
|
||
test "should destroy document_data_dictionary_entry" do | ||
assert_difference("DocumentDataDictionaryEntry.count", -1) do | ||
delete admin_document_document_data_dictionary_document_data_dictionary_entry_url( | ||
@document, | ||
@document_data_dictionary, | ||
@document_data_dictionary_entry | ||
) | ||
end | ||
|
||
assert_redirected_to admin_document_document_data_dictionary_path(@document, @document_data_dictionary) | ||
end | ||
|
||
test "should destroy all entries" do | ||
assert_difference("DocumentDataDictionaryEntry.count", -DocumentDataDictionaryEntry.count) do | ||
post destroy_all_admin_document_document_data_dictionary_document_data_dictionary_entries_path( | ||
@document, | ||
@document_data_dictionary | ||
) | ||
end | ||
|
||
assert_redirected_to admin_document_document_data_dictionary_document_data_dictionary_entries_path( | ||
@document_data_dictionary.friendlier_id, | ||
@document_data_dictionary | ||
) | ||
end | ||
|
||
test "should sort entries" do | ||
entry1 = document_data_dictionary_entries(:one) | ||
entry2 = document_data_dictionary_entries(:two) | ||
|
||
post sort_admin_document_document_data_dictionary_document_data_dictionary_entries_url( | ||
@document, | ||
@document_data_dictionary | ||
), params: { id_list: [entry2.id, entry1.id] } | ||
|
||
assert_response :success | ||
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,7 @@ | ||
one: | ||
friendlier_id: 35c8a641589c4e13b7aa11e37f3f00a1_0 | ||
name: Sample Dictionary | ||
description: Description | ||
staff_notes: Staff notes | ||
tags: tag1,tag2,tag3 | ||
position: 1 |
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,13 @@ | ||
one: | ||
document_data_dictionary: one | ||
field_name: "field_one" | ||
field_type: "string" | ||
definition: "First test field" | ||
position: 1 | ||
|
||
two: | ||
document_data_dictionary: one | ||
field_name: "field_two" | ||
field_type: "string" | ||
definition: "Second test field" | ||
position: 2 |