BigW Consortium Gitlab

markdown.rb 1.56 KB
Newer Older
1 2 3 4
module SharedMarkdown
  include Spinach::DSL

  def header_should_have_correct_id_and_link(level, text, id, parent = ".wiki")
5 6
    find(:css, "#{parent} h#{level}##{id}").text.should == text
    find(:css, "#{parent} h#{level}##{id} > :last-child")[:href].should =~ /##{id}$/
7 8
  end

9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
  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

30 31 32
  step 'Header "Description header" should have correct id and link' do
    header_should_have_correct_id_and_link(1, 'Description header', 'description-header')
  end
33 34 35 36 37 38 39

  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

40
  step 'I should see the task status for the Taskable' do
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
    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
57
end