-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
In this PR I change how the accepted_at is used. It was in a weird place because right now the owner could create a request that has it set automatically. So basically the code was not really used. I now use it to let the owner approve the requests made through IRIS. This also made it possible to remove the dead code :) references [#125](railslove/recover-backlog#125)
- Loading branch information
Showing
19 changed files
with
201 additions
and
33 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 +1,2 @@ | ||
STRIPE_SUBSCRIPTION_PRICE_ID=test_price | ||
HAPPY_PDF_API_KEY=HAPPY_KEY |
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 @@ | ||
module Owners | ||
class AcceptDataRequestsController < Owners::ApplicationController | ||
def update | ||
data_request = current_owner.data_requests.find(params[:unaccepted_data_request_id]) | ||
result = AcceptDataRequest.call(data_request: data_request) | ||
render json: result.data_request, include: { tickets: { methods: [:encrypted_data, :area_name, :encrypted_data_change_history] } } | ||
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
15 changes: 15 additions & 0 deletions
15
app/controllers/owners/unaccepted_data_requests_controller.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,15 @@ | ||
module Owners | ||
class UnacceptedDataRequestsController < Owners::ApplicationController | ||
|
||
def index | ||
render json: company.data_requests.unaccepted | ||
end | ||
|
||
private | ||
|
||
def company | ||
current_owner.companies.find(params[:company_id]) | ||
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,13 @@ | ||
class AcceptDataRequest | ||
include Interactor | ||
include RequiredAttributes | ||
|
||
required_attributes %i[data_request] | ||
|
||
def call | ||
if (!data_request.accepted?) | ||
data_request.accept! | ||
end | ||
context.data_request = data_request | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class AddIrisFieldsToDataRequest < ActiveRecord::Migration[6.1] | ||
def change | ||
add_column :data_requests, :iris_submission_url, :string | ||
add_column :data_requests, :iris_health_department, :text | ||
add_column :data_requests, :iris_key_of_health_department, :text | ||
add_column :data_requests, :iris_key_reference, :text | ||
add_index :data_requests, :accepted_at | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe Owners::AcceptDataRequestsController do | ||
include_context 'api request authentication' | ||
|
||
let(:owner) { FactoryBot.create(:owner) } | ||
let(:company) { FactoryBot.create(:company, owner: owner) } | ||
let(:other_company) { FactoryBot.create(:company, owner: owner) } | ||
let(:area) { FactoryBot.create(:area, company: company) } | ||
|
||
before do | ||
sign_in(owner) | ||
end | ||
|
||
context "PATCH accepted_data_request update" do | ||
let!(:data_request) do | ||
FactoryBot.create(:ticket, area: area, encrypted_data: "data", entered_at: Time.zone.now.yesterday - 2.hours, left_at: Time.zone.now.yesterday - 1.hour) | ||
FactoryBot.create(:data_request, | ||
company: company, | ||
from: Time.zone.now.yesterday - 4.hours, | ||
to: Time.zone.now.yesterday, | ||
accepted_at: Time.zone.now.yesterday) | ||
FactoryBot.create(:data_request, | ||
company: other_company, | ||
from: Time.zone.now.yesterday - 4.hours, | ||
to: Time.zone.now.yesterday) | ||
FactoryBot.create(:data_request, | ||
company: company, | ||
from: Time.zone.now.yesterday - 4.hours, | ||
to: Time.zone.now.yesterday) | ||
end | ||
|
||
before do | ||
patch owners_unaccepted_data_request_accept_path(unaccepted_data_request_id: data_request.id) | ||
end | ||
|
||
subject { JSON.parse(response.body) } | ||
|
||
it "has the correct data" do | ||
expect(subject['id']).to eq(data_request.id) | ||
expect(data_request.reload.accepted?).to be(true) | ||
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
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe Owners::UnacceptedDataRequestsController do | ||
include_context 'api request authentication' | ||
|
||
let(:owner) { FactoryBot.create(:owner) } | ||
let(:company) { FactoryBot.create(:company, owner: owner) } | ||
let(:other_company) { FactoryBot.create(:company, owner: owner) } | ||
let(:area) { FactoryBot.create(:area, company: company) } | ||
|
||
before do | ||
sign_in(owner) | ||
end | ||
|
||
context "GET unaccepted_data_request index" do | ||
let!(:data_request) do | ||
FactoryBot.create(:ticket, area: area, encrypted_data: "data", entered_at: Time.zone.now.yesterday - 2.hours, left_at: Time.zone.now.yesterday - 1.hour) | ||
FactoryBot.create(:data_request, | ||
company: company, | ||
from: Time.zone.now.yesterday - 4.hours, | ||
to: Time.zone.now.yesterday, | ||
accepted_at: Time.zone.now.yesterday) | ||
FactoryBot.create(:data_request, | ||
company: other_company, | ||
from: Time.zone.now.yesterday - 4.hours, | ||
to: Time.zone.now.yesterday) | ||
FactoryBot.create(:data_request, | ||
company: company, | ||
from: Time.zone.now.yesterday - 4.hours, | ||
to: Time.zone.now.yesterday) | ||
end | ||
|
||
before do | ||
get owners_company_unaccepted_data_requests_path(company_id: company.id) | ||
end | ||
|
||
subject { JSON.parse(response.body) } | ||
|
||
it "has the correct data" do | ||
expect(subject.length).to eq(1) | ||
expect(subject.map{|item| item["id"]}).to eq([data_request.id]) | ||
end | ||
end | ||
end |