Skip to content

Commit 265a427

Browse files
committed
Add specs for empty ids or contains nil
1 parent 5cafa74 commit 265a427

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

app/controllers/application_controller/performance.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ def date_time_running_msg(typ, timestamp)
524524
end
525525
end
526526

527-
# Send error message if record is found and authorized, else return the record
527+
# Return record when is found and authorized, else raises exception
528528
def perf_menu_record_valid(model, id)
529529
record = find_record_with_rbac(model.constantize, id)
530530
if record.blank?

spec/controllers/mixins/checked_id_mixin_spec.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,21 @@
4646
expect { subject }.to raise_error("Can't access selected records")
4747
end
4848
end
49+
50+
context 'when there is no record id' do
51+
let(:model) { VmOrTemplate }
52+
let(:id) { [] }
53+
it 'is expected to raise exeption' do
54+
expect { subject }.to raise_error("Can't access records without id")
55+
end
56+
end
57+
58+
context 'when user tries to access record with nil id ' do
59+
let(:model) { VmOrTemplate }
60+
let(:id) { [vm1.id, nil] }
61+
it 'is expected to raise exeption' do
62+
expect { subject }.to raise_error("Can't access records without id")
63+
end
64+
end
4965
end
5066
end

0 commit comments

Comments
 (0)