summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-07-31 20:13:27 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-07-31 20:13:27 +0300
commitcbe4891d7c44d59c902d13315eb3140fb6d47486 (patch)
tree83c35728846a48e1b498ed720c311e342f7f481a
parent2a6fc1c5debc81ac883bad4e7f9748be88a9b9ff (diff)
downloadgitlab-ce-cbe4891d7c44d59c902d13315eb3140fb6d47486.tar.gz
Fix form mr tests
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
-rw-r--r--features/project/forked_merge_requests.feature1
-rw-r--r--features/steps/project/forked_merge_requests.rb60
-rw-r--r--spec/factories.rb43
-rw-r--r--spec/factories/projects.rb44
4 files changed, 54 insertions, 94 deletions
diff --git a/features/project/forked_merge_requests.feature b/features/project/forked_merge_requests.feature
index 5832b729deb..7442145d87e 100644
--- a/features/project/forked_merge_requests.feature
+++ b/features/project/forked_merge_requests.feature
@@ -4,7 +4,6 @@ Feature: Project Forked Merge Requests
And I am a member of project "Shop"
And I have a project forked off of "Shop" called "Forked Shop"
- @javascript
Scenario: I submit new unassigned merge request to a forked project
Given I visit project "Forked Shop" merge requests page
And I click link "New Merge Request"
diff --git a/features/steps/project/forked_merge_requests.rb b/features/steps/project/forked_merge_requests.rb
index 3c497638d9c..6ec527df13d 100644
--- a/features/steps/project/forked_merge_requests.rb
+++ b/features/steps/project/forked_merge_requests.rb
@@ -9,18 +9,11 @@ class ProjectForkedMergeRequests < Spinach::FeatureSteps
@project = Project.find_by(name: "Shop")
@project ||= create(:project, name: "Shop")
@project.team << [@user, :reporter]
+ @project.ensure_satellite_exists
end
step 'I have a project forked off of "Shop" called "Forked Shop"' do
- @forking_user = @user
- forked_project_link = build(:forked_project_link)
- @forked_project = Project.find_by(name: "Forked Shop")
- @forked_project ||= create(:project, name: "Forked Shop", forked_project_link: forked_project_link, creator_id: @forking_user.id , namespace: @forking_user.namespace)
-
- forked_project_link.forked_from_project = @project
- forked_project_link.forked_to_project = @forked_project
- @forked_project.team << [@forking_user , :master]
- forked_project_link.save!
+ @forked_project = Projects::ForkService.new(@project, @user).execute
end
step 'I click link "New Merge Request"' do
@@ -33,8 +26,8 @@ class ProjectForkedMergeRequests < Spinach::FeatureSteps
current_path.should == project_merge_request_path(@project, @merge_request)
@merge_request.title.should == "Merge Request On Forked Project"
@merge_request.source_project.should == @forked_project
- @merge_request.source_branch.should == "master"
- @merge_request.target_branch.should == "stable"
+ @merge_request.source_branch.should == "fix"
+ @merge_request.target_branch.should == "master"
page.should have_content @forked_project.path_with_namespace
page.should have_content @project.path_with_namespace
page.should have_content @merge_request.source_branch
@@ -42,17 +35,11 @@ class ProjectForkedMergeRequests < Spinach::FeatureSteps
end
step 'I fill out a "Merge Request On Forked Project" merge request' do
- select2 @forked_project.id, from: "#merge_request_source_project_id"
- select2 @project.id, from: "#merge_request_target_project_id"
-
- find(:select, "merge_request_source_project_id", {}).value.should == @forked_project.id.to_s
- find(:select, "merge_request_target_project_id", {}).value.should == @project.id.to_s
-
- select2 "master", from: "#merge_request_source_branch"
- select2 "stable", from: "#merge_request_target_branch"
+ select @forked_project.path_with_namespace, from: "merge_request_source_project_id"
+ select @project.path_with_namespace, from: "merge_request_target_project_id"
+ select "fix", from: "merge_request_source_branch"
+ select "master", from: "merge_request_target_branch"
- find(:select, "merge_request_source_branch", {}).value.should == 'master'
- find(:select, "merge_request_target_branch", {}).value.should == 'stable'
click_button "Compare branches"
fill_in "merge_request_title", with: "Merge Request On Forked Project"
@@ -101,8 +88,8 @@ class ProjectForkedMergeRequests < Spinach::FeatureSteps
@merge_request = @project.merge_requests.last
current_path.should == project_merge_request_path(@project, @merge_request)
@merge_request.source_project.should == @forked_project
- @merge_request.source_branch.should == "master"
- @merge_request.target_branch.should == "stable"
+ @merge_request.source_branch.should == "fix"
+ @merge_request.target_branch.should == "master"
page.should have_content @forked_project.path_with_namespace
page.should have_content @project.path_with_namespace
page.should have_content @merge_request.source_branch
@@ -114,33 +101,6 @@ class ProjectForkedMergeRequests < Spinach::FeatureSteps
page.should have_link "Create Merge Request"
end
- step 'project "Forked Shop" has push event' do
- @forked_project = Project.find_by(name: "Forked Shop")
-
- data = {
- before: "0000000000000000000000000000000000000000",
- after: "0220c11b9a3e6c69dc8fd35321254ca9a7b98f7e",
- ref: "refs/heads/new_design",
- user_id: @user.id,
- user_name: @user.name,
- repository: {
- name: @forked_project.name,
- url: "localhost/rubinius",
- description: "",
- homepage: "localhost/rubinius",
- private: true
- }
- }
-
- @event = Event.create(
- project: @forked_project,
- action: Event::PUSHED,
- data: data,
- author_id: @user.id
- )
- end
-
-
step 'I click link edit "Merge Request On Forked Project"' do
find("#edit_merge_request").click
end
diff --git a/spec/factories.rb b/spec/factories.rb
index a9f297279da..c593b1fc401 100644
--- a/spec/factories.rb
+++ b/spec/factories.rb
@@ -27,49 +27,6 @@ FactoryGirl.define do
factory :admin, traits: [:admin]
end
- factory :empty_project, class: 'Project' do
- sequence(:name) { |n| "project#{n}" }
- path { name.downcase.gsub(/\s/, '_') }
- namespace
- creator
- snippets_enabled true
-
- trait :public do
- visibility_level Gitlab::VisibilityLevel::PUBLIC
- end
-
- trait :internal do
- visibility_level Gitlab::VisibilityLevel::INTERNAL
- end
-
- trait :private do
- visibility_level Gitlab::VisibilityLevel::PRIVATE
- end
- end
-
- # Generates a test repository from the repository stored under `spec/seed_project.tar.gz`.
- # Once you run `rake gitlab:setup`, you can see what the repository looks like under `tmp/repositories/gitlabhq`.
- # In order to modify files in the repository, you must untar the seed, modify and remake the tar.
- # Before recompressing, do not forget to `git checkout master`.
- # After recompressing, you need to run `RAILS_ENV=test bundle exec rake gitlab:setup` to regenerate the seeds under tmp.
- #
- # If you want to modify the repository only for an specific type of tests, e.g., markdown tests,
- # consider using a feature branch to reduce the chances of collision with other tests.
- # Create a new commit, and use the same commit message that you will use for the change in the main repo.
- # Changing the commig message and SHA of branch `master` may break tests.
- factory :project, parent: :empty_project do
- path { 'gitlabhq' }
-
- after :create do |project|
- TestEnv.copy_repo(project)
- end
- end
-
- factory :redmine_project, parent: :project do
- issues_tracker { "redmine" }
- issues_tracker_id { "project_name_in_redmine" }
- end
-
factory :group do
sequence(:name) { |n| "group#{n}" }
path { name.downcase.gsub(/\s/, '_') }
diff --git a/spec/factories/projects.rb b/spec/factories/projects.rb
new file mode 100644
index 00000000000..353d9d645ef
--- /dev/null
+++ b/spec/factories/projects.rb
@@ -0,0 +1,44 @@
+FactoryGirl.define do
+ factory :empty_project, class: 'Project' do
+ sequence(:name) { |n| "project#{n}" }
+ path { name.downcase.gsub(/\s/, '_') }
+ namespace
+ creator
+ snippets_enabled true
+
+ trait :public do
+ visibility_level Gitlab::VisibilityLevel::PUBLIC
+ end
+
+ trait :internal do
+ visibility_level Gitlab::VisibilityLevel::INTERNAL
+ end
+
+ trait :private do
+ visibility_level Gitlab::VisibilityLevel::PRIVATE
+ end
+ end
+
+ # Generates a test repository from the repository stored under `spec/seed_project.tar.gz`.
+ # Once you run `rake gitlab:setup`, you can see what the repository looks like under `tmp/repositories/gitlabhq`.
+ # In order to modify files in the repository, you must untar the seed, modify and remake the tar.
+ # Before recompressing, do not forget to `git checkout master`.
+ # After recompressing, you need to run `RAILS_ENV=test bundle exec rake gitlab:setup` to regenerate the seeds under tmp.
+ #
+ # If you want to modify the repository only for an specific type of tests, e.g., markdown tests,
+ # consider using a feature branch to reduce the chances of collision with other tests.
+ # Create a new commit, and use the same commit message that you will use for the change in the main repo.
+ # Changing the commig message and SHA of branch `master` may break tests.
+ factory :project, parent: :empty_project do
+ path { 'gitlabhq' }
+
+ after :create do |project|
+ TestEnv.copy_repo(project)
+ end
+ end
+
+ factory :redmine_project, parent: :project do
+ issues_tracker { "redmine" }
+ issues_tracker_id { "project_name_in_redmine" }
+ end
+end