Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tatuya Kamada
gitlab-ce
Commits
918bc207
Commit
918bc207
authored
Nov 19, 2016
by
winniehell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use Rails test host name for frontend fixtures
parent
d100f843
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
14 deletions
+17
-14
spec/javascripts/build_spec.js.es6
spec/javascripts/build_spec.js.es6
+8
-12
spec/javascripts/issue_spec.js
spec/javascripts/issue_spec.js
+1
-1
spec/javascripts/spec_helper.js
spec/javascripts/spec_helper.js
+5
-0
spec/support/javascript_fixtures_helpers.rb
spec/support/javascript_fixtures_helpers.rb
+3
-1
No files found.
spec/javascripts/build_spec.js.es6
View file @
918bc207
...
...
@@ -10,6 +10,7 @@
//= require turbolinks
describe('Build', () => {
const BUILD_URL = `${gl.TEST_HOST}/namespace1/project1/builds/1`;
// see spec/factories/ci/builds.rb
const BUILD_TRACE = 'BUILD TRACE';
// see lib/ci/ansi2html.rb
...
...
@@ -39,8 +40,8 @@ describe('Build', () => {
});
it('copies build options', function () {
expect(this.build.pageUrl).toBe(
'http://test.host/namespace1/project1/builds/1'
);
expect(this.build.buildUrl).toBe(
'http://test.host/namespace1/project1/builds/1.json'
);
expect(this.build.pageUrl).toBe(
BUILD_URL
);
expect(this.build.buildUrl).toBe(
`${BUILD_URL}.json`
);
expect(this.build.buildStatus).toBe('success');
expect(this.build.buildStage).toBe('test');
expect(this.build.state).toBe(INITIAL_BUILD_TRACE_STATE);
...
...
@@ -79,7 +80,7 @@ describe('Build', () => {
it('displays the initial build trace', function () {
expect($.ajax.calls.count()).toBe(1);
const [{ url, dataType, success, context }] = $.ajax.calls.argsFor(0);
expect(url).toBe(
'http://test.host/namespace1/project1/builds/1.json'
);
expect(url).toBe(
`${BUILD_URL}.json`
);
expect(dataType).toBe('json');
expect(success).toEqual(jasmine.any(Function));
...
...
@@ -100,8 +101,7 @@ describe('Build', () => {
beforeEach(function () {
$('.js-build-options').data('buildStatus', 'running');
this.build = new Build();
spyOn(this.build, 'location')
.and.returnValue('http://test.host/namespace1/project1/builds/1');
spyOn(this.build, 'location').and.returnValue(BUILD_URL);
});
it('updates the build trace on an interval', function () {
...
...
@@ -110,7 +110,7 @@ describe('Build', () => {
expect($.ajax.calls.count()).toBe(2);
let [{ url, dataType, success, context }] = $.ajax.calls.argsFor(1);
expect(url).toBe(
`
http://test.host/namespace1/project1/builds/1
/trace.json?state=${encodeURIComponent(INITIAL_BUILD_TRACE_STATE)}`
`
${BUILD_URL}
/trace.json?state=${encodeURIComponent(INITIAL_BUILD_TRACE_STATE)}`
);
expect(dataType).toBe('json');
expect(success).toEqual(jasmine.any(Function));
...
...
@@ -129,9 +129,7 @@ describe('Build', () => {
expect($.ajax.calls.count()).toBe(3);
[{ url, dataType, success, context }] = $.ajax.calls.argsFor(2);
expect(url).toBe(
'http://test.host/namespace1/project1/builds/1/trace.json?state=newstate'
);
expect(url).toBe(`${BUILD_URL}/trace.json?state=newstate`);
expect(dataType).toBe('json');
expect(success).toEqual(jasmine.any(Function));
...
...
@@ -180,9 +178,7 @@ describe('Build', () => {
append: true,
});
expect(Turbolinks.visit).toHaveBeenCalledWith(
'http://test.host/namespace1/project1/builds/1'
);
expect(Turbolinks.visit).toHaveBeenCalledWith(BUILD_URL);
});
});
});
...
...
spec/javascripts/issue_spec.js
View file @
918bc207
...
...
@@ -74,7 +74,7 @@
it
(
'
submits an ajax request on tasklist:changed
'
,
function
()
{
spyOn
(
jQuery
,
'
ajax
'
).
and
.
callFake
(
function
(
req
)
{
expect
(
req
.
type
).
toBe
(
'
PATCH
'
);
expect
(
req
.
url
).
toBe
(
'
https://fixture.invalid
/namespace3/project3/issues/1.json
'
);
expect
(
req
.
url
).
toBe
(
gl
.
TEST_HOST
+
'
/namespace3/project3/issues/1.json
'
);
expect
(
req
.
data
.
issue
.
description
).
not
.
toBe
(
null
);
});
...
...
spec/javascripts/spec_helper.js
View file @
918bc207
...
...
@@ -41,3 +41,8 @@
}).
call
(
this
);
// defined in ActionDispatch::TestRequest
// see https://github.com/rails/rails/blob/v4.2.7.1/actionpack/lib/action_dispatch/testing/test_request.rb#L7
window
.
gl
=
window
.
gl
||
{};
gl
.
TEST_HOST
=
'
http://test.host
'
;
spec/support/javascript_fixtures_helpers.rb
View file @
918bc207
require
'action_dispatch/testing/test_request'
require
'fileutils'
require
'gitlab/popen'
...
...
@@ -36,7 +37,8 @@ module JavaScriptFixturesHelpers
fixture
=
doc
.
to_html
# replace relative links
fixture
.
gsub!
(
%r{="/}
,
'="https://fixture.invalid/'
)
test_host
=
ActionDispatch
::
TestRequest
::
DEFAULT_ENV
[
'HTTP_HOST'
]
fixture
.
gsub!
(
%r{="/}
,
"=
\"
http://
#{
test_host
}
/"
)
end
FileUtils
.
mkdir_p
(
File
.
dirname
(
fixture_file_name
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment