Skip to content

Commit

Permalink
Merge pull request #1859 from openstax/bc-preview
Browse files Browse the repository at this point in the history
use page title as fallback if preview can't be parsed
  • Loading branch information
nathanstitt authored Apr 15, 2019
2 parents f71205b + 30b2b85 commit 52f5ec5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
3 changes: 1 addition & 2 deletions app/subsystems/tasks/models/tasked_reading.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ def has_learning_objectives?
end

def content_preview
text = document_title.presence || data_title.presence || class_title.presence
text || "Reading Step ##{id}"
document_title.presence || data_title.presence || class_title.presence || task_step.page.title
end

private
Expand Down
5 changes: 2 additions & 3 deletions spec/subsystems/tasks/models/tasked_reading_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
it { is_expected.to validate_presence_of(:content) }

describe '#content_preview' do
let(:default_reading_copy) { "Reading Step ##{tasked_reading.id}" }

before do
tasked_reading.content = content
Expand Down Expand Up @@ -77,8 +76,8 @@
HTML
end

it "defaults to an expected copy" do
expect(tasked_reading.content_preview).to eq(default_reading_copy)
it "defaults to page title" do
expect(tasked_reading.content_preview).to eq(tasked_reading.task_step.page.title)
end
end
end
Expand Down

0 comments on commit 52f5ec5

Please sign in to comment.