Last active
October 17, 2018 07:37
-
-
Save neudabei/132bd16e20ce1ffd4222ec7ce4ff4fff to your computer and use it in GitHub Desktop.
fl_medium_blogpost
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 | |
let(:current_user) { FactoryBot.create(:learner) } | |
before do | |
SubjectCategoryInterest.create(learner: current_user, subject_category: subject_category_one) | |
SubjectCategoryInterest.create(learner: current_user, subject_category: subject_category_three) | |
end | |
## act and assert | |
it 'returns props containing title, value and selected status' do | |
props = { fields: [{ title: 'subject-category-title-1', value: '1', selected: true }, | |
{ title: 'subject-category-title-2', value: '2', selected: false }, | |
{ title: 'subject-category-title-3', value: '3', selected: true }] } | |
# call #subject_category_interest_props and assert they match props | |
expect(subject.subject_category_interest_props).to eq(props) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment