manifest_import_spec.rb 1.38 KB
Newer Older
1 2
require 'spec_helper'

3
describe 'Import multiple repositories by uploading a manifest file', :js, :postgresql do
4 5 6 7 8 9 10 11 12 13 14
  include Select2Helper

  let(:user) { create(:admin) }
  let(:group) { create(:group) }

  before do
    sign_in(user)

    group.add_owner(user)
  end

15
  it 'parses manifest file and list repositories' do
16 17 18
    visit new_import_manifest_path

    attach_file('manifest', Rails.root.join('spec/fixtures/aosp_manifest.xml'))
19
    click_on 'List available repositories'
20 21 22 23

    expect(page).to have_button('Import all repositories')
    expect(page).to have_content('https://android-review.googlesource.com/platform/build/blueprint')
  end
24 25 26 27 28

  it 'imports succesfully imports a project' do
    visit new_import_manifest_path

    attach_file('manifest', Rails.root.join('spec/fixtures/aosp_manifest.xml'))
29
    click_on 'List available repositories'
30 31 32 33 34 35 36 37 38

    page.within(first_row) do
      click_on 'Import'

      expect(page).to have_content 'Done'
      expect(page).to have_content("#{group.full_path}/build/make")
    end
  end

39 40 41 42 43 44 45 46 47
  it 'renders an error if invalid file was provided' do
    visit new_import_manifest_path

    attach_file('manifest', Rails.root.join('spec/fixtures/banana_sample.gif'))
    click_on 'List available repositories'

    expect(page).to have_content 'The uploaded file is not a valid XML file.'
  end

48 49 50
  def first_row
    page.all('table.import-jobs tbody tr')[0]
  end
51
end