Skip to content

Commit b225055

Browse files
committed
add tests
1 parent 535b6bb commit b225055

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

spec/requests/volumes/batch_actions_spec.rb

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,56 @@
194194
end
195195
end
196196

197+
context "when updating notes" do
198+
it "appends notes with a semicolon delimiter" do
199+
asset_1.update!(notes: "First note")
200+
asset_2.update!(notes: nil)
201+
202+
patch volume_batch_actions_path(volume), params: {
203+
asset_ids: "#{asset_1.id},#{asset_2.id}",
204+
notes_action: "append",
205+
notes: "Second note"
206+
}
207+
208+
expect(response).to have_http_status(:redirect)
209+
210+
asset_1.reload
211+
asset_2.reload
212+
213+
expect(asset_1.notes).to eq("First note; Second note")
214+
expect(asset_2.notes).to eq("Second note")
215+
expect(flash[:notice]).to include("notes appended")
216+
end
217+
218+
it "replaces notes even when the new value is blank" do
219+
asset_1.update!(notes: "Existing note")
220+
221+
patch volume_batch_actions_path(volume), params: {
222+
asset_ids: asset_1.id.to_s,
223+
notes_action: "replace",
224+
notes: ""
225+
}
226+
227+
expect(response).to have_http_status(:redirect)
228+
expect(asset_1.reload.notes).to eq("")
229+
expect(flash[:notice]).to include("notes replaced")
230+
end
231+
232+
it "clears notes for selected assets" do
233+
asset_1.update!(notes: "Existing note")
234+
235+
patch volume_batch_actions_path(volume), params: {
236+
asset_ids: asset_1.id.to_s,
237+
notes_action: "clear",
238+
notes: "ignored"
239+
}
240+
241+
expect(response).to have_http_status(:redirect)
242+
expect(asset_1.reload.notes).to be_nil
243+
expect(flash[:notice]).to include("notes cleared")
244+
end
245+
end
246+
197247
context "when updating multiple fields simultaneously" do
198248
it "updates all specified fields for selected assets" do
199249
patch volume_batch_actions_path(volume), params: {

spec/system/batch_actions_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@
6565
expect(page).to have_select("migration_status_id")
6666
expect(page).to have_select("assigned_user_id")
6767
expect(page).to have_select("aspace_collection_id")
68+
expect(page).to have_select(
69+
"notes_action",
70+
with_options: [ "Unchanged", "Append", "Replace", "Clear (removes all notes)" ]
71+
)
72+
expect(page).to have_field("notes")
6873
expect(page).to have_field("aspace_linking_unchanged", checked: true)
6974
end
7075
end

0 commit comments

Comments
 (0)