Skip to content

Commit

Permalink
Import section-video-highlight
Browse files Browse the repository at this point in the history
  • Loading branch information
gburgett committed Oct 24, 2018
1 parent 83de25e commit b2f3274
Show file tree
Hide file tree
Showing 5 changed files with 286 additions and 0 deletions.
18 changes: 18 additions & 0 deletions wcc-contentful-app/app/views/sections/_video_highlight.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<div class="row justify-content-center">
<div class="col col-md-6">
<% if section.tag.present? %>
<span class="section-video-highlight__tag"><%= section.tag %></span>
<% end %>
<h2 class="section-video-highlight__title"><%= section.title %></h2>
<% if section.subtext.present? %>
<div class="section-video-highlight__subtext">
<%= markdown(section.subtext) %>
</div>
<% end %>
</div>
<div class="column medium-6">
<div class="video-responsive section-video-highlight__video">
<%= raw section.embed_code %>
</div>
</div>
</div><!--row-->
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import Migration, { MigrationFunction } from 'contentful-migration'

// Generated by contentful-schema-diff
// from empty-export.json
// to 7yx6ovlj39n5
export = function(migration : Migration, { makeRequest, spaceId, accessToken }) {

/************ section-video-highlight ******************/

var sectionVideoHighlight = migration.createContentType('section-video-highlight', {
displayField: 'internalTitle',
name: 'Section: Video Highlight',
description: 'Highlight a video with some text'
})

sectionVideoHighlight.createField('internalTitle', {
name: 'Internal Title (Contentful Only)',
type: 'Symbol',
localized: false,
required: true,
validations: [],
disabled: false,
omitted: true
})

sectionVideoHighlight.createField('tag', {
name: 'Tag',
type: 'Symbol',
localized: true,
required: false,
validations:
[{
size: { max: 75 },
message: 'Tag must be short!'
}],
disabled: false,
omitted: false
})

sectionVideoHighlight.createField('title', {
name: 'Title',
type: 'Symbol',
localized: false,
required: true,
validations: [],
disabled: false,
omitted: false
})

sectionVideoHighlight.createField('subtext', {
name: 'Subtext',
type: 'Text',
localized: true,
required: false,
validations: [{ size: { max: 500 } }],
disabled: false,
omitted: false
})

sectionVideoHighlight.createField('embedCode', {
name: 'Embed Code',
type: 'Text',
localized: false,
required: true,
validations: [],
disabled: false,
omitted: false
})

sectionVideoHighlight.changeEditorInterface('tag', 'singleLine')

sectionVideoHighlight.changeEditorInterface('title', 'singleLine')

sectionVideoHighlight.changeEditorInterface('subtext', 'markdown')

sectionVideoHighlight.changeEditorInterface('embedCode', 'markdown')

sectionVideoHighlight.changeEditorInterface('internalTitle', 'singleLine')

} as MigrationFunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# frozen_string_literal: true
# This model represents the 'section-video-highlight' content type in Contentful. Any linked
# entries of the 'section-video-highlight' content type will be resolved as instances of this class.
# It exposes .find, .find_by, and .find_all methods to query Contentful.
class SectionVideoHighlight < WCC::Contentful::Model::SectionVideoHighlight
# Add custom validations to ensure that app-specific properties exist:
# validate_field :foo, :String, :required
# validate_field :bar_links, :Array, link_to: %w[bar baz]
# Override functionality or add utilities
#
# # Example: override equality
# def ===(other)
# ...
# end
#
# # Example: override "title" attribute to always be titlecase.
# # `@title` is populated by the gem in the initializer.
# def title
# @title_titlecased ||= @title.titlecase
# end
end
Original file line number Diff line number Diff line change
Expand Up @@ -2609,6 +2609,128 @@
"omitted": false
}
]
},
{
"sys": {
"space": {
"sys": {
"type": "Link",
"linkType": "Space",
"id": "7yx6ovlj39n5"
}
},
"id": "section-video-highlight",
"type": "ContentType",
"createdAt": "2018-04-16T18:37:25.985Z",
"updatedAt": "2018-06-29T21:21:23.175Z",
"environment": {
"sys": {
"id": "master",
"type": "Link",
"linkType": "Environment"
}
},
"createdBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "0SUbYs2vZlXjVR6bH6o83O"
}
},
"updatedBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "2Rw3pZANDXJEtKNoPuE40I"
}
},
"publishedCounter": 3,
"version": 6,
"publishedBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "2Rw3pZANDXJEtKNoPuE40I"
}
},
"publishedVersion": 5,
"firstPublishedAt": "2018-04-16T18:37:26.238Z",
"publishedAt": "2018-06-29T21:21:23.175Z"
},
"displayField": "internalTitle",
"name": "Section: Video Highlight",
"description": "Highlight a video with some text",
"fields": [
{
"id": "internalTitle",
"name": "Internal Title (Contentful Only)",
"type": "Symbol",
"localized": false,
"required": true,
"validations": [

],
"disabled": false,
"omitted": true
},
{
"id": "tag",
"name": "Tag",
"type": "Symbol",
"localized": true,
"required": false,
"validations": [
{
"size": {
"max": 75
},
"message": "Tag must be short!"
}
],
"disabled": false,
"omitted": false
},
{
"id": "title",
"name": "Title",
"type": "Symbol",
"localized": false,
"required": true,
"validations": [

],
"disabled": false,
"omitted": false
},
{
"id": "subtext",
"name": "Subtext",
"type": "Text",
"localized": true,
"required": false,
"validations": [
{
"size": {
"max": 500
}
}
],
"disabled": false,
"omitted": false
},
{
"id": "embedCode",
"name": "Embed Code",
"type": "Text",
"localized": false,
"required": true,
"validations": [

],
"disabled": false,
"omitted": false
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# frozen_string_literal: true

require 'rails_helper'

RSpec.describe 'sections/video_highlight' do
helper WCC::Contentful::App::SectionHelper

it 'renders successfully' do
section = contentful_create('section-video-highlight')

render partial: 'components/section', locals: { section: section }

expect(rendered).to have_css('section.section-video-highlight.default')
end

it 'renders raw embed code' do
section = contentful_create('section-video-highlight',
embed_code: '<video src="youtu.be/asdf">')

render partial: 'components/section', locals: { section: section }

expect(rendered).to include('<video src="youtu.be/asdf">')
end

it 'renders tag' do
section = contentful_create('section-video-highlight',
tag: 'Some Video')

render partial: 'components/section', locals: { section: section }

body = Capybara.string(rendered)
expect(body.find('.section-video-highlight__tag').text.strip).to eq('Some Video')
end

it 'renders markdown subtext' do
section = contentful_create('section-video-highlight',
subtext: '## expect h2')

render partial: 'components/section', locals: { section: section }

body = Capybara.string(rendered)
subtext = body.find('.section-video-highlight__subtext')
expect(subtext.find('h2').text.strip).to eq('expect h2')
end
end

0 comments on commit b2f3274

Please sign in to comment.