initial commit

This commit is contained in:
2018-01-20 13:02:44 -03:00
commit 203138a969
650 changed files with 19523 additions and 0 deletions
+95
View File
@@ -0,0 +1,95 @@
require 'rails_helper'
feature "Show badge info" do
describe "Not linked to service provider" do
background do
i_am_logged_in_as_admin
@workflow_instance_batch = create :workflow_instance_batch_scenario1, name: 'Batchy'
@dslam_1 = create :workflow_instance_scenario1, :active, my_name: 'DSLA/111'
@dslam_2 = create :workflow_instance_scenario1, :active, plan_date: '2019-03-09', my_name: 'DSLA/222', workflow_instance_batch: @workflow_instance_batch
@dslam_3 = create :workflow_instance_scenario1, my_name: 'DSLA/333', workflow_instance_batch: @workflow_instance_batch
@dslam_4 = create :workflow_instance_scenario1, my_name: 'DSLA/444'
@owner_initialization = @dslam_3.owner_initialization
@owner_initialization.replace_notes 'PreparationNotes'
@owner_initialization.is_overdue!
end
describe 'Statistics' do
it "Shows the dslams for a workflow_instance state", js: true do
visit root_path
badge = find('.workflow_instance.scenario1.active.display-badge')
expect( badge.text ).to eq 'Actief (2)'
badge.click
within '#display-badge-info-popup' do
expect( page ).to have_content 'DSLA/111'
expect( page ).to have_content 'DSLA/222'
expect( page ).not_to have_content 'DSLA/333'
expect( page ).not_to have_content 'DSLA/444'
click_on "Toon lijst"
end
page.current_url.should include "/workflow_instance/scenario1s?q%5Bstate_eq%5D=active"
expect( page ).to have_content 'DSLA/111'
expect( page ).to have_content 'DSLA/222'
expect( page ).not_to have_content 'DSLA/333'
expect( page ).not_to have_content 'DSLA/444'
end
it "Show the dslams for a subprocess state", js: true do
visit root_path
badge = find('.owner_initialization.scenario1.overdue.display-badge')
expect( badge.text ).to eq 'Overdue (1)'
badge.click
within '#display-badge-info-popup' do
page.should_not have_content 'DSLA/111'
page.should_not have_content 'DSLA/222'
page.should have_content 'DSLA/333'
page.should_not have_content 'DSLA/444'
end
end
end
describe "Actual record" do
it "Shows basic information for the workflow_instance record", js: true, disabled: true do # disabled because plan_date out of scope
visit workflow_instance_scenario1s_path
badge = find(%|[data-record='{"id":#{@dslam_2.id}}'] .workflow_instance.scenario1.display-badge|)
badge.click
within '#display-badge-info-popup' do
expect( page ).to have_content '09-03-2019'
end
end
it "Shows basic information for the subprocess record", js: true do
visit workflow_instance_scenario1s_path
badge = find(%|[data-record='{"id":#{@dslam_3.id}}'] .owner_initialization.scenario1.display-badge|)
badge.click
within '#display-badge-info-popup' do
expect( page ).to have_content 'PreparationNotes'
end
end
end
describe "Batch scope" do
it "Shows batch limited informatio", js: true do
# Create bogus not batch records, if batch is not activated on
# query, two records are found in stead of 1
dslam_4 = create :workflow_instance_scenario1, :active, my_name: 'DSLA/444'
dslam_4.owner_initialization.update state: 'processing'
visit workflow_instance_batch_scenario1s_path
badge = find(%|.contractor_initialization.scenario1.pending.display-badge|)
expect( badge.text ).to eq 'Contr. init (2)'
badge.click
within '#display-badge-info-popup' do
expect( page ).to have_content 'DSLA/222'
expect( page ).not_to have_content 'DSLA/444'
end
#TODO: workflow step filtering
#click_on "Toon lijst"
#page.current_url.should include "/workflow_instance/scenario1s?q%5Bworkflow_instance_batch_id_eq%5D=#{@workflow_instance_batch.id}&q%5Bworkflow_step%5D%5Bowner_initialization%5D=pending"
end
end
end
end
+11
View File
@@ -0,0 +1,11 @@
require 'rails_helper'
RSpec.feature 'Changelog' do
background { i_am_logged_in_as_admin }
scenario "underscore integrity" do
visit '/dunlop/changelog'
page.should have_content "These un_der_scores are not replaced by italic"
page.should have_content "Already escaped_under_scores are not double escaped"
end
end
+16
View File
@@ -0,0 +1,16 @@
require 'rails_helper'
RSpec.feature 'Home page' do
background { i_am_logged_in_as_admin }
scenario "there are no javascript error messages", js: true do
visit '/'
case page.driver.class.name.underscore
when /webkit/
expect( page.driver.error_messages ).to be_empty
when /poltergeist/
# nothing, js_errors: true will raise ruby error
end
page.should have_content Rails.application.config.application_name
end
end
@@ -0,0 +1,15 @@
require 'rails_helper'
feature "Show execution batches" do
background { i_am_logged_in_as_admin }
scenario "From the index to the show" do
batch = create 'execution_batch/my_batch', info_message: 'I did stuff'
visit "/dunlop/execution_batches"
page.should have_content "I did stuff"
click_on "Uitvoerings batch"
page.status_code.should eq 200
page.current_path.should eq "/dunlop/execution_batches/#{batch.id}"
page.should have_content "I did stuff"
end
end
@@ -0,0 +1,13 @@
require 'rails_helper'
feature "Application helpers with feature spec" do
background { i_am_logged_in_as_admin }
scenario '#render_as_dunlop_modal', js: true do
visit "/dashboard/render_as_dunlop_modal_test"
within "#workflow-step-modal" do
page.should have_content "Special partial for testing, passed value is 78"
end
end
end
+12
View File
@@ -0,0 +1,12 @@
require 'rails_helper'
feature "Workflow steps in batch finished report" do
background { i_am_logged_in_as_admin }
scenario "rendering the page" do
visit "/dunlop/reports"
page.should have_content "Workflow instance fields"
page.should have_content "Report listing actions performed when all workflow steps in a batch are in a final state"
page.should have_content "Users permissions overview"
end
end
@@ -0,0 +1,10 @@
require 'rails_helper'
feature "Workflow steps in batch finished report" do
background { i_am_logged_in_as_admin }
scenario "rendering the page" do
visit "/dunlop/reports/system/workflow_steps_in_batch_finished"
page.should have_content "Report listing actions performed when all workflow steps in a batch are in a final state"
end
end
@@ -0,0 +1,10 @@
require 'rails_helper'
feature "Workflow steps overdue report" do
background { i_am_logged_in_as_admin }
scenario "rendering the page" do
visit "/dunlop/reports/system/workflow_steps_overdue"
page.should have_content "Contr. initialisatie is overdue als hij 2 dagen na Core initialisatie → Dattum nog niet afgerond is"
end
end
@@ -0,0 +1,36 @@
require 'rails_helper'
RSpec.feature 'Source files index page' do
background { i_am_logged_in_as_admin }
scenario "it renders with all kinds of source file without problems, also a good check wether all layout files have app prefix in navigation links" do
user = create :user, email: 'source-user8731@example.com'
batch = create 'execution_batch/my_batch'
source_file_1 = create 'source_file/my_source', creator: nil
source_file_2 = create 'source_file/my_source', creator: user, original_file: fixture_file("source_files/my_source_1.csv")
source_file_3 = create 'source_file/my_source', creator: batch
visit '/dunlop/source_files'
page.should have_content "Bronbestanden overzicht"
page.body.should include "source-user8731@example.com"
page.body.should_not include "source-user8731@example.com</a>" # users have no show page
page.body.should include "Uitvoerings batch</a>" # link to batch
find(".table-link.show[href='/dunlop/source_files/#{source_file_2.id}']").click
current_path.should eq "/dunlop/source_files/#{source_file_2.id}"
page.should have_content "Download"
find(".title-back-link").click
current_path.should eq "/dunlop/source_files"
# download source file 2
find(".table-link.download[href='/dunlop/source_files/#{source_file_2.id}/download']").click
page.body.should eq <<-CSV.strip_heredoc
my_date,my_var,My count,my_num,my_truth
2015-05-09,abc D,19,4.8,true
2015-11-09,def G,19,7.8,false
CSV
end
end
@@ -0,0 +1,30 @@
require 'rails_helper'
feature 'Target files index page' do
background { i_am_logged_in_as_admin }
scenario "download_latest when completed with specific type" do
allow_any_instance_of(TargetFile::MyTarget).to receive(:gzip_file?).and_return false # no gzip for this test
target_file = create 'target_file/my_target'
target_file.execute_generation_process
target_file.should be_completed
visit "/dunlop/target_files/download_latest/my_target"
page.response_headers['Content-Disposition'].should match /attachment; filename="my_target-/
page.body.should eq target_file.original_file.read
end
scenario "download_latest when failed with specific type should not return" do
allow_any_instance_of(TargetFile::MyTarget).to receive(:gzip_file?).and_return false # no gzip for this test
target_file = create 'target_file/my_target', :failed
target_file.execute_generation_process
target_file.should be_failed
visit "/dunlop/target_files/download_latest/my_target"
page.body.should be_empty
page.status_code.should be 404
end
end
+12
View File
@@ -0,0 +1,12 @@
require 'rails_helper'
feature 'Target files index page' do
background { i_am_logged_in_as_admin }
scenario "it renders with all kinds of target file without problems, also a good check wether all layout files have app prefix in navigation links" do
TargetFile.classes.each(&:create!)
visit '/dunlop/target_files'
page.should have_content "Target files overzicht"
end
end
+25
View File
@@ -0,0 +1,25 @@
require 'rails_helper'
feature 'Target files show page' do
background { i_am_logged_in_as_admin }
scenario "download button when completed" do
target_file = create 'target_file/my_target'
target_file.execute_generation_process
target_file.should be_completed
visit "/dunlop/target_files/#{target_file.id}"
page.should have_content "Download"
end
scenario "no download button when not completed" do
target_file = create 'target_file/my_target'
target_file.should be_new
visit "/dunlop/target_files/#{target_file.id}"
page.should_not have_content "Download"
end
end
+66
View File
@@ -0,0 +1,66 @@
require 'rails_helper'
RSpec.feature "Admin manages user" do
let(:user_options){ Hash.new }
let!(:admin) { create :admin, user_options.merge(email: 'admin@example.com') }
#let(:user) { create :user, user_options.merge(email: 'user@example.com') }
background { i_am_logged_in_as user }
context "With manage user rights" do
let(:user) { create(:user, email: 'user@example.com', role_names_admin: ['manage-class-User']) }
scenario 'list users' do
user and click_on "Gebruikers"
expect(page).to have_content('admin@example.com')
expect(page).to have_content('user@example.com')
end
scenario "create new user" do
click_on "Gebruikers"
click_on "Gebruiker toevoegen"
fill_in 'Email', with: "new_user@example.com"
fill_in 'Password', with: "password123"
#find('#user-role-migration-read').set true
#find('#user-role-owner-read').set true
#find('#user-role-service_provider-read').set true
#find('#user-role-contractor-manage').set true
#find('#user-role-report-timewax').set true
#check 'Role1'
#check 'Role2'
click_on "Gebruiker toevoegen"
expect(current_path).to eq dunlop.users_path
user = User.find_by(email: 'new_user@example.com')
expect( admin ).to_not eq user
expect( user.valid_password?('password123')) .to be true
expect( user.role_names.map(&:presence).compact ).to match_array %w[read-class-WorkflowInstance]
#expect(user.roles).to eq [Role::Role1, Role::Role2, '']
end
scenario "edit user" do
other_user = create :user, email: 'other-user@example.com'
click_on "Gebruikers"
within "#user-#{other_user.id}" do
click_on_selector ".table-link.edit"
end
# Clear all permissions (empty value ...)
#find('#user-role-migration-read').set false
#click_on "Update"
click_on "Gebruiker bijwerken"
expect(current_path).to eq "/dunlop/users"
expect(other_user.reload.role_names).to eq ["", "read-class-WorkflowInstance"]
end
scenario "show permissions table" do
visit "/dunlop/users/permissions_table"
page.should have_selector '.role-icon.read'
end
end
end
@@ -0,0 +1,55 @@
require "rails_helper"
feature "Archive and revive workflow instances", js: true do
let(:user_params) { {} }
let(:user) { create :user, user_params }
background { i_am_logged_in_as user }
context "with permissions" do
let(:user_params) { {role_names: ["read-class-WorkflowInstance", "archive-class-WorkflowInstance"] } }
scenario "Archive workflow instances" do
create 'workflow_instance/scenario1', bucket: 'B1'
create 'workflow_instance/scenario1', bucket: 'B2'
visit "/workflow_instance/scenario1s"
select_all_workflow_instances
js_click ".collection-edit.workflow_instance-actions"
page.should_not have_selector ".workflow-instance-revive-button"
js_click ".workflow-instance-archive-button"
#page.current_path.should eq "/workflow_instance/scenario1s"
page.should have_selector "body.archived-mode"
page.current_path.should eq "/"
WorkflowInstance.archived.count.should eq 2
WorkflowInstance.scope_for(user).count.should eq 0
visit "/workflow_instance/scenario1s"
page.should have_content "B1"
page.should have_content "B2"
select_all_workflow_instances
js_click ".collection-edit.workflow_instance-actions"
page.should_not have_selector ".workflow-instance-archive-button"
js_click ".workflow-instance-revive-button"
page.current_path.should eq "/workflow_instance/scenario1s"
page.should_not have_selector "body.archived-mode"
WorkflowInstance.archived.count.should eq 0
WorkflowInstance.scope_for(user).count.should eq 2
end
end
context "without permissions" do
let(:user_params) { {role_names: ["read-class-WorkflowInstance", "update-class-WorkflowInstance"] } }
scenario "business as usual, but should not have archive action" do
create 'workflow_instance/scenario1', bucket: 'B1'
create 'workflow_instance/scenario1', bucket: 'B2'
visit "/workflow_instance/scenario1s"
select_all_workflow_instances
js_click ".collection-edit.workflow_instance-actions"
page.should_not have_selector ".workflow-instance-archive-button"
end
end
end
@@ -0,0 +1,50 @@
require 'rails_helper'
feature "Categorize workflow instances as other scenario", js: true do
let(:user_params) { {} }
let(:user) { create :user, user_params }
background { i_am_logged_in_as user }
context "with permissions" do
let(:user_params) { {role_names: ["read-class-WorkflowInstance", "categorize-class-WorkflowInstance"] } }
scenario "nothing selected" do
create 'workflow_instance/scenario1', bucket: 'B1'
create 'workflow_instance/scenario1', bucket: 'B2'
visit "/workflow_instance/scenario1s"
js_click "#categorize-as-button"
page.accept_alert "Nothing selected" # will fail if no modal is present
end
scenario "from scenario1 to 2" do
create 'workflow_instance/scenario1', bucket: 'B1'
create 'workflow_instance/scenario1', bucket: 'B2'
visit "/workflow_instance/scenario1s"
select_all_workflow_instances
js_click "#categorize-as-button"
accept_confirm "Weet je dit zeker? Stappen die niet aanwezig zijn in SC2 zullen verdwijnen." do
sleep 0.3
WorkflowInstance.pluck(:sti_type).uniq.should eq ["WorkflowInstance::Scenario2"]
page.current_path.should eq "/workflow_instance/scenario2s/selection"
page.should have_content "B1"
page.should have_content "B2"
end
end
end
context "without permissions" do
let(:user_params) { {role_names: ["read-class-WorkflowInstance"] } }
scenario "there is no button" do
create 'workflow_instance/scenario1', bucket: 'B1'
create 'workflow_instance/scenario1', bucket: 'B2'
page.should_not have_selector "#categorize-as-button"
end
scenario "fabricate hack request", js: false do
wi = create 'workflow_instance/scenario1', bucket: 'B1'
page.driver.post "/dunlop/workflow_instances/categorize_as?scenario=scenario2&ids=#{wi.id}"
page.status_code.should eq 403
WorkflowInstance.pluck(:sti_type).should eq ["WorkflowInstance::Scenario1"]
end
end
end
@@ -0,0 +1,41 @@
require "rails_helper"
feature "Reset workflow instances", js: true do
let(:user_params) { {} }
let(:user) { create :user, user_params }
background { i_am_logged_in_as user }
context "with permissions" do
let(:user_params) { {role_names: ["read-class-WorkflowInstance", "reset-class-WorkflowInstance"] } }
scenario "Reset workflow instances" do
wi = create 'workflow_instance/scenario1', :active, bucket: 'B1'
wi.workflow_steps.map(&:state).uniq.should match_array ['processing', 'pending']
visit "/workflow_instance/scenario1s"
select_all_workflow_instances
js_click ".collection-edit.workflow_instance-actions"
js_click ".workflow-instance-reset-button"
#page.current_path.should eq "/workflow_instance/scenario1s"
page.current_path.should eq "/workflow_instance/scenario1s" # redirect back
page.should_not have_content "B1"
wi_reset = WorkflowInstance.find(wi.id)
wi_reset.sti_type.should eq "WorkflowInstance::Scenario1" # no scenario reset here
wi_reset.workflow_steps.map(&:state).uniq.should eq ['pending']
end
end
context "without permissions" do
let(:user_params) { {role_names: ["read-class-WorkflowInstance", "update-class-WorkflowInstance"] } }
scenario "business as usual, but should not have reset action" do
create 'workflow_instance/scenario1', bucket: 'B1'
create 'workflow_instance/scenario1', bucket: 'B2'
visit "/workflow_instance/scenario1s"
select_all_workflow_instances
js_click ".collection-edit.workflow_instance-actions"
page.should_not have_selector ".workflow-instance-reset-button"
end
end
end
@@ -0,0 +1,12 @@
require 'rails_helper'
RSpec.feature "ContractorInitialization for Scenario1" do
it_behaves_like "a workflow step", :contractor_initialization do
let(:workflow_instance_factory) { :workflow_instance_scenario1 }
let :attributes do
{
}
end
end
end
@@ -0,0 +1,20 @@
require 'rails_helper'
RSpec.feature "OwnerInitialization for Scenario1" do
it_behaves_like "a workflow step", :owner_initialization do
let(:workflow_instance_factory) { :workflow_instance_scenario1 }
let :attributes do
{
initialization_check_done: { type: :boolean },
plan_date: { type: :date },
my_identifier: { type: :string },
window_from: { type: :window_from},
window_to: { type: :window_to},
number_of_visits: { type: :integer },
my_fraction: { type: :float },
my_explanation: { type: :string },
}
end
end
end
@@ -0,0 +1,14 @@
require 'rails_helper'
RSpec.feature "WbaSubmission for Scenario2" do
it_behaves_like "a workflow step", :wba_submission do
let(:workflow_instance_factory) { :workflow_instance_scenario2 }
let :attributes do
{
all_clear: { type: :boolean },
new_service_group: { type: :string},
}
end
end
end