From 965177ba1a05f9f62c7e9f266e637f7f5753b3de Mon Sep 17 00:00:00 2001 From: Rubens Fernandes Date: Mon, 2 Dec 2024 15:05:05 -0600 Subject: [PATCH] added ability to set data checked status multiple times #111 --- .idea/disburser.iml | 91 +++++++++++ .idea/misc.xml | 4 + .idea/vcs.xml | 6 + .idea/workspace.xml | 141 ++++++++++++++++++ Gemfile | 2 +- Gemfile.lock | 7 +- ...disburser_request_edit_admin_status.coffee | 2 +- ....disburser_request_edit_data_status.coffee | 2 +- app/models/disburser_request.rb | 2 +- .../edit_admin_status.html.haml | 5 +- .../edit_data_status.html.haml | 5 +- spec/models/disburser_request_spec.rb | 12 +- spec/rails_helper.rb | 7 + 13 files changed, 275 insertions(+), 11 deletions(-) create mode 100644 .idea/disburser.iml create mode 100644 .idea/misc.xml create mode 100644 .idea/vcs.xml create mode 100644 .idea/workspace.xml diff --git a/.idea/disburser.iml b/.idea/disburser.iml new file mode 100644 index 0000000..af83c17 --- /dev/null +++ b/.idea/disburser.iml @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..3205808 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..c52e2cb --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,141 @@ + + + + + + + + + + + + + + + + + { + "keyToString": { + "RunOnceActivity.ShowReadmeOnStart": "true", + "WebServerToolWindowFactoryState": "false", + "last_opened_file_path": "/Users/rdf6928/work/code/disburser", + "node.js.detected.package.eslint": "true", + "node.js.detected.package.tslint": "true", + "node.js.selected.package.eslint": "(autodetect)", + "node.js.selected.package.tslint": "(autodetect)", + "nodejs_package_manager_path": "npm", + "ruby.rails.projectView.checked": "true", + "ruby.structure.view.model.defaults.configured": "true", + "vue.rearranger.settings.migration": "true" + } +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1717773721797 + + + + + + \ No newline at end of file diff --git a/Gemfile b/Gemfile index 8137d25..b7bdb32 100644 --- a/Gemfile +++ b/Gemfile @@ -56,7 +56,7 @@ gem 'will_paginate-foundation' group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console - gem 'byebug', platform: :mri + gem 'pry' end group :development do diff --git a/Gemfile.lock b/Gemfile.lock index 80febb5..0bda760 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -52,7 +52,6 @@ GEM bcrypt (3.1.20) bindex (0.8.1) builder (3.2.4) - byebug (11.1.3) capistrano (3.6.0) airbrussh (>= 1.0.0) capistrano-harrow @@ -85,6 +84,7 @@ GEM ckeditor (5.1.1) orm_adapter (~> 0.5.0) cocoon (1.2.15) + coderay (1.1.3) coffee-rails (4.2.2) coffee-script (>= 2.2.0) railties (>= 4.0.0) @@ -216,6 +216,9 @@ GEM activerecord (>= 4.2) request_store (~> 1.1) pg (1.5.6) + pry (0.15.0) + coderay (~> 1.1) + method_source (~> 1.0) public_suffix (5.0.5) puma (3.12.6) pundit (2.3.1) @@ -384,7 +387,6 @@ PLATFORMS DEPENDENCIES american_date - byebug capistrano (= 3.6.0) capistrano-rails capistrano-rvm @@ -412,6 +414,7 @@ DEPENDENCIES net-ldap paper_trail pg + pry puma (~> 3.0) pundit rails (~> 5.0.0, >= 5.0.0.1) diff --git a/app/assets/javascripts/disburser.disburser_request_edit_admin_status.coffee b/app/assets/javascripts/disburser.disburser_request_edit_admin_status.coffee index 797afc2..5d3033a 100644 --- a/app/assets/javascripts/disburser.disburser_request_edit_admin_status.coffee +++ b/app/assets/javascripts/disburser.disburser_request_edit_admin_status.coffee @@ -2,7 +2,7 @@ class Disburser.DisburserRequestEditAdminStatus constructor: () -> render: () -> $("input[name='disburser_request[data_status]']").on 'change', (e) -> - if $(this).val() == $('#data_status_original').val() + if ($(this).val() != 'data checked' && $(this).val() == $('#data_status_original').val()) $('#disburser_request_data_status_comments').val(''); $('#disburser_request_data_status_comments').attr('disabled', true) $('#disburser_request_data_status_status_at').attr('disabled', true) diff --git a/app/assets/javascripts/disburser.disburser_request_edit_data_status.coffee b/app/assets/javascripts/disburser.disburser_request_edit_data_status.coffee index f4d592d..af611c0 100644 --- a/app/assets/javascripts/disburser.disburser_request_edit_data_status.coffee +++ b/app/assets/javascripts/disburser.disburser_request_edit_data_status.coffee @@ -2,7 +2,7 @@ class Disburser.DisburserRequestEditDataStatus constructor: () -> render: () -> $("input[name='disburser_request[data_status]']").on 'change', (e) -> - if $(this).val() == $('#data_status_original').val() + if ($(this).val() != 'data checked' && $(this).val() == $('#data_status_original').val()) $('#disburser_request_data_status_comments').val(''); $('#disburser_request_data_status_comments').attr('disabled', true) $('#disburser_request_data_status_status_at').attr('disabled', true) diff --git a/app/models/disburser_request.rb b/app/models/disburser_request.rb index e58ec7f..da1dfe1 100644 --- a/app/models/disburser_request.rb +++ b/app/models/disburser_request.rb @@ -187,7 +187,7 @@ def build_disburser_request_status disburser_request_statuses.build(status_type: DisburserRequestStatus::DISBURSER_REQUEST_STATUS_TYPE_STATUS, status: self.status, user_id: self.status_user.id, comments: self.status_comments, status_at: self.status_at) end - if !self.data_status_not_started? && self.data_status_changed? + if !self.data_status_not_started? && (self.data_status_changed? || self.data_status == DISBURSER_REQUEST_DATA_STATUS_DATA_CHECKED) if self.data_status_status_at.blank? self.data_status_status_at = DateTime.now end diff --git a/app/views/disburser_requests/edit_admin_status.html.haml b/app/views/disburser_requests/edit_admin_status.html.haml index 377647c..336b1ce 100644 --- a/app/views/disburser_requests/edit_admin_status.html.haml +++ b/app/views/disburser_requests/edit_admin_status.html.haml @@ -1,3 +1,4 @@ +- data_disabled = @disburser_request.data_status == DisburserRequest::DISBURSER_REQUEST_DATA_STATUS_DATA_CHECKED ? false : true - content_for(:title) do Request #disburser_request @@ -36,14 +37,14 @@ .disburser_request_data_status_status_at %label{for: 'disburser_request_data_status_status_at' } Date - = f.text_field :data_status_status_at, disabled: true, class: 'datepicker' + = f.text_field :data_status_status_at, disabled: data_disabled, class: 'datepicker' - if validation_errors?(@disburser_request, :data_status_status_at) %p.error=format_validation_errors(@disburser_request, :data_status_status_at) %br .disburser_request_data_status_comments %label{for: 'disburser_request_data_status_comments' } Data Status Comments - = f.text_area :data_status_comments, rows: 3, disabled: true + = f.text_area :data_status_comments, rows: 3, disabled: data_disabled .specimen_status{ class: 'large-8 columns' } .disburser_request_specimen_status %label{for: 'disburser_request_specimen_status' } diff --git a/app/views/disburser_requests/edit_data_status.html.haml b/app/views/disburser_requests/edit_data_status.html.haml index 7b43e83..3162d89 100644 --- a/app/views/disburser_requests/edit_data_status.html.haml +++ b/app/views/disburser_requests/edit_data_status.html.haml @@ -1,3 +1,4 @@ +- disabled = @disburser_request.data_status == 'data checked' ? false : true - content_for(:title) do Request #disburser_request_show @@ -23,14 +24,14 @@ .data_status_status_at %label{for: 'disburser_request_data_status_status_at' } Date - = f.text_field :data_status_status_at, disabled: true, class: 'datepicker' + = f.text_field :data_status_status_at, disabled: disabled, class: 'datepicker' - if validation_errors?(@disburser_request, :data_status_status_at) %p.error=format_validation_errors(@disburser_request, :data_status_status_at) %br .data_status_comments %label{for: 'disburser_request_data_status_comments' } Data Status Comments - = f.text_area :data_status_comments, rows: 3, disabled: true + = f.text_area :data_status_comments, rows: 3, disabled: disabled .row .navigation{ class: 'large-offset-8 large-16 columns' } = f.submit 'Save', class: 'button' diff --git a/spec/models/disburser_request_spec.rb b/spec/models/disburser_request_spec.rb index 43fb443..944a9cf 100644 --- a/spec/models/disburser_request_spec.rb +++ b/spec/models/disburser_request_spec.rb @@ -252,7 +252,7 @@ expect(disburser_request_1.disburser_request_statuses.first.comments).to eq(data_status_comments) end - it "saves a disburser request status once the data status reaches anything but 'not started' (but only once)", focus: false do + it "saves a disburser request status once the data status reaches anything but 'not started' (but only once if not data checked)", focus: false do disburser_request_1 = FactoryGirl.create(:disburser_request, repository: @moomin_repository, submitter: @moomintroll_user) expect(disburser_request_1.disburser_request_statuses.size).to eq(0) expect(disburser_request_1.data_status).to eq(DisburserRequest::DISBURSER_REQUEST_DATA_STATUS_NOT_STARTED) @@ -273,6 +273,16 @@ disburser_request_1.data_status_comments = data_status_comments disburser_request_1.save! expect(disburser_request_1.disburser_request_statuses.size).to eq(1) + disburser_request_1.data_status = DisburserRequest::DISBURSER_REQUEST_DATA_STATUS_DATA_CHECKED + data_status_comments = 'data check 1' + disburser_request_1.data_status_comments = data_status_comments + disburser_request_1.save! + expect(disburser_request_1.disburser_request_statuses.size).to eq(2) + disburser_request_1.data_status = DisburserRequest::DISBURSER_REQUEST_DATA_STATUS_DATA_CHECKED + data_status_comments = 'data check 2' + disburser_request_1.data_status_comments = data_status_comments + disburser_request_1.save! + expect(disburser_request_1.disburser_request_statuses.size).to eq(3) end it "can return disburser requests that do not have a status of 'draft'", focus: false do diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 06f700c..07adf0e 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -100,6 +100,13 @@ end end +Shoulda::Matchers.configure do |config| + config.integrate do |with| + with.test_framework :rspec + with.library :rails + end +end + def human_boolean(boolean) boolean ? 'Yes' : 'No' end \ No newline at end of file