Show link to the first question
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Legislation::Question, type: :model do
|
||||
let(:legislation_question) { build(:legislation_question) }
|
||||
let(:question) { create(:legislation_question) }
|
||||
|
||||
it "should be valid" do
|
||||
expect(legislation_question).to be_valid
|
||||
expect(question).to be_valid
|
||||
end
|
||||
|
||||
context "can be deleted" do
|
||||
@@ -17,7 +17,6 @@ RSpec.describe Legislation::Question, type: :model do
|
||||
end
|
||||
|
||||
example "when it has options but no answers" do
|
||||
question = create(:legislation_question)
|
||||
create(:legislation_question_option, question: question, value: "Yes")
|
||||
create(:legislation_question_option, question: question, value: "No")
|
||||
|
||||
@@ -27,7 +26,6 @@ RSpec.describe Legislation::Question, type: :model do
|
||||
end
|
||||
|
||||
example "when it has options and answers" do
|
||||
question = create(:legislation_question)
|
||||
option_1 = create(:legislation_question_option, question: question, value: "Yes")
|
||||
option_2 = create(:legislation_question_option, question: question, value: "No")
|
||||
create(:legislation_answer, question: question, question_option: option_1)
|
||||
@@ -38,4 +36,27 @@ RSpec.describe Legislation::Question, type: :model do
|
||||
end.to change { Legislation::Question.count }.by(-1)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#next_question_id" do
|
||||
let!(:question1) { create(:legislation_question) }
|
||||
let!(:question2) { create(:legislation_question, legislation_process_id: question1.legislation_process_id) }
|
||||
|
||||
it "should return the next question" do
|
||||
expect(question1.next_question_id).to eq(question2.id)
|
||||
end
|
||||
|
||||
it "should return nil" do
|
||||
expect(question2.next_question_id).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
describe "#first_question_id" do
|
||||
let!(:question1) { create(:legislation_question) }
|
||||
let!(:question2) { create(:legislation_question, legislation_process_id: question1.legislation_process_id) }
|
||||
|
||||
it "should return the first question" do
|
||||
expect(question1.first_question_id).to eq(question1.id)
|
||||
expect(question2.first_question_id).to eq(question1.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user