projects.rb 1.76 KB
Newer Older
1
class Spinach::Features::AdminProjects < Spinach::FeatureSteps
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
2 3 4
  include SharedAuthentication
  include SharedPaths
  include SharedAdmin
Artem Sidorenko's avatar
Artem Sidorenko committed
5 6 7 8 9 10 11
  include SharedProject

  step 'I should see all non-archived projects' do
    Project.non_archived.each do |p|
      expect(page).to have_content p.name_with_namespace
    end
  end
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
12

13
  step 'I should see all projects' do
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
14
    Project.all.each do |p|
15
      expect(page).to have_content p.name_with_namespace
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
16 17 18
    end
  end

Artem Sidorenko's avatar
Artem Sidorenko committed
19 20 21 22 23 24 25 26 27
  step 'I check "Show archived projects"' do
    page.check 'Show archived projects'
    click_button "Search"
  end

  step 'I should see "archived" label' do
    expect(page).to have_xpath("//span[@class='label label-warning']", text: 'archived')
  end

28
  step 'I click on first project' do
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
29 30 31
    click_link Project.first.name_with_namespace
  end

32
  step 'I should see project details' do
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
33
    project = Project.first
34 35 36
    expect(current_path).to eq admin_namespace_project_path(project.namespace, project)
    expect(page).to have_content(project.name_with_namespace)
    expect(page).to have_content(project.creator.name)
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
37
  end
38 39

  step 'I visit admin project page' do
Vinnie Okada's avatar
Vinnie Okada committed
40
    visit admin_namespace_project_path(project.namespace, project)
41 42 43
  end

  step 'I transfer project to group \'Web\'' do
44 45
    allow_any_instance_of(Projects::TransferService).
      to receive(:move_uploads_to_new_namespace).and_return(true)
Vinnie Okada's avatar
Vinnie Okada committed
46
    find(:xpath, "//input[@id='new_namespace_id']").set group.id
47 48 49 50 51 52 53 54
    click_button 'Transfer'
  end

  step 'group \'Web\'' do
    create(:group, name: 'Web')
  end

  step 'I should see project transfered' do
55 56
    expect(page).to have_content 'Web / ' + project.name
    expect(page).to have_content 'Namespace: Web'
57 58 59 60 61 62 63 64 65
  end

  def project
    @project ||= Project.first
  end

  def group
    Group.find_by(name: 'Web')
  end
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
66
end