Skip to content

Commit

Permalink
report_period testing
Browse files Browse the repository at this point in the history
  • Loading branch information
kjgarza committed May 15, 2018
1 parent 694d567 commit 62cf1c6
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 9 deletions.
2 changes: 1 addition & 1 deletion spec/concerns/helpeable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
it "has correct country counts format" do
y = params.attributes["report_datasets"].first["performance"].first["instance"].first
x = ReportsController.permit_recursive_params y
expect(x).to eq(["country", "access-method", "metric-type", "count"])
expect(x).to eq(["access-method", "metric-type", "count"])
end
end
end
Expand Down
3 changes: 1 addition & 2 deletions spec/factories/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
provider_id "datacite"
sequence(:created_by) { |n| "datacite#{n}" }
created "2020-03-02"
reporting_period "begin_date": "2018-03-01", "end_date": "2018-03-31"
report_filters []
report_attributes []
report_datasets [{
Expand All @@ -30,13 +31,11 @@
},
"instance": [
{
"country": "gb",
"access-method": "regular",
"metric-type": "total-dataset-investigations",
"count": 3
},
{
"country": "gb",
"access-method": "regular",
"metric-type": "unique-dataset-investigations",
"count": 3
Expand Down
4 changes: 4 additions & 0 deletions spec/fixtures/files/report_1.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
"report_id": "DSR",
"created_by": "DataONE",
"created": "2022-01-01",
"reporting-period": {
"begin-date": "2022-01-01",
"end-date": "2022-01-0"
},
"report_datasets": [{
"yop": "2010",
"platform": "DataONE",
Expand Down
4 changes: 4 additions & 0 deletions spec/fixtures/files/report_2.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
"report_id": "DSR",
"created_by": "CDL",
"created": "2015-01-01",
"reporting-period": {
"begin-date": "2015-01-01",
"end-date": "2015-01-0"
},
"report_datasets": [{
"yop": "2010",
"platform": "DataONE",
Expand Down
4 changes: 4 additions & 0 deletions spec/fixtures/files/report_3.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
"release": "rd1",
"created": "2128-04-09",
"created-by": "dash",
"reporting-period": {
"begin-date": "2128-04-09",
"end-date": "2128-04-09"
},
"report-attributes": [],
"report-filters": [
{
Expand Down
4 changes: 4 additions & 0 deletions spec/fixtures/files/report_4.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
"report-id": "DSR",
"release": "rd1",
"created": "2128-04-09",
"reporting-period": {
"end-date": "2128-04-09",
"begin-date": "2128-04-09"
},
"created-by": "dash",
"report-filters": [
{
Expand Down
4 changes: 4 additions & 0 deletions spec/fixtures/files/report_5.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
"report-id": "DSR",
"release": "rd1",
"created": "2128-04-09",
"reporting_period": {
"end_date": "2128-04-09",
"begin_date": "2128-04-09"
},
"created-by": "dash",
"report-filters": [
{
Expand Down
4 changes: 4 additions & 0 deletions spec/fixtures/files/report_6.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
"report-id": "DSR",
"release": "rd1",
"created": "2128-04-09",
"reporting_period": {
"end_date": "2128-04-09",
"begin_date": "2128-04-09"
},
"created-by": "dash",
"report-attributes": [],
"report-filters": [
Expand Down
14 changes: 9 additions & 5 deletions spec/fixtures/files/report_7.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
{
"report-header": {
"report-name": "dataset report",
"report-id": "DSR",
"report-id": "FULL",
"release": "rd1",
"created": "2018-05-11",
"reporting_period": {
"begin_date": "2128-05-09",
"end_date": "2128-05-09"
},
"created-by": "Dash",
"report-attributes": [],
"report-filters": [
Expand Down Expand Up @@ -13844,7 +13848,7 @@
"metric-type": "total-dataset-investigations",
"count": 41,
"country-counts": {
"": 3,
"US": 3,
"DE": 2,
"DK": 1,
"US": 35
Expand All @@ -13855,7 +13859,7 @@
"metric-type": "unique-dataset-investigations",
"count": 32,
"country-counts": {
"": 3,
"US": 3,
"DE": 2,
"DK": 1,
"US": 26
Expand Down Expand Up @@ -23066,7 +23070,7 @@
"metric-type": "total-dataset-requests",
"count": 1223,
"country-counts": {
"": 1,
"US": 1,
"AU": 556,
"CA": 17,
"DK": 55,
Expand All @@ -23079,7 +23083,7 @@
"metric-type": "unique-dataset-requests",
"count": 40,
"country-counts": {
"": 1,
"US": 1,
"AU": 9,
"CA": 6,
"DK": 3,
Expand Down
24 changes: 23 additions & 1 deletion spec/requests/reports_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
end
end
context 'index filter by year' do
let!(:report) { create(:report, created:"2222-01-01") }
let!(:report) { create(:report, reporting_period:{"begin_date":"2222-01-01"}) }
before { get '/reports?year=2222'}

it 'returns reports' do
Expand Down Expand Up @@ -96,6 +96,10 @@
"report_name": "Dataset Report",
"report_id": "DSR",
"created": "2018-01-01",
"reporting-period": {
"begin-date": "2018-01-01",
"end-date": "2022-01-01"
},
"report-filters": [],
"report-attributes": [],
"exceptions": [
Expand Down Expand Up @@ -188,6 +192,16 @@
expect(response).to have_http_status(422)
end
end

context 'when the request is valid and has many countries' do
let(:params_countries) {file_fixture('report_7.json').read}
before { post '/reports', params: params_countries, headers: headers }

it 'creates a report' do
expect(response).to have_http_status(201)
expect(json.dig("report", "report-header", "report-id")).to eq("FULL")
end
end
end


Expand All @@ -200,6 +214,10 @@
"report_name": "Dataset Report",
"report_id": "DSR",
"created": "2018-01-01",
"reporting-period": {
"begin-date": "2018-01-01",
"end-date": "2022-01-01"
},
"created_by": "CDL",
"report-filters": [],
"report-attributes": [],
Expand Down Expand Up @@ -261,6 +279,10 @@
{ "report_heasder": {
"report_name": "Dataset Report",
"created": "2018-01-01",
"reporting-period": {
"begin-date": "2018-01-01",
"end-date": "2022-01-01"
},
"report_id": "DSR",
},
"report_datasets": [
Expand Down

0 comments on commit 62cf1c6

Please sign in to comment.