This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# These two queries | |
subject_categories = SubjectCategory.in_alphabetical_order | |
interested_subject_categories = current_user.interested_subject_categories | |
# will now return the objects set up in our test | |
let(:subject_category_interests) { [subject_category_one, subject_category_three] } | |
let(:subject_categories) { [subject_category_one, subject_category_two, subject_category_three] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ... | |
{ fields: | |
subject_categories.map do |sc| | |
selected = interested_subject_categories.include?(sc) | |
{ title: sc.title, value: sc.id.to_s, selected: selected } | |
end | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe '#subject_category_interest_props' do | |
let(:current_user) { double(:user) } | |
let(:subject_category_one) { double(:subject_category_one, id: 1, title: 'subject-category-title-1') } | |
let(:subject_category_two) { double(:subject_category_two, id: 2, title: 'subject-category-title-2') } | |
let(:subject_category_three) { double(:subject_category_three, id: 3, title: 'subject-category-title-3') } | |
let(:subject_category_interests) { [subject_category_one, subject_category_three] } | |
let(:subject_categories) { [subject_category_one, subject_category_two, subject_category_three] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe '#subject_category_interest_props' do | |
## arrange | |
# create all subject categories | |
let!(:subject_category_one) { FactoryBot.create(:subject_category, id: 1, title: 'subject-category-title-1') } | |
let!(:subject_category_two) { FactoryBot.create(:subject_category, id: 2, title: 'subject-category-title-2') } | |
let!(:subject_category_three) { FactoryBot.create(:subject_category, id: 3, title: 'subject-category-title-3') } | |
# a learner has some subject category interests |
OlderNewer