labels.rb 2.33 KB
Newer Older
1
class ProjectLabels < Spinach::FeatureSteps
Nihad Abbasov's avatar
Nihad Abbasov committed
2 3 4 5
  include SharedAuthentication
  include SharedProject
  include SharedPaths

Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
6 7 8 9 10 11 12 13 14 15
  step 'I visit \'bug\' label edit page' do
    visit edit_project_label_path(project, bug_label)
  end

  step 'I remove label \'bug\'' do
    within "#label_#{bug_label.id}" do
      click_link 'Remove'
    end
  end

16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
  step 'I delete all labels' do
    within '.labels' do
      all('.btn-remove').each do |remove|
        remove.click
        sleep 0.05
      end
    end
  end

  step 'I should see labels help message' do
    within '.labels' do
      page.should have_content 'Create first label or generate default set of '\
                               'labels'
    end
  end

Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
32 33 34 35 36 37
  step 'I submit new label \'support\'' do
    fill_in 'Title', with: 'support'
    fill_in 'Background Color', with: '#F95610'
    click_button 'Save'
  end

38 39 40 41 42 43
  step 'I submit new label \'bug\'' do
    fill_in 'Title', with: 'bug'
    fill_in 'Background Color', with: '#F95610'
    click_button 'Save'
  end

44 45 46 47 48 49
  step 'I submit new label with invalid color' do
    fill_in 'Title', with: 'support'
    fill_in 'Background Color', with: '#12'
    click_button 'Save'
  end

50 51 52 53 54 55
  step 'I should see label label exist error message' do
    within '.label-form' do
      page.should have_content 'Title has already been taken'
    end
  end

56 57 58 59 60 61
  step 'I should see label color error message' do
    within '.label-form' do
      page.should have_content 'Color is invalid'
    end
  end

62 63 64 65 66 67
  step 'I should see label \'feature\'' do
    within '.manage-labels-list' do
      page.should have_content 'feature'
    end
  end

68 69 70 71 72 73
  step 'I should see label \'bug\'' do
    within '.manage-labels-list' do
      page.should have_content 'bug'
    end
  end

Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
  step 'I should not see label \'bug\'' do
    within '.manage-labels-list' do
      page.should_not have_content 'bug'
    end
  end

  step 'I should see label \'support\'' do
    within '.manage-labels-list' do
      page.should have_content 'support'
    end
  end

  step 'I change label \'bug\' to \'fix\'' do
    fill_in 'Title', with: 'fix'
    fill_in 'Background Color', with: '#F15610'
    click_button 'Save'
  end

  step 'I should see label \'fix\'' do
    within '.manage-labels-list' do
      page.should have_content 'fix'
    end
  end

  def bug_label
    project.labels.find_or_create_by(title: 'bug')
  end
101
end