Skip to content

Commit d09bb55

Browse files
committed
rubocop and rspec fixes
1 parent f21c8d3 commit d09bb55

6 files changed

Lines changed: 14 additions & 13 deletions

File tree

app/controllers/templates_preferences_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def create
1717

1818
old_submitters_order = @template.preferences['submitters_order']
1919
@template.preferences = @template.preferences.merge(template_params[:preferences])
20-
@templahttp://app.lvh.me:3000/retain/team/tasks_list_builder/13/editte.preferences = @template.preferences.reject { |_, v| (v.is_a?(String) || v.is_a?(Hash)) && v.blank? }
20+
@template.preferences = @template.preferences.reject { |_, v| (v.is_a?(String) || v.is_a?(Hash)) && v.blank? }
2121

2222
# Handle single_sided case (when template has < 2 unique submitters)
2323
if @template.unique_submitter_uuids.size < 2 && @template.preferences['submitters_order'].present?

lib/submitters.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ def current_submitter_order?(submitter)
168168

169169
ordered_items = submitters_order == 'manager_then_employee' ? submitter_items.reverse : submitter_items
170170

171-
before_items = ordered_items[0...ordered_items.find_index { |e| e['uuid'] == submitter.uuid }]
171+
before_items = ordered_items[0...(ordered_items.find_index { |e| e['uuid'] == submitter.uuid })]
172172

173173
before_items.all? do |item|
174174
submitter.submission.submitters.find { |e| e.uuid == item['uuid'] }&.completed_at?

spec/lib/submissions/create_from_submitters_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99

1010
let(:submitter_attrs) do
1111
template.submitters.map do |s|
12-
HashWithIndifferentAccess.new({ 'uuid' => s['uuid'], 'email' => Faker::Internet.email })
12+
{ 'uuid' => s['uuid'], 'email' => Faker::Internet.email }.with_indifferent_access
1313
end
1414
end
1515

1616
def call(template:, submitters_order:)
1717
described_class.call(
1818
template:,
1919
user:,
20-
submissions_attrs: [HashWithIndifferentAccess.new({ 'submitters' => submitter_attrs })],
20+
submissions_attrs: [{ 'submitters' => submitter_attrs }.with_indifferent_access],
2121
source: :api,
2222
submitters_order:
2323
)

spec/lib/submissions_spec.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@
1919
allow(Submitters).to receive(:send_signature_requests)
2020
end
2121

22-
def set_order(order)
22+
def update_order(order)
2323
template.update_column(:preferences, { 'submitters_order' => order })
2424
submission.reload
2525
end
2626

2727
context 'with employee_then_manager order' do
28-
before { set_order('employee_then_manager') }
28+
before { update_order('employee_then_manager') }
2929

3030
it 'sends signature request only to the employee first' do
3131
described_class.send_signature_requests([submission])
@@ -35,7 +35,7 @@ def set_order(order)
3535
end
3636

3737
context 'with manager_then_employee order' do
38-
before { set_order('manager_then_employee') }
38+
before { update_order('manager_then_employee') }
3939

4040
it 'sends signature request only to the manager first' do
4141
described_class.send_signature_requests([submission])
@@ -45,12 +45,12 @@ def set_order(order)
4545
end
4646

4747
context 'with simultaneous order' do
48-
before { set_order('simultaneous') }
48+
before { update_order('simultaneous') }
4949

5050
it 'sends signature requests to all submitters' do
5151
described_class.send_signature_requests([submission])
5252

53-
expect(Submitters).to have_received(:send_signature_requests).with(match_array([employee, manager]),
53+
expect(Submitters).to have_received(:send_signature_requests).with(contain_exactly(employee, manager),
5454
delay_seconds: nil)
5555
end
5656
end

spec/lib/submitters_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
let!(:employee) { create(:submitter, submission:, uuid: employee_uuid) }
1616
let!(:manager) { create(:submitter, submission:, uuid: manager_uuid) }
1717

18-
def set_order(order)
18+
def update_order(order)
1919
template.update_column(:preferences, { 'submitters_order' => order })
2020
submission.reload
2121
end
2222

2323
context 'with manager_then_employee order' do
24-
before { set_order('manager_then_employee') }
24+
before { update_order('manager_then_employee') }
2525

2626
it 'returns true for the manager (index 1)' do
2727
expect(described_class.current_submitter_order?(manager.reload)).to be true
@@ -39,7 +39,7 @@ def set_order(order)
3939
end
4040

4141
context 'with employee_then_manager order' do
42-
before { set_order('employee_then_manager') }
42+
before { update_order('employee_then_manager') }
4343

4444
it 'returns true for the first submitter (Employee)' do
4545
expect(described_class.current_submitter_order?(employee.reload)).to be true

spec/requests/templates_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,8 @@ def template_body(template)
253253
],
254254
preferences: {
255255
'request_email_subject' => 'Subject text',
256-
'request_email_body' => 'Body Text'
256+
'request_email_body' => 'Body Text',
257+
'submitters_order' => 'single_sided'
257258
},
258259
schema: [
259260
{

0 commit comments

Comments
 (0)