diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-07-31 17:23:40 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-07-31 17:23:40 +0300 |
commit | c2c7d14ec51ec8654cc4e0ca57ba0bc146fd8725 (patch) | |
tree | a934912a8d8711d5fca2b7a1b3da1ee8b4698519 | |
parent | bb2f4d665e946806d0bb94d3a50569ae6aa12e66 (diff) | |
download | gitlab-ce-c2c7d14ec51ec8654cc4e0ca57ba0bc146fd8725.tar.gz |
Move all test repos data to ReposHelpers
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
-rw-r--r-- | features/project/commits/commits.feature | 4 | ||||
-rw-r--r-- | features/project/commits/user_lookup.feature | 11 | ||||
-rw-r--r-- | features/steps/project/browse_commits.rb | 36 | ||||
-rw-r--r-- | features/steps/project/browse_commits_user_lookup.rb | 47 | ||||
-rw-r--r-- | features/steps/project/browse_files.rb | 3 | ||||
-rw-r--r-- | features/steps/shared/paths.rb | 5 | ||||
-rw-r--r-- | features/support/env.rb | 2 | ||||
-rw-r--r-- | spec/support/big_commits.rb | 8 | ||||
-rw-r--r-- | spec/support/repo_helpers.rb | 67 | ||||
-rw-r--r-- | spec/support/valid_commit.rb | 27 | ||||
-rw-r--r-- | spec/support/valid_commit_with_alt_email.rb | 6 |
11 files changed, 124 insertions, 92 deletions
diff --git a/features/project/commits/commits.feature b/features/project/commits/commits.feature index cbe8b321507..7c6db3c465a 100644 --- a/features/project/commits/commits.feature +++ b/features/project/commits/commits.feature @@ -38,10 +38,6 @@ Feature: Project Browse commits Given I visit big commit page 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 Given I visit a commit with an image that changed Then The diff links to both the previous and current image diff --git a/features/project/commits/user_lookup.feature b/features/project/commits/user_lookup.feature index aa347e24fe4..7b194ab9206 100644 --- a/features/project/commits/user_lookup.feature +++ b/features/project/commits/user_lookup.feature @@ -2,13 +2,14 @@ Feature: Project Browse Commits User Lookup Background: Given I sign in as a user And I own a project - And I have the user that authored the commits And I visit my project's commits page Scenario: I browse commit from list - Given I click on commit link - Then I see commit info + Given I have user with primary email + When I click on commit link + Then I see author based on primary email Scenario: I browse another commit from list - Given I click on another commit link - Then I see other commit info + Given I have user with secondary email + When I click on another commit link + Then I see author based on secondary email diff --git a/features/steps/project/browse_commits.rb b/features/steps/project/browse_commits.rb index fe47a731915..37207aafebe 100644 --- a/features/steps/project/browse_commits.rb +++ b/features/steps/project/browse_commits.rb @@ -2,11 +2,12 @@ class ProjectBrowseCommits < Spinach::FeatureSteps include SharedAuthentication include SharedProject include SharedPaths + include RepoHelpers Then 'I see project commits' do commit = @project.repository.commit 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]) end @@ -19,21 +20,21 @@ class ProjectBrowseCommits < Spinach::FeatureSteps 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("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 Given 'I click on commit link' do - visit project_commit_path(@project, ValidCommit::ID) + visit project_commit_path(@project, sample_commit.id) end Then 'I see commit info' do - page.should have_content ValidCommit::MESSAGE - page.should have_content "Showing 1 changed file" + page.should have_content sample_commit.message + page.should have_content "Showing #{sample_commit.files_changed_count} changed files" end And 'I fill compare fields with refs' do - fill_in "from", with: "8716fc78f3c65bbf7bcf7b574febd583bc5d2812" - fill_in "to", with: "bcf03b5de6c33f3869ef70d68cf06e679d1d7f9a" + fill_in "from", with: sample_commit.parent_id + fill_in "to", with: sample_commit.id click_button "Compare" end @@ -56,30 +57,24 @@ class ProjectBrowseCommits < Spinach::FeatureSteps end 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 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" - end - - 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 + Commit::DIFF_SAFE_FILES = 100 end 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 Then 'The diff links to both the previous and current image' do links = page.all('.two-up span div a') - links[0]['href'].should =~ %r{blob/bc3735004cb45cec5e0e4fa92710897a910a5957} - links[1]['href'].should =~ %r{blob/cc1ba255d6c5ffdce87a357ba7ccc397a4f4026b} + links[0]['href'].should =~ %r{blob/#{sample_image_commit.old_blob_id}} + links[1]['href'].should =~ %r{blob/#{sample_image_commit.new_blob_id}} end Given 'I click side-by-side diff button' do @@ -93,5 +88,4 @@ class ProjectBrowseCommits < Spinach::FeatureSteps Then 'I see inline diff button' do page.should have_content "Inline Diff" end - end diff --git a/features/steps/project/browse_commits_user_lookup.rb b/features/steps/project/browse_commits_user_lookup.rb index 328be373553..198ea29f28d 100644 --- a/features/steps/project/browse_commits_user_lookup.rb +++ b/features/steps/project/browse_commits_user_lookup.rb @@ -2,34 +2,47 @@ class ProjectBrowseCommitsUserLookup < Spinach::FeatureSteps include SharedAuthentication include SharedProject 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 - visit project_commit_path(@project, ValidCommit::ID) + visit project_commit_path(@project, sample_commit.id) end 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 - Then 'I see commit info' do - page.should have_content ValidCommit::MESSAGE - check_author_link(ValidCommit::AUTHOR_EMAIL) + step 'I see author based on primary email' do + check_author_link(sample_commit.author_email, user_primary) end - - Then 'I see other commit info' do - page.should have_content ValidCommitWithAltEmail::MESSAGE - check_author_link(ValidCommitWithAltEmail::AUTHOR_EMAIL) + + step 'I see author based on secondary email' do + check_author_link(sample_commit.author_email, user_secondary) end - def check_author_link(email) + def check_author_link(email, user) 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 - 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 diff --git a/features/steps/project/browse_files.rb b/features/steps/project/browse_files.rb index 1e54e00f37a..6fd0c2c2ded 100644 --- a/features/steps/project/browse_files.rb +++ b/features/steps/project/browse_files.rb @@ -2,6 +2,7 @@ class ProjectBrowseFiles < Spinach::FeatureSteps include SharedAuthentication include SharedProject include SharedPaths + include RepoHelpers step 'I should see files from repository' do page.should have_content "VERSION" @@ -28,7 +29,7 @@ class ProjectBrowseFiles < Spinach::FeatureSteps end step 'I should see raw file content' do - page.source.should == ValidCommit::BLOB_FILE + page.source.should == sample_blob.data end step 'I click button "edit"' do diff --git a/features/steps/shared/paths.rb b/features/steps/shared/paths.rb index 6acf877c256..4e97dba20b3 100644 --- a/features/steps/shared/paths.rb +++ b/features/steps/shared/paths.rb @@ -1,5 +1,6 @@ module SharedPaths include Spinach::DSL + include RepoHelpers step 'I visit new project page' do visit new_project_path @@ -257,7 +258,7 @@ module SharedPaths end 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 step 'I visit ".gitignore" file in repo' do @@ -273,7 +274,7 @@ module SharedPaths end step 'I visit project commit page' do - visit project_commit_path(@project, ValidCommit::ID) + visit project_commit_path(@project, sample_commit.id) end step 'I visit project "Shop" issues page' do diff --git a/features/support/env.rb b/features/support/env.rb index 5b3e78cbec3..480cb361b67 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -15,7 +15,7 @@ require 'spinach/capybara' 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) end diff --git a/spec/support/big_commits.rb b/spec/support/big_commits.rb deleted file mode 100644 index 69daa709dd9..00000000000 --- a/spec/support/big_commits.rb +++ /dev/null @@ -1,8 +0,0 @@ -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 - diff --git a/spec/support/repo_helpers.rb b/spec/support/repo_helpers.rb new file mode 100644 index 00000000000..2584853077f --- /dev/null +++ b/spec/support/repo_helpers.rb @@ -0,0 +1,67 @@ +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 diff --git a/spec/support/valid_commit.rb b/spec/support/valid_commit.rb deleted file mode 100644 index 65ad1d52084..00000000000 --- a/spec/support/valid_commit.rb +++ /dev/null @@ -1,27 +0,0 @@ -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 - diff --git a/spec/support/valid_commit_with_alt_email.rb b/spec/support/valid_commit_with_alt_email.rb deleted file mode 100644 index 75854c63a59..00000000000 --- a/spec/support/valid_commit_with_alt_email.rb +++ /dev/null @@ -1,6 +0,0 @@ -module ValidCommitWithAltEmail - ID = "1e689bfba39525ead225eaf611948cfbe8ac34cf" - MESSAGE = "fixed notes logic" - AUTHOR_FULL_NAME = "Dmitriy Zaporozhets" - AUTHOR_EMAIL = "dzaporozhets@sphereconsultinginc.com" -end |