Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-02-06 09:40:35 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-02-06 09:40:35 +0300
commitf9e6f668981f6f57d41c34d68a84879a48593269 (patch)
treefe9fb490b467b5f1886376f14f0dac7525635b53 /spec
parentbdfb349ff70f0fde6d4dc7b4317c3bc7ead580a4 (diff)
Fix tests
Diffstat (limited to 'spec')
-rw-r--r--spec/features/admin/admin_users_spec.rb6
-rw-r--r--spec/features/issues_spec.rb18
-rw-r--r--spec/requests/api/merge_requests_spec.rb25
3 files changed, 27 insertions, 22 deletions
diff --git a/spec/features/admin/admin_users_spec.rb b/spec/features/admin/admin_users_spec.rb
index 82da19746f8..59c4ffb5624 100644
--- a/spec/features/admin/admin_users_spec.rb
+++ b/spec/features/admin/admin_users_spec.rb
@@ -32,14 +32,14 @@ describe "Admin::Users", feature: true do
it "should apply defaults to user" do
click_button "Create user"
- user = User.last
+ user = User.find_by(username: 'bang')
user.projects_limit.should == Gitlab.config.gitlab.default_projects_limit
user.can_create_group.should == Gitlab.config.gitlab.default_can_create_group
end
it "should create user with valid data" do
click_button "Create user"
- user = User.last
+ user = User.find_by(username: 'bang')
user.name.should == "Big Bang"
user.email.should == "bigbang@mail.com"
end
@@ -52,7 +52,7 @@ describe "Admin::Users", feature: true do
it "should send valid email to user with email & password" do
click_button "Create user"
- user = User.last
+ user = User.find_by(username: 'bang')
email = ActionMailer::Base.deliveries.last
email.subject.should have_content("Account was created")
email.text_part.body.should have_content(user.email)
diff --git a/spec/features/issues_spec.rb b/spec/features/issues_spec.rb
index e6fa376f3eb..29aeb6a400a 100644
--- a/spec/features/issues_spec.rb
+++ b/spec/features/issues_spec.rb
@@ -1,6 +1,8 @@
require 'spec_helper'
describe "Issues", feature: true do
+ include SortingHelper
+
let(:project) { create(:project) }
before do
@@ -80,7 +82,7 @@ describe "Issues", feature: true do
title: title)
end
- @issue = Issue.first # with title 'foobar'
+ @issue = Issue.find_by(title: 'foobar')
@issue.milestone = create(:milestone, project: project)
@issue.assignee = nil
@issue.save
@@ -130,14 +132,14 @@ describe "Issues", feature: true do
let(:later_due_milestone) { create(:milestone, due_date: '2013-12-12') }
it 'sorts by newest' do
- visit project_issues_path(project, sort: 'newest')
+ visit project_issues_path(project, sort: sort_value_recently_created)
first_issue.should include("foo")
last_issue.should include("baz")
end
it 'sorts by oldest' do
- visit project_issues_path(project, sort: 'oldest')
+ visit project_issues_path(project, sort: sort_value_oldest_created)
first_issue.should include("baz")
last_issue.should include("foo")
@@ -146,7 +148,7 @@ describe "Issues", feature: true do
it 'sorts by most recently updated' do
baz.updated_at = Time.now + 100
baz.save
- visit project_issues_path(project, sort: 'recently_updated')
+ visit project_issues_path(project, sort: sort_value_recently_updated)
first_issue.should include("baz")
end
@@ -154,7 +156,7 @@ describe "Issues", feature: true do
it 'sorts by least recently updated' do
baz.updated_at = Time.now - 100
baz.save
- visit project_issues_path(project, sort: 'last_updated')
+ visit project_issues_path(project, sort: sort_value_oldest_updated)
first_issue.should include("baz")
end
@@ -168,13 +170,13 @@ describe "Issues", feature: true do
end
it 'sorts by recently due milestone' do
- visit project_issues_path(project, sort: 'milestone_due_soon')
+ visit project_issues_path(project, sort: sort_value_milestone_soon)
first_issue.should include("foo")
end
it 'sorts by least recently due milestone' do
- visit project_issues_path(project, sort: 'milestone_due_later')
+ visit project_issues_path(project, sort: sort_value_milestone_later)
first_issue.should include("bar")
end
@@ -191,7 +193,7 @@ describe "Issues", feature: true do
end
it 'sorts with a filter applied' do
- visit project_issues_path(project, sort: 'oldest', assignee_id: user2.id)
+ visit project_issues_path(project, sort: sort_value_oldest_created, assignee_id: user2.id)
first_issue.should include("bar")
last_issue.should include("foo")
diff --git a/spec/requests/api/merge_requests_spec.rb b/spec/requests/api/merge_requests_spec.rb
index 0870a298eff..b5deb072cd1 100644
--- a/spec/requests/api/merge_requests_spec.rb
+++ b/spec/requests/api/merge_requests_spec.rb
@@ -26,7 +26,7 @@ describe API::API, api: true do
response.status.should == 200
json_response.should be_an Array
json_response.length.should == 3
- json_response.first['title'].should == merge_request.title
+ json_response.last['title'].should == merge_request.title
end
it "should return an array of all merge_requests" do
@@ -34,7 +34,7 @@ describe API::API, api: true do
response.status.should == 200
json_response.should be_an Array
json_response.length.should == 3
- json_response.first['title'].should == merge_request.title
+ json_response.last['title'].should == merge_request.title
end
it "should return an array of open merge_requests" do
@@ -42,7 +42,7 @@ describe API::API, api: true do
response.status.should == 200
json_response.should be_an Array
json_response.length.should == 1
- json_response.first['title'].should == merge_request.title
+ json_response.last['title'].should == merge_request.title
end
it "should return an array of closed merge_requests" do
@@ -50,8 +50,8 @@ describe API::API, api: true do
response.status.should == 200
json_response.should be_an Array
json_response.length.should == 2
- json_response.first['title'].should == merge_request_closed.title
- json_response.second['title'].should == merge_request_merged.title
+ json_response.second['title'].should == merge_request_closed.title
+ json_response.first['title'].should == merge_request_merged.title
end
it "should return an array of merged merge_requests" do
@@ -73,9 +73,10 @@ describe API::API, api: true do
response.status.should == 200
json_response.should be_an Array
json_response.length.should == 3
- json_response.first['id'].should == @mr_earlier.id
- json_response.last['id'].should == @mr_later.id
+ json_response.last['id'].should == @mr_earlier.id
+ json_response.first['id'].should == @mr_later.id
end
+
it "should return an array of merge_requests in descending order" do
get api("/projects/#{project.id}/merge_requests?sort=desc", user)
response.status.should == 200
@@ -84,21 +85,23 @@ describe API::API, api: true do
json_response.first['id'].should == @mr_later.id
json_response.last['id'].should == @mr_earlier.id
end
+
it "should return an array of merge_requests ordered by updated_at" do
get api("/projects/#{project.id}/merge_requests?order_by=updated_at", user)
response.status.should == 200
json_response.should be_an Array
json_response.length.should == 3
- json_response.first['id'].should == @mr_earlier.id
- json_response.last['id'].should == @mr_later.id
+ json_response.last['id'].should == @mr_earlier.id
+ json_response.first['id'].should == @mr_later.id
end
+
it "should return an array of merge_requests ordered by created_at" do
get api("/projects/#{project.id}/merge_requests?sort=created_at", user)
response.status.should == 200
json_response.should be_an Array
json_response.length.should == 3
- json_response.first['id'].should == @mr_earlier.id
- json_response.last['id'].should == @mr_later.id
+ json_response.last['id'].should == @mr_earlier.id
+ json_response.first['id'].should == @mr_later.id
end
end
end