path_locks_spec.rb 1.63 KB
Newer Older
Valery Sizov's avatar
Valery Sizov committed
1 2
require 'spec_helper'

3
feature 'Path Locks', :js do
Valery Sizov's avatar
Valery Sizov committed
4
  let(:user) { create(:user) }
5
  let(:project) { create(:project, :repository, namespace: user.namespace) }
6
  let(:tree_path) { project_tree_path(project, project.repository.root_ref) }
Valery Sizov's avatar
Valery Sizov committed
7 8

  before do
Nick Thomas's avatar
Nick Thomas committed
9
    allow(project).to receive(:feature_available?).with(:file_locks) { true }
Valery Sizov's avatar
Valery Sizov committed
10 11

    project.team << [user, :master]
12
    sign_in(user)
Valery Sizov's avatar
Valery Sizov committed
13

14
    visit tree_path
Valery Sizov's avatar
Valery Sizov committed
15 16 17 18 19 20
  end

  scenario 'Locking folders' do
    within '.tree-content-holder' do
      click_link "encoding"
    end
Rémy Coutable's avatar
Rémy Coutable committed
21
    click_link "Lock"
22 23 24

    expect(page).to have_selector('.fa-lock')

25
    visit tree_path
Rémy Coutable's avatar
Rémy Coutable committed
26 27

    expect(page).to have_selector('.fa-lock')
Valery Sizov's avatar
Valery Sizov committed
28 29 30 31 32 33 34 35 36 37 38
  end

  scenario 'Locking files' do
    page_tree = find('.tree-content-holder')

    within page_tree do
      click_link "VERSION"
    end

    within '.file-actions' do
      click_link "Lock"
39 40

      expect(page).to have_link('Unlock')
Valery Sizov's avatar
Valery Sizov committed
41 42
    end

43
    visit tree_path
Valery Sizov's avatar
Valery Sizov committed
44 45 46 47 48 49

    within page_tree do
      expect(page).to have_selector('.fa-lock')
    end
  end

50
  scenario 'Unlocking files' do
51
    within find('.tree-content-holder') do
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
      click_link "VERSION"
    end

    within '.file-actions' do
      click_link "Lock"

      expect(page).to have_link('Unlock')
    end

    within '.file-actions' do
      click_link "Unlock"

      expect(page).to have_link('Lock')
    end
  end

Valery Sizov's avatar
Valery Sizov committed
68 69 70 71 72 73 74 75
  scenario 'Managing of lock list' do
    create :path_lock, path: 'encoding', user: user, project: project

    click_link "Locked Files"

    within '.locks' do
      expect(page).to have_content('encoding')

76
      accept_confirm { find('.btn-remove').click }
Valery Sizov's avatar
Valery Sizov committed
77 78 79 80 81

      expect(page).not_to have_content('encoding')
    end
  end
end