browse_files.rb 4.28 KB
Newer Older
1
class Spinach::Features::ProjectSourceBrowseFiles < Spinach::FeatureSteps
Nihad Abbasov's avatar
Nihad Abbasov committed
2 3 4
  include SharedAuthentication
  include SharedProject
  include SharedPaths
5
  include RepoHelpers
Nihad Abbasov's avatar
Nihad Abbasov committed
6

7
  step 'I should see files from repository' do
8 9 10
    page.should have_content "VERSION"
    page.should have_content ".gitignore"
    page.should have_content "LICENSE"
11 12
  end

13 14 15 16
  step 'I should see files from repository for "6d39438"' do
    current_path.should == project_tree_path(@project, "6d39438")
    page.should have_content ".gitignore"
    page.should have_content "LICENSE"
17 18
  end

Ciro Santilli's avatar
Ciro Santilli committed
19 20 21 22 23 24 25 26
  step 'I see the ".gitignore"' do
    page.should have_content '.gitignore'
  end

  step 'I don\'t see the ".gitignore"' do
    page.should_not have_content '.gitignore'
  end

27 28
  step 'I click on ".gitignore" file in repo' do
    click_link ".gitignore"
29 30
  end

Ciro Santilli's avatar
Ciro Santilli committed
31
  step 'I should see its content' do
Ciro Santilli's avatar
Ciro Santilli committed
32 33 34 35 36
    page.should have_content old_gitignore_content
  end

  step 'I should see its new content' do
    page.should have_content new_gitignore_content
37 38
  end

39 40
  step 'I click link "Raw"' do
    click_link 'Raw'
41 42
  end

43
  step 'I should see raw file content' do
44
    source.should == sample_blob.data
45
  end
Valeriy Sizov's avatar
Valeriy Sizov committed
46

47 48
  step 'I click button "Edit"' do
    click_link 'Edit'
Valeriy Sizov's avatar
Valeriy Sizov committed
49 50
  end

51
  step 'I can edit code' do
Ciro Santilli's avatar
Ciro Santilli committed
52 53
    set_new_content
    evaluate_script('editor.getValue()').should == new_gitignore_content
Valeriy Sizov's avatar
Valeriy Sizov committed
54 55
  end

skv-headless's avatar
skv-headless committed
56
  step 'I edit code' do
Ciro Santilli's avatar
Ciro Santilli committed
57 58 59 60 61 62 63
    set_new_content
  end

  step 'I fill the new file name' do
    fill_in :file_name, with: new_file_name
  end

64 65 66 67
  step 'I fill the new file name with an illegal name' do
    fill_in :file_name, with: '.git'
  end

Ciro Santilli's avatar
Ciro Santilli committed
68 69
  step 'I fill the commit message' do
    fill_in :commit_message, with: 'Not yet a commit message.'
skv-headless's avatar
skv-headless committed
70 71 72 73 74 75
  end

  step 'I click link "Diff"' do
    click_link 'Diff'
  end

76 77
  step 'I click on "Commit Changes"' do
    click_button 'Commit Changes'
Ciro Santilli's avatar
Ciro Santilli committed
78 79
  end

80 81
  step 'I click on "Remove"' do
    click_link 'Remove'
Ciro Santilli's avatar
Ciro Santilli committed
82 83 84 85 86 87
  end

  step 'I click on "Remove file"' do
    click_button 'Remove file'
  end

skv-headless's avatar
skv-headless committed
88 89 90 91
  step 'I see diff' do
    page.should have_css '.line_holder.new'
  end

92 93 94 95 96 97 98 99 100
  step 'I click on "new file" link in repo' do
    click_link 'new-file-link'
  end

  step 'I can see new file page' do
    page.should have_content "New file"
    page.should have_content "File name"
    page.should have_content "Commit message"
  end
101

102 103
  step 'I click on files directory' do
    click_link 'files'
104 105
  end

106 107
  step 'I click on History link' do
    click_link 'History'
108 109 110 111 112 113 114 115
  end

  step 'I see Browse dir link' do
    page.should have_link 'Browse Dir »'
    page.should_not have_link 'Browse Code »'
  end

  step 'I click on readme file' do
116 117 118
    within '.tree-table' do
      click_link 'README.md'
    end
119 120 121 122 123 124 125 126 127 128 129 130
  end

  step 'I see Browse file link' do
    page.should have_link 'Browse File »'
    page.should_not have_link 'Browse Code »'
  end

  step 'I see Browse code link' do
    page.should have_link 'Browse Code »'
    page.should_not have_link 'Browse File »'
    page.should_not have_link 'Browse Dir »'
  end
131

132 133
  step 'I click on Permalink' do
    click_link 'Permalink'
134 135
  end

Ciro Santilli's avatar
Ciro Santilli committed
136 137 138 139 140 141 142 143
  step 'I am redirected to the files URL' do
    current_path.should == project_tree_path(@project, 'master')
  end

  step 'I am redirected to the ".gitignore"' do
    expect(current_path).to eq(project_blob_path(@project, 'master/.gitignore'))
  end

144 145 146 147 148
  step 'I am redirected to the permalink URL' do
    expect(current_path).to eq(project_blob_path(
      @project, @project.repository.commit.sha + '/.gitignore'))
  end

Ciro Santilli's avatar
Ciro Santilli committed
149 150 151 152 153
  step 'I am redirected to the new file' do
    expect(current_path).to eq(project_blob_path(
      @project, 'master/' + new_file_name))
  end

154 155 156
  step "I don't see the permalink link" do
    expect(page).not_to have_link('permalink')
  end
Ciro Santilli's avatar
Ciro Santilli committed
157

158 159 160 161
  step 'I see a commit error message' do
    expect(page).to have_content('Your changes could not be committed')
  end

Ciro Santilli's avatar
Ciro Santilli committed
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183
  private

  def set_new_content
    execute_script("editor.setValue('#{new_gitignore_content}')")
  end

  # Content of the gitignore file on the seed repository.
  def old_gitignore_content
    '*.rbc'
  end

  # Constant value that differs from the content
  # of the gitignore of the seed repository.
  def new_gitignore_content
    old_gitignore_content + 'a'
  end

  # Constant value that is a valid filename and
  # not a filename present at root of the seed repository.
  def new_file_name
    'not_a_file.md'
  end
184
end