2014-02-04 02:48:33 -05:00
|
|
|
module SharedMarkdown
|
|
|
|
include Spinach::DSL
|
|
|
|
|
|
|
|
def header_should_have_correct_id_and_link(level, text, id, parent = ".wiki")
|
2014-09-24 02:28:41 -04:00
|
|
|
find(:css, "#{parent} h#{level}##{id}").text.should == text
|
|
|
|
find(:css, "#{parent} h#{level}##{id} > :last-child")[:href].should =~ /##{id}$/
|
2014-02-04 02:48:33 -05:00
|
|
|
end
|
|
|
|
|
2014-10-06 20:19:12 -04:00
|
|
|
def create_taskable(type, title)
|
|
|
|
desc_text = <<EOT.gsub(/^ {6}/, '')
|
|
|
|
* [ ] Task 1
|
|
|
|
* [x] Task 2
|
|
|
|
EOT
|
|
|
|
|
|
|
|
case type
|
|
|
|
when :issue, :closed_issue
|
|
|
|
options = { project: project }
|
|
|
|
when :merge_request
|
|
|
|
options = { source_project: project, target_project: project }
|
|
|
|
end
|
|
|
|
|
|
|
|
create(
|
|
|
|
type,
|
|
|
|
options.merge(title: title,
|
|
|
|
author: project.users.first,
|
|
|
|
description: desc_text)
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2014-02-04 02:48:33 -05:00
|
|
|
step 'Header "Description header" should have correct id and link' do
|
|
|
|
header_should_have_correct_id_and_link(1, 'Description header', 'description-header')
|
|
|
|
end
|
2014-10-06 02:59:03 -04:00
|
|
|
|
|
|
|
step 'I should see task checkboxes in the description' do
|
|
|
|
expect(page).to have_selector(
|
|
|
|
'div.description li.task-list-item input[type="checkbox"]'
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2014-10-06 20:19:12 -04:00
|
|
|
step 'I should see the task status for the Taskable' do
|
2014-10-06 02:59:03 -04:00
|
|
|
expect(find(:css, 'span.task-status').text).to eq(
|
|
|
|
'2 tasks (1 done, 1 unfinished)'
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
step 'Task checkboxes should be enabled' do
|
|
|
|
expect(page).to have_selector(
|
|
|
|
'div.description li.task-list-item input[type="checkbox"]:enabled'
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
step 'Task checkboxes should be disabled' do
|
|
|
|
expect(page).to have_selector(
|
|
|
|
'div.description li.task-list-item input[type="checkbox"]:disabled'
|
|
|
|
)
|
|
|
|
end
|
2014-10-15 03:21:21 -04:00
|
|
|
|
|
|
|
step 'I should not see the Markdown preview' do
|
2014-10-20 22:53:17 -04:00
|
|
|
expect(find('.gfm-form .js-md-preview')).not_to be_visible
|
2014-10-15 03:21:21 -04:00
|
|
|
end
|
|
|
|
|
2014-10-17 00:36:52 -04:00
|
|
|
step 'The Markdown preview tab should say there is nothing to do' do
|
2014-10-18 19:24:12 -04:00
|
|
|
within('.gfm-form') do
|
2014-10-17 00:36:52 -04:00
|
|
|
find('.js-md-preview-button').click
|
|
|
|
expect(find('.js-md-preview')).to have_content('Nothing to preview.')
|
|
|
|
end
|
2014-10-15 03:21:21 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
step 'I should not see the Markdown text field' do
|
2014-10-20 22:53:17 -04:00
|
|
|
expect(find('.gfm-form textarea')).not_to be_visible
|
2014-10-15 03:21:21 -04:00
|
|
|
end
|
|
|
|
|
2014-10-17 00:36:52 -04:00
|
|
|
step 'I should see the Markdown write tab' do
|
2014-10-20 22:53:17 -04:00
|
|
|
expect(find('.gfm-form')).to have_css('.js-md-write-button', visible: true)
|
2014-10-15 03:21:21 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
step 'I should see the Markdown preview' do
|
2014-10-20 22:53:17 -04:00
|
|
|
expect(find('.gfm-form')).to have_css('.js-md-preview', visible: true)
|
2014-10-15 03:21:21 -04:00
|
|
|
end
|
|
|
|
|
2014-10-17 00:36:52 -04:00
|
|
|
step 'The Markdown preview tab should display rendered Markdown' do
|
2014-10-18 19:24:12 -04:00
|
|
|
within('.gfm-form') do
|
2014-10-17 00:36:52 -04:00
|
|
|
find('.js-md-preview-button').click
|
2014-10-20 22:53:17 -04:00
|
|
|
expect(find('.js-md-preview')).to have_css('img.emoji', visible: true)
|
2014-10-17 00:36:52 -04:00
|
|
|
end
|
2014-10-15 03:21:21 -04:00
|
|
|
end
|
|
|
|
|
2014-10-17 00:36:52 -04:00
|
|
|
step 'I write a description like ":+1: Nice"' do
|
|
|
|
find('.gfm-form').fill_in 'Description', with: ':+1: Nice'
|
2014-10-15 03:21:21 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
step 'I preview a description text like "Bug fixed :smile:"' do
|
|
|
|
within('.gfm-form') do
|
|
|
|
fill_in 'Description', with: 'Bug fixed :smile:'
|
2014-10-18 19:24:12 -04:00
|
|
|
find('.js-md-preview-button').click
|
2014-10-15 03:21:21 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
step 'I haven\'t written any description text' do
|
|
|
|
find('.gfm-form').fill_in 'Description', with: ''
|
|
|
|
end
|
2014-02-04 02:48:33 -05:00
|
|
|
end
|