summaryrefslogtreecommitdiff
path: root/spec/javascripts
diff options
context:
space:
mode:
authorwinniehell <git@winniehell.de>2016-08-29 18:18:59 +0200
committerwinniehell <git@winniehell.de>2016-10-28 14:02:17 +0200
commit0f060bf4fccc3119dc4b7d6e296c2f0fc994bb4e (patch)
tree374a5157636eaa43b5f19e97937266d61ed3951f /spec/javascripts
parent8afc2873304bd7de759fe3abf63a46f1541b4dc6 (diff)
downloadgitlab-ce-0f060bf4fccc3119dc4b7d6e296c2f0fc994bb4e.tar.gz
Replace static issue fixtures by script (!6059)
Diffstat (limited to 'spec/javascripts')
-rw-r--r--spec/javascripts/fixtures/.gitignore1
-rw-r--r--spec/javascripts/fixtures/issues.rb44
-rw-r--r--spec/javascripts/fixtures/issues_show.html.haml23
-rw-r--r--spec/javascripts/issue_spec.js35
4 files changed, 63 insertions, 40 deletions
diff --git a/spec/javascripts/fixtures/.gitignore b/spec/javascripts/fixtures/.gitignore
new file mode 100644
index 00000000000..009b68d5d1c
--- /dev/null
+++ b/spec/javascripts/fixtures/.gitignore
@@ -0,0 +1 @@
+*.html.raw
diff --git a/spec/javascripts/fixtures/issues.rb b/spec/javascripts/fixtures/issues.rb
new file mode 100644
index 00000000000..d95eb851421
--- /dev/null
+++ b/spec/javascripts/fixtures/issues.rb
@@ -0,0 +1,44 @@
+require 'spec_helper'
+
+describe Projects::IssuesController, '(JavaScript fixtures)', type: :controller do
+ include JavaScriptFixturesHelpers
+
+ let(:admin) { create(:admin) }
+ let(:project) { create(:project_empty_repo) }
+
+ render_views
+
+ before(:all) do
+ clean_frontend_fixtures('issues/')
+ end
+
+ before(:each) do
+ sign_in(admin)
+ end
+
+ it 'issues/open-issue.html.raw' do |example|
+ render_issue(example.description, create(:issue, project: project))
+ end
+
+ it 'issues/closed-issue.html.raw' do |example|
+ render_issue(example.description, create(:closed_issue, project: project))
+ end
+
+ it 'issues/issue-with-task-list.html.raw' do |example|
+ issue = create(:issue, project: project)
+ issue.update(description: '- [ ] Task List Item')
+ render_issue(example.description, issue)
+ end
+
+ private
+
+ def render_issue(fixture_file_name, issue)
+ get :show,
+ namespace_id: project.namespace.to_param,
+ project_id: project.to_param,
+ id: issue.to_param
+
+ expect(response).to be_success
+ store_frontend_fixture(response, fixture_file_name)
+ end
+end
diff --git a/spec/javascripts/fixtures/issues_show.html.haml b/spec/javascripts/fixtures/issues_show.html.haml
deleted file mode 100644
index 06c2ab1e823..00000000000
--- a/spec/javascripts/fixtures/issues_show.html.haml
+++ /dev/null
@@ -1,23 +0,0 @@
-:css
- .hidden { display: none !important; }
-
-.flash-container.flash-container-page
- .flash-alert
- .flash-notice
-
-.status-box.status-box-open Open
-.status-box.status-box-closed.hidden Closed
-%a.btn-close{"href" => "http://gitlab.com/issues/6/close"} Close
-%a.btn-reopen.hidden{"href" => "http://gitlab.com/issues/6/reopen"} Reopen
-
-.detail-page-description
- .description.js-task-list-container
- .wiki
- %ul.task-list
- %li.task-list-item
- %input.task-list-item-checkbox{type: 'checkbox'}
- Task List Item
- %textarea.js-task-list-field
- \- [ ] Task List Item
-
-%form.js-issuable-update{action: '/foo'}
diff --git a/spec/javascripts/issue_spec.js b/spec/javascripts/issue_spec.js
index d0c44b6346d..949114185cf 100644
--- a/spec/javascripts/issue_spec.js
+++ b/spec/javascripts/issue_spec.js
@@ -7,6 +7,10 @@
var INVALID_URL = 'http://goesnowhere.nothing/whereami';
var $boxClosed, $boxOpen, $btnClose, $btnReopen;
+ fixture.preload('issues/closed-issue.html');
+ fixture.preload('issues/issue-with-task-list.html');
+ fixture.preload('issues/open-issue.html');
+
function expectErrorMessage() {
var $flashMessage = $('div.flash-alert');
expect($flashMessage).toExist();
@@ -55,33 +59,33 @@
}
describe('Issue', function() {
- return describe('task lists', function() {
- fixture.preload('issues_show.html');
+ describe('task lists', function() {
+ fixture.load('issues/issue-with-task-list.html');
beforeEach(function() {
- fixture.load('issues_show.html');
- return this.issue = new Issue();
+ this.issue = new Issue();
});
+
it('modifies the Markdown field', function() {
spyOn(jQuery, 'ajax').and.stub();
$('input[type=checkbox]').attr('checked', true).trigger('change');
- return expect($('.js-task-list-field').val()).toBe('- [x] Task List Item');
+ expect($('.js-task-list-field').val()).toBe('- [x] Task List Item');
});
- return it('submits an ajax request on tasklist:changed', function() {
+
+ 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('/foo');
- return expect(req.data.issue.description).not.toBe(null);
+ expect(req.url).toBe('https://fixture.invalid/namespace3/project3/issues/1.json');
+ expect(req.data.issue.description).not.toBe(null);
});
- return $('.js-task-list-field').trigger('tasklist:changed');
+
+ $('.js-task-list-field').trigger('tasklist:changed');
});
});
});
describe('close issue', function() {
- fixture.preload('issues_show.html');
-
beforeEach(function() {
- fixture.load('issues_show.html');
+ fixture.load('issues/open-issue.html');
findElements();
this.issue = new Issue();
@@ -134,15 +138,12 @@
});
describe('reopen issue', function() {
- fixture.preload('issues_show.html');
-
beforeEach(function() {
- fixture.load('issues_show.html');
+ fixture.load('issues/closed-issue.html');
findElements();
this.issue = new Issue();
- // TODO: fixture is an open issue, we should replace it by a closed issue
- expectIssueState(true);
+ expectIssueState(false);
});
it('reopens an issue', function() {