Skip to content

Commit 820adc7

Browse files
committed
Merge branch 'develop' into 'master'
Develop See merge request gtt/redmine_supply!5
2 parents f9094e9 + dcfa257 commit 820adc7

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

init.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
author 'Jens Krämer, Georepublic'
1010
author_url 'https://hub.georepublic.net/gtt/redmine_supply'
1111
description 'Add configurable supply items to issues'
12-
version '1.2.0'
12+
version '1.2.1'
1313

1414
requires_redmine version_or_higher: '3.4.0'
1515

lib/redmine_supply/save_supply_item.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ def call
2323

2424
SupplyItem.transaction do
2525
save_supply_item
26-
rescue ActiveRecord::RecordInvalid
27-
@error = $!.message
2826
end
2927

3028
if @error
@@ -53,6 +51,9 @@ def save_supply_item
5351
old_stock: old_stock, new_stock: new_stock
5452
)
5553
end
54+
rescue ActiveRecord::RecordInvalid
55+
@error = $!.message
56+
raise ActiveRecord::Rollback
5657
end
5758
end
5859
end

test/unit/save_supply_item_test.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@ class SaveSupplyItemTest < ActiveSupport::TestCase
1414
SupplyItem.delete_all
1515
end
1616

17+
test 'should require name' do
18+
r = RedmineSupply::SaveSupplyItem.(
19+
{name: '', stock: 5}, project: @project
20+
)
21+
refute r.supply_item_saved?, r.inspect
22+
assert i = r.supply_item
23+
refute i.persisted?
24+
assert r.error.present?
25+
end
26+
1727
test 'should record stock change when created' do
1828
r = RedmineSupply::SaveSupplyItem.(
1929
{name: 'new item', stock: 5}, project: @project

0 commit comments

Comments
 (0)