Fix failing specs
Dieser Commit ist enthalten in:
Ursprung
0e5fc756df
Commit
403f063b0f
2 geänderte Dateien mit 39 neuen und 34 gelöschten Zeilen
|
@ -13,39 +13,44 @@ describe CustomWizard::Submission do
|
||||||
|
|
||||||
before do
|
before do
|
||||||
CustomWizard::Template.save(template_json, skip_jobs: true)
|
CustomWizard::Template.save(template_json, skip_jobs: true)
|
||||||
|
|
||||||
template_json_2 = template_json.dup
|
|
||||||
template_json_2["id"] = "super_mega_fun_wizard_2"
|
|
||||||
CustomWizard::Template.save(template_json_2, skip_jobs: true)
|
|
||||||
|
|
||||||
@wizard = CustomWizard::Wizard.create(template_json["id"], user)
|
@wizard = CustomWizard::Wizard.create(template_json["id"], user)
|
||||||
@wizard2 = CustomWizard::Wizard.create(template_json["id"], user2)
|
described_class.new(@wizard, step_1_field_1: "I am user submission").save
|
||||||
@wizard3 = CustomWizard::Wizard.create(template_json_2["id"], user)
|
|
||||||
@count = CustomWizard::Submission::PAGE_LIMIT + 20
|
|
||||||
|
|
||||||
@count.times do |index|
|
|
||||||
described_class.new(@wizard, step_1_field_1: "I am user submission #{index + 1}").save
|
|
||||||
end
|
|
||||||
described_class.new(@wizard2, step_1_field_1: "I am another user's submission").save
|
|
||||||
described_class.new(@wizard3, step_1_field_1: "I am a user submission on another wizard").save
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it "saves a user's submission" do
|
it "saves a user's submission" do
|
||||||
expect(
|
expect(
|
||||||
described_class.get(@wizard, user.id).fields["step_1_field_1"]
|
described_class.get(@wizard, user.id).fields["step_1_field_1"]
|
||||||
).to eq("I am user submission #{@count}")
|
).to eq("I am user submission")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "list submissions by wizard" do
|
context "#list" do
|
||||||
expect(described_class.list(@wizard).total).to eq(@count + 1)
|
before do
|
||||||
end
|
template_json_2 = template_json.dup
|
||||||
|
template_json_2["id"] = "super_mega_fun_wizard_2"
|
||||||
|
CustomWizard::Template.save(template_json_2, skip_jobs: true)
|
||||||
|
|
||||||
it "list submissions by wizard and user" do
|
@wizard2 = CustomWizard::Wizard.create(template_json["id"], user2)
|
||||||
expect(described_class.list(@wizard, user_id: user.id).total).to eq(@count)
|
@wizard3 = CustomWizard::Wizard.create(template_json_2["id"], user)
|
||||||
end
|
@count = CustomWizard::Submission::PAGE_LIMIT + 20
|
||||||
|
|
||||||
it "paginates submission lists" do
|
@count.times do |index|
|
||||||
expect(described_class.list(@wizard, page: 1).submissions.size).to eq((@count + 1) - CustomWizard::Submission::PAGE_LIMIT)
|
described_class.new(@wizard, step_1_field_1: "I am user submission #{index + 1}").save
|
||||||
|
end
|
||||||
|
described_class.new(@wizard2, step_1_field_1: "I am another user's submission").save
|
||||||
|
described_class.new(@wizard3, step_1_field_1: "I am a user submission on another wizard").save
|
||||||
|
end
|
||||||
|
|
||||||
|
it "list submissions by wizard" do
|
||||||
|
expect(described_class.list(@wizard).total).to eq(@count + 2)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "list submissions by wizard and user" do
|
||||||
|
expect(described_class.list(@wizard, user_id: user.id).total).to eq(@count + 1)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "paginates submission lists" do
|
||||||
|
expect(described_class.list(@wizard, page: 1).submissions.size).to eq((@count + 2) - CustomWizard::Submission::PAGE_LIMIT)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "#cleanup_incomplete_submissions" do
|
context "#cleanup_incomplete_submissions" do
|
||||||
|
@ -54,10 +59,10 @@ describe CustomWizard::Submission do
|
||||||
described_class.new(@wizard, step_1_field_1: "I am the second submission").save
|
described_class.new(@wizard, step_1_field_1: "I am the second submission").save
|
||||||
builder = CustomWizard::Builder.new(@wizard.id, @wizard.user)
|
builder = CustomWizard::Builder.new(@wizard.id, @wizard.user)
|
||||||
builder.build
|
builder.build
|
||||||
sub_list = described_class.list(@wizard, user_id: @wizard.user.id)
|
submissions = described_class.list(@wizard, user_id: @wizard.user.id).submissions
|
||||||
|
|
||||||
expect(sub_list.length).to eq(1)
|
expect(submissions.length).to eq(1)
|
||||||
expect(sub_list.first.fields["step_1_field_1"]).to eq("I am the second submission")
|
expect(submissions.first.fields["step_1_field_1"]).to eq("I am the second submission")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "handles submissions without 'updated_at' field correctly" do
|
it "handles submissions without 'updated_at' field correctly" do
|
||||||
|
@ -70,10 +75,10 @@ describe CustomWizard::Submission do
|
||||||
PluginStore.set("#{@wizard.id}_submissions", @wizard.user.id, sub_data)
|
PluginStore.set("#{@wizard.id}_submissions", @wizard.user.id, sub_data)
|
||||||
builder = CustomWizard::Builder.new(@wizard.id, @wizard.user)
|
builder = CustomWizard::Builder.new(@wizard.id, @wizard.user)
|
||||||
builder.build
|
builder.build
|
||||||
sub_list = described_class.list(@wizard, user_id: @wizard.user.id)
|
submissions = described_class.list(@wizard, user_id: @wizard.user.id).submissions
|
||||||
|
|
||||||
expect(sub_list.length).to eq(1)
|
expect(submissions.length).to eq(1)
|
||||||
expect(sub_list.first.fields["step_1_field_1"]).to eq("I am the third submission")
|
expect(submissions.first.fields["step_1_field_1"]).to eq("I am the third submission")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "handles submissions with and without 'updated_at' field correctly" do
|
it "handles submissions with and without 'updated_at' field correctly" do
|
||||||
|
@ -87,10 +92,10 @@ describe CustomWizard::Submission do
|
||||||
|
|
||||||
builder = CustomWizard::Builder.new(@wizard.id, @wizard.user)
|
builder = CustomWizard::Builder.new(@wizard.id, @wizard.user)
|
||||||
builder.build
|
builder.build
|
||||||
sub_list = described_class.list(@wizard, user_id: @wizard.user.id)
|
submissions = described_class.list(@wizard, user_id: @wizard.user.id).submissions
|
||||||
|
|
||||||
expect(sub_list.length).to eq(1)
|
expect(submissions.length).to eq(1)
|
||||||
expect(sub_list.first.fields["step_1_field_1"]).to eq("I am the third submission")
|
expect(submissions.first.fields["step_1_field_1"]).to eq("I am the third submission")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -84,9 +84,9 @@ describe CustomWizard::WizardController do
|
||||||
CustomWizard::Submission.new(@wizard, step_1_field_1: "Hello World").save
|
CustomWizard::Submission.new(@wizard, step_1_field_1: "Hello World").save
|
||||||
current_submission = @wizard.current_submission
|
current_submission = @wizard.current_submission
|
||||||
put '/w/super-mega-fun-wizard/skip.json'
|
put '/w/super-mega-fun-wizard/skip.json'
|
||||||
list = CustomWizard::Submission.list(@wizard)
|
submissions = CustomWizard::Submission.list(@wizard).submissions
|
||||||
|
|
||||||
expect(list.any? { |submission| submission.id == current_submission.id }).to eq(false)
|
expect(submissions.any? { |submission| submission.id == current_submission.id }).to eq(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "starts from the first step if user visits after skipping the wizard" do
|
it "starts from the first step if user visits after skipping the wizard" do
|
||||||
|
|
Laden …
In neuem Issue referenzieren