Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-25 18:50:27 +01:00
Merge pull request #234 from paviliondev/fix_user_in_submissions_two
Ensure each submission wizard has the right user
Dieser Commit ist enthalten in:
Commit
7d6456667a
3 geänderte Dateien mit 14 neuen und 13 gelöschten Zeilen
|
@ -134,8 +134,9 @@ class CustomWizard::Submission
|
||||||
submission_user = list_user || User.find_by(id: record.key.to_i)
|
submission_user = list_user || User.find_by(id: record.key.to_i)
|
||||||
|
|
||||||
submission_data.each do |data|
|
submission_data.each do |data|
|
||||||
wizard.user = submission_user if submission_user.present?
|
_wizard = wizard.clone
|
||||||
result.submissions.push(new(wizard, data))
|
_wizard.user = submission_user if submission_user.present?
|
||||||
|
result.submissions.push(new(_wizard, data))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
# name: discourse-custom-wizard
|
# name: discourse-custom-wizard
|
||||||
# about: Forms for Discourse. Better onboarding, structured posting, data enrichment, automated actions and much more.
|
# about: Forms for Discourse. Better onboarding, structured posting, data enrichment, automated actions and much more.
|
||||||
# version: 2.2.10
|
# version: 2.2.11
|
||||||
# authors: Angus McLeod, Faizaan Gagan, Robert Barrow, Keegan George, Kaitlin Maddever
|
# authors: Angus McLeod, Faizaan Gagan, Robert Barrow, Keegan George, Kaitlin Maddever
|
||||||
# url: https://github.com/paviliondev/discourse-custom-wizard
|
# url: https://github.com/paviliondev/discourse-custom-wizard
|
||||||
# contact_emails: development@pavilion.tech
|
# contact_emails: development@pavilion.tech
|
||||||
|
|
|
@ -14,11 +14,12 @@ describe CustomWizard::SubmissionSerializer do
|
||||||
|
|
||||||
before do
|
before do
|
||||||
CustomWizard::Template.save(template_json, skip_jobs: true)
|
CustomWizard::Template.save(template_json, skip_jobs: true)
|
||||||
|
|
||||||
wizard = CustomWizard::Wizard.create(template_json["id"], user1)
|
wizard = CustomWizard::Wizard.create(template_json["id"], user1)
|
||||||
CustomWizard::Submission.new(wizard,
|
CustomWizard::Submission.new(wizard, step_1_field_1: "I am user1 submission", submitted_at: Time.now.iso8601).save
|
||||||
step_1_field_1: "I am user submission",
|
|
||||||
submitted_at: Time.now.iso8601
|
wizard = CustomWizard::Wizard.create(template_json["id"], user2)
|
||||||
).save
|
CustomWizard::Submission.new(wizard, step_1_field_1: "I am user2 submission", submitted_at: Time.now.iso8601).save
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should return submission attributes' do
|
it 'should return submission attributes' do
|
||||||
|
@ -30,12 +31,11 @@ describe CustomWizard::SubmissionSerializer do
|
||||||
each_serializer: described_class
|
each_serializer: described_class
|
||||||
).as_json
|
).as_json
|
||||||
|
|
||||||
expect(json_array.length).to eq(1)
|
expect(json_array.length).to eq(2)
|
||||||
expect(json_array[0][:id].present?).to eq(true)
|
expect(json_array[0][:id].present?).to eq(true)
|
||||||
expect(json_array[0][:user]).to eq(
|
|
||||||
BasicUserSerializer.new(user1, root: false).as_json
|
|
||||||
)
|
|
||||||
expect(json_array[0][:submitted_at].present?).to eq(true)
|
expect(json_array[0][:submitted_at].present?).to eq(true)
|
||||||
|
expect(json_array[0][:user]).to eq(BasicUserSerializer.new(user2, root: false).as_json)
|
||||||
|
expect(json_array[1][:user]).to eq(BasicUserSerializer.new(user1, root: false).as_json)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should return field values, types and labels" do
|
it "should return field values, types and labels" do
|
||||||
|
@ -47,10 +47,10 @@ describe CustomWizard::SubmissionSerializer do
|
||||||
each_serializer: described_class
|
each_serializer: described_class
|
||||||
).as_json
|
).as_json
|
||||||
|
|
||||||
expect(json_array.length).to eq(1)
|
expect(json_array.length).to eq(2)
|
||||||
expect(json_array[0][:fields].as_json).to eq({
|
expect(json_array[0][:fields].as_json).to eq({
|
||||||
"step_1_field_1": {
|
"step_1_field_1": {
|
||||||
"value": "I am user submission",
|
"value": "I am user2 submission",
|
||||||
"type": "text",
|
"type": "text",
|
||||||
"label": "Text"
|
"label": "Text"
|
||||||
}
|
}
|
||||||
|
|
Laden …
In neuem Issue referenzieren