Commit c2c7d14e authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Move all test repos data to ReposHelpers

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent bb2f4d66
...@@ -38,10 +38,6 @@ Feature: Project Browse commits ...@@ -38,10 +38,6 @@ Feature: Project Browse commits
Given I visit big commit page Given I visit big commit page
Then I see big commit warning Then I see big commit warning
Scenario: I browse huge commit
Given I visit huge commit page
Then I see huge commit message
Scenario: I browse a commit with an image Scenario: I browse a commit with an image
Given I visit a commit with an image that changed Given I visit a commit with an image that changed
Then The diff links to both the previous and current image Then The diff links to both the previous and current image
...@@ -2,13 +2,14 @@ Feature: Project Browse Commits User Lookup ...@@ -2,13 +2,14 @@ Feature: Project Browse Commits User Lookup
Background: Background:
Given I sign in as a user Given I sign in as a user
And I own a project And I own a project
And I have the user that authored the commits
And I visit my project's commits page And I visit my project's commits page
Scenario: I browse commit from list Scenario: I browse commit from list
Given I click on commit link Given I have user with primary email
Then I see commit info When I click on commit link
Then I see author based on primary email
Scenario: I browse another commit from list Scenario: I browse another commit from list
Given I click on another commit link Given I have user with secondary email
Then I see other commit info When I click on another commit link
Then I see author based on secondary email
...@@ -2,11 +2,12 @@ class ProjectBrowseCommits < Spinach::FeatureSteps ...@@ -2,11 +2,12 @@ class ProjectBrowseCommits < Spinach::FeatureSteps
include SharedAuthentication include SharedAuthentication
include SharedProject include SharedProject
include SharedPaths include SharedPaths
include RepoHelpers
Then 'I see project commits' do Then 'I see project commits' do
commit = @project.repository.commit commit = @project.repository.commit
page.should have_content(@project.name) page.should have_content(@project.name)
page.should have_content(commit.message) page.should have_content(commit.message[0..20])
page.should have_content(commit.id.to_s[0..5]) page.should have_content(commit.id.to_s[0..5])
end end
...@@ -19,21 +20,21 @@ class ProjectBrowseCommits < Spinach::FeatureSteps ...@@ -19,21 +20,21 @@ class ProjectBrowseCommits < Spinach::FeatureSteps
page.response_headers['Content-Type'].should have_content("application/atom+xml") page.response_headers['Content-Type'].should have_content("application/atom+xml")
page.body.should have_selector("title", text: "Recent commits to #{@project.name}") page.body.should have_selector("title", text: "Recent commits to #{@project.name}")
page.body.should have_selector("author email", text: commit.author_email) page.body.should have_selector("author email", text: commit.author_email)
page.body.should have_selector("entry summary", text: commit.description) page.body.should have_selector("entry summary", text: commit.description[0..10])
end end
Given 'I click on commit link' do Given 'I click on commit link' do
visit project_commit_path(@project, ValidCommit::ID) visit project_commit_path(@project, sample_commit.id)
end end
Then 'I see commit info' do Then 'I see commit info' do
page.should have_content ValidCommit::MESSAGE page.should have_content sample_commit.message
page.should have_content "Showing 1 changed file" page.should have_content "Showing #{sample_commit.files_changed_count} changed files"
end end
And 'I fill compare fields with refs' do And 'I fill compare fields with refs' do
fill_in "from", with: "8716fc78f3c65bbf7bcf7b574febd583bc5d2812" fill_in "from", with: sample_commit.parent_id
fill_in "to", with: "bcf03b5de6c33f3869ef70d68cf06e679d1d7f9a" fill_in "to", with: sample_commit.id
click_button "Compare" click_button "Compare"
end end
...@@ -56,30 +57,24 @@ class ProjectBrowseCommits < Spinach::FeatureSteps ...@@ -56,30 +57,24 @@ class ProjectBrowseCommits < Spinach::FeatureSteps
end end
Given 'I visit big commit page' do Given 'I visit big commit page' do
visit project_commit_path(@project, BigCommits::BIG_COMMIT_ID) Commit::DIFF_SAFE_FILES = 20
visit project_commit_path(@project, sample_big_commit.id)
end end
Then 'I see big commit warning' do Then 'I see big commit warning' do
page.should have_content BigCommits::BIG_COMMIT_MESSAGE page.should have_content sample_big_commit.message
page.should have_content "Too many changes" page.should have_content "Too many changes"
end Commit::DIFF_SAFE_FILES = 100
Given 'I visit huge commit page' do
visit project_commit_path(@project, BigCommits::HUGE_COMMIT_ID)
end
Then 'I see huge commit message' do
page.should have_content BigCommits::HUGE_COMMIT_MESSAGE
end end
Given 'I visit a commit with an image that changed' do Given 'I visit a commit with an image that changed' do
visit project_commit_path(@project, 'cc1ba255d6c5ffdce87a357ba7ccc397a4f4026b') visit project_commit_path(@project, sample_image_commit.id)
end end
Then 'The diff links to both the previous and current image' do Then 'The diff links to both the previous and current image' do
links = page.all('.two-up span div a') links = page.all('.two-up span div a')
links[0]['href'].should =~ %r{blob/bc3735004cb45cec5e0e4fa92710897a910a5957} links[0]['href'].should =~ %r{blob/#{sample_image_commit.old_blob_id}}
links[1]['href'].should =~ %r{blob/cc1ba255d6c5ffdce87a357ba7ccc397a4f4026b} links[1]['href'].should =~ %r{blob/#{sample_image_commit.new_blob_id}}
end end
Given 'I click side-by-side diff button' do Given 'I click side-by-side diff button' do
...@@ -93,5 +88,4 @@ class ProjectBrowseCommits < Spinach::FeatureSteps ...@@ -93,5 +88,4 @@ class ProjectBrowseCommits < Spinach::FeatureSteps
Then 'I see inline diff button' do Then 'I see inline diff button' do
page.should have_content "Inline Diff" page.should have_content "Inline Diff"
end end
end end
...@@ -3,33 +3,46 @@ class ProjectBrowseCommitsUserLookup < Spinach::FeatureSteps ...@@ -3,33 +3,46 @@ class ProjectBrowseCommitsUserLookup < Spinach::FeatureSteps
include SharedProject include SharedProject
include SharedPaths include SharedPaths
Given 'I have the user that authored the commits' do
@user = create(:user, email: 'dmitriy.zaporozhets@gmail.com')
create(:email, { user: @user, email: 'dzaporozhets@sphereconsultinginc.com' })
end
Given 'I click on commit link' do Given 'I click on commit link' do
visit project_commit_path(@project, ValidCommit::ID) visit project_commit_path(@project, sample_commit.id)
end end
Given 'I click on another commit link' do Given 'I click on another commit link' do
visit project_commit_path(@project, ValidCommitWithAltEmail::ID) visit project_commit_path(@project, sample_commit.parent_id)
end
step 'I have user with primary email' do
user_primary
end
step 'I have user with secondary email' do
user_secondary
end end
Then 'I see commit info' do step 'I see author based on primary email' do
page.should have_content ValidCommit::MESSAGE check_author_link(sample_commit.author_email, user_primary)
check_author_link(ValidCommit::AUTHOR_EMAIL)
end end
Then 'I see other commit info' do step 'I see author based on secondary email' do
page.should have_content ValidCommitWithAltEmail::MESSAGE check_author_link(sample_commit.author_email, user_secondary)
check_author_link(ValidCommitWithAltEmail::AUTHOR_EMAIL)
end end
def check_author_link(email) def check_author_link(email, user)
author_link = find('.commit-author-link') author_link = find('.commit-author-link')
author_link['href'].should == user_path(@user) author_link['href'].should == user_path(user)
author_link['data-original-title'].should == email author_link['data-original-title'].should == email
find('.commit-author-name').text.should == @user.name find('.commit-author-name').text.should == user.name
end
def user_primary
@user_primary ||= create(:user, email: 'dmitriy.zaporozhets@gmail.com')
end
def user_secondary
@user_secondary ||= begin
user = create(:user, email: 'dzaporozhets@example.com')
create(:email, { user: user, email: 'dmitriy.zaporozhets@gmail.com' })
user
end
end end
end end
...@@ -2,6 +2,7 @@ class ProjectBrowseFiles < Spinach::FeatureSteps ...@@ -2,6 +2,7 @@ class ProjectBrowseFiles < Spinach::FeatureSteps
include SharedAuthentication include SharedAuthentication
include SharedProject include SharedProject
include SharedPaths include SharedPaths
include RepoHelpers
step 'I should see files from repository' do step 'I should see files from repository' do
page.should have_content "VERSION" page.should have_content "VERSION"
...@@ -28,7 +29,7 @@ class ProjectBrowseFiles < Spinach::FeatureSteps ...@@ -28,7 +29,7 @@ class ProjectBrowseFiles < Spinach::FeatureSteps
end end
step 'I should see raw file content' do step 'I should see raw file content' do
page.source.should == ValidCommit::BLOB_FILE page.source.should == sample_blob.data
end end
step 'I click button "edit"' do step 'I click button "edit"' do
......
module SharedPaths module SharedPaths
include Spinach::DSL include Spinach::DSL
include RepoHelpers
step 'I visit new project page' do step 'I visit new project page' do
visit new_project_path visit new_project_path
...@@ -257,7 +258,7 @@ module SharedPaths ...@@ -257,7 +258,7 @@ module SharedPaths
end end
step 'I visit blob file from repo' do step 'I visit blob file from repo' do
visit project_blob_path(@project, File.join(ValidCommit::ID, ValidCommit::BLOB_FILE_PATH)) visit project_blob_path(@project, File.join(sample_commit.id, sample_blob.path))
end end
step 'I visit ".gitignore" file in repo' do step 'I visit ".gitignore" file in repo' do
...@@ -273,7 +274,7 @@ module SharedPaths ...@@ -273,7 +274,7 @@ module SharedPaths
end end
step 'I visit project commit page' do step 'I visit project commit page' do
visit project_commit_path(@project, ValidCommit::ID) visit project_commit_path(@project, sample_commit.id)
end end
step 'I visit project "Shop" issues page' do step 'I visit project "Shop" issues page' do
......
...@@ -15,7 +15,7 @@ require 'spinach/capybara' ...@@ -15,7 +15,7 @@ require 'spinach/capybara'
require 'sidekiq/testing/inline' require 'sidekiq/testing/inline'
%w(valid_commit valid_commit_with_alt_email big_commits select2_helper test_env).each do |f| %w(select2_helper test_env repo_helpers).each do |f|
require Rails.root.join('spec', 'support', f) require Rails.root.join('spec', 'support', f)
end end
......
module BigCommits
HUGE_COMMIT_ID = "7f92534f767fa20357a11c63f973ae3b79cc5b85"
HUGE_COMMIT_MESSAGE = "pybments.rb version up. gitignore improved"
BIG_COMMIT_ID = "d62200cad430565bd9f80befaf329297120330b5"
BIG_COMMIT_MESSAGE = "clean-up code"
end
module RepoHelpers
extend self
# Text file in repo
#
# Ex.
#
# # Get object
# blob = RepoHelpers.text_blob
#
# blob.path # => 'files/js/commit.js.coffee'
# blob.data # => 'class Commit...'
#
def sample_blob
OpenStruct.new(
path: "files/js/commit.js.coffee",
data: <<eos
class Commit
constructor: ->
$('.files .diff-file').each ->
new CommitFile(this)
@Commit = Commit
eos
)
end
def sample_commit
OpenStruct.new(
id: "570e7b2abdd848b95f2f578043fc23bd6f6fd24d",
parent_id: '6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9',
author_full_name: "Dmitriy Zaporozhets",
author_email: "dmitriy.zaporozhets@gmail.com",
files_changed_count: 2,
message: <<eos
Change some files
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
eos
)
end
def sample_big_commit
OpenStruct.new(
id: "913c66a37b4a45b9769037c55c2d238bd0942d2e",
author_full_name: "Dmitriy Zaporozhets",
author_email: "dmitriy.zaporozhets@gmail.com",
message: <<eos
Files, encoding and much more
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
eos
)
end
def sample_image_commit
OpenStruct.new(
id: "2f63565e7aac07bcdadb654e253078b727143ec4",
author_full_name: "Dmitriy Zaporozhets",
author_email: "dmitriy.zaporozhets@gmail.com",
old_blob_id: '33f3729a45c02fc67d00adb1b8bca394b0e761d9',
new_blob_id: '2f63565e7aac07bcdadb654e253078b727143ec4',
message: <<eos
Modified image
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
eos
)
end
end
module ValidCommit
ID = "570e7b2abdd848b95f2f578043fc23bd6f6fd24d"
MESSAGE = <<eos
Change some files
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
eos
AUTHOR_FULL_NAME = "Dmitriy Zaporozhets"
AUTHOR_EMAIL = "dmitriy.zaporozhets@gmail.com"
FILES = [".foreman", ".gitignore", ".rails_footnotes", ".rspec", ".travis.yml", "CHANGELOG", "Gemfile", "Gemfile.lock", "LICENSE", "Procfile", "Procfile.production", "README.md", "Rakefile", "VERSION", "app", "config.ru", "config", "db", "doc", "lib", "log", "public", "resque.sh", "script", "spec", "vendor"]
FILES_COUNT = 26
C_FILE_PATH = "app/models"
C_FILES = [".gitkeep", "ability.rb", "commit.rb", "issue.rb", "key.rb", "mailer_observer.rb", "merge_request.rb", "note.rb", "project.rb", "protected_branch.rb", "repository.rb", "snippet.rb", "tree.rb", "user.rb", "users_project.rb", "web_hook.rb", "wiki.rb"]
BLOB_FILE = <<eos
class Commit
constructor: ->
$('.files .diff-file').each ->
new CommitFile(this)
@Commit = Commit
eos
BLOB_FILE_PATH = "files/js/commit.js.coffee"
end
module ValidCommitWithAltEmail
ID = "1e689bfba39525ead225eaf611948cfbe8ac34cf"
MESSAGE = "fixed notes logic"
AUTHOR_FULL_NAME = "Dmitriy Zaporozhets"
AUTHOR_EMAIL = "dzaporozhets@sphereconsultinginc.com"
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment