Skip to content

Commit

Permalink
Hound
Browse files Browse the repository at this point in the history
  • Loading branch information
zwolf committed May 31, 2024
1 parent f3b0d55 commit 99fb3b7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
4 changes: 2 additions & 2 deletions app/models/workflow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Workflow < ApplicationRecord
include Translatable
include Versioning

self.ignored_columns = ["aggregation"]
self.ignored_columns = ['aggregation']

versioned association: :workflow_versions, attributes: %w(tasks first_task strings major_version minor_version)

Expand Down Expand Up @@ -46,7 +46,7 @@ class Workflow < ApplicationRecord
'options' => {'count' => 15}
}.freeze

JSON_ATTRIBUTES = %w(tasks retirement strings steps).freeze
JSON_ATTRIBUTES = %w[tasks retirement strings steps].freeze

SELECTOR_PAGE_SIZE_KEY = 'subject_queue_page_size'.freeze

Expand Down
8 changes: 4 additions & 4 deletions lib/formatter/csv/workflow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ module Csv
class Workflow
attr_reader :workflow_version

JSON_FIELDS = [:tasks, :strings ].freeze
JSON_FIELDS = %i[tasks strings].freeze

def headers
%w(workflow_id display_name version active classifications_count pairwise
grouped prioritized primary_language first_task tutorial_subject_id
retired_set_member_subjects_count tasks retirement strings minor_version)
%w[workflow_id display_name version active classifications_count pairwise
grouped prioritized primary_language first_task tutorial_subject_id
retired_set_member_subjects_count tasks retirement strings minor_version]
end

def to_rows(workflow_version)
Expand Down
20 changes: 12 additions & 8 deletions spec/lib/formatter/csv/workflow_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
require "spec_helper"
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Formatter::Csv::Workflow do
let(:workflow) { create(:workflow) }
Expand Down Expand Up @@ -33,22 +35,24 @@ def retirement_json
end

let(:header) do
%w(workflow_id display_name version minor_version active classifications_count pairwise grouped prioritized primary_language first_task tutorial_subject_id retired_set_member_subjects_count tasks retirement strings)
%w[workflow_id display_name version minor_version active classifications_count pairwise grouped
prioritized primary_language first_task tutorial_subject_id retired_set_member_subjects_count
tasks retirement strings]
end

describe "#headers" do
it 'should contain the required headers' do
describe '#headers' do
it 'contains the required headers' do
expect(described_class.new.headers).to match_array(header)
end
end

describe "#to_rows" do
describe '#to_rows' do
subject { described_class.new.to_rows(workflow_version) }

it { is_expected.to match_array(rows) }
end

context "with a versioned workflow" do
context 'with a versioned workflow' do
let(:q_workflow) { build(:workflow, :question_task) }
let(:tasks) { q_workflow.tasks }

Expand All @@ -60,13 +64,13 @@ def retirement_json
workflow.update(updates)
end

describe "#to_rows on the latest version" do
describe '#to_rows on the latest version' do
subject { described_class.new.to_rows(workflow_version) }

it { is_expected.to match_array(rows) }
end

describe "#to_rows on the previous version" do
describe '#to_rows on the previous version' do
let(:workflow_version) { workflow.workflow_versions.order(:created_at).first }

subject { described_class.new.to_rows(workflow_version) }
Expand Down

0 comments on commit 99fb3b7

Please sign in to comment.