FEATURE: Show user fields when the user is signing up

This commit is contained in:
Robin Ward
2014-09-26 14:48:34 -04:00
parent 872d8fce58
commit edb34c178a
42 changed files with 476 additions and 141 deletions

File diff suppressed because one or more lines are too long

View File

@@ -1,9 +1,13 @@
/* global asyncTest */
/* exported integration, testController, controllerFor, asyncTestDiscourse, fixture */
function integration(name, options) {
import siteFixtures from 'fixtures/site_fixtures';
export function integration(name, options) {
module("Integration: " + name, {
setup: function() {
Ember.run(Discourse, Discourse.advanceReadiness);
var siteJson = siteFixtures['site.json'].site;
if (options) {
if (options.setup) {
options.setup.call(this);
@@ -16,7 +20,12 @@ function integration(name, options) {
if (options.settings) {
Discourse.SiteSettings = jQuery.extend(true, Discourse.SiteSettings, options.settings);
}
if (options.site) {
Discourse.Site.resetCurrent(Discourse.Site.create(jQuery.extend(true, {}, siteJson, options.site)));
}
}
Discourse.reset();
},
@@ -30,13 +39,13 @@ function integration(name, options) {
});
}
function controllerFor(controller, model) {
export function controllerFor(controller, model) {
controller = Discourse.__container__.lookup('controller:' + controller);
if (model) { controller.set('model', model ); }
return controller;
}
function asyncTestDiscourse(text, func) {
export function asyncTestDiscourse(text, func) {
asyncTest(text, function () {
var self = this;
Ember.run(function () {
@@ -45,7 +54,7 @@ function asyncTestDiscourse(text, func) {
});
}
function fixture(selector) {
export function fixture(selector) {
if (selector) {
return $("#qunit-fixture").find(selector);
}

View File

@@ -0,0 +1,46 @@
import { integration } from "helpers/qunit-helpers";
integration("Create Account - User Fields", {
site: {
user_fields: [{"id":34,"name":"I've read the terms of service","field_type":"confirm"},
{"id":35,"name":"What is your pet's name?","field_type":"text"}]
}
});
test("create account with user fields", function() {
visit("/");
click("header .sign-up-button");
andThen(function() {
ok(exists('.create-account'), "it shows the create account modal");
ok(exists('.user-field'), "it has at least one user field");
ok(exists('.modal-footer .btn-primary:disabled'), 'create account is disabled at first');
});
fillIn('#new-account-name', 'Dr. Good Tuna');
fillIn('#new-account-password', 'cool password bro');
fillIn('#new-account-email', 'good.tuna@test.com');
fillIn('#new-account-username', 'goodtuna');
andThen(function() {
ok(exists('#username-validation.good'), 'the username validation is good');
ok(exists('.modal-footer .btn-primary:disabled'), 'create account is still disabled due to lack of user fields');
});
fillIn(".user-field input[type=text]", "Barky");
andThen(function() {
ok(exists('.modal-footer .btn-primary:disabled'), 'create account is disabled because field is not checked');
});
click(".user-field input[type=checkbox]");
andThen(function() {
not(exists('.modal-footer .btn-primary:disabled'), 'create account is disabled because field is not checked');
});
click(".user-field input[type=checkbox]");
andThen(function() {
ok(exists('.modal-footer .btn-primary:disabled'), 'unclicking the checkbox disables the submit');
});
});

View File

@@ -20,16 +20,18 @@ test('has a postStream', function() {
equal(postStream.get('topic'), topic, "the postStream has a reference back to the topic");
});
var category = _.first(Discourse.Category.list());
test('category relationship', function() {
// It finds the category by id
var topic = Discourse.Topic.create({id: 1111, category_id: category.get('id') });
var category = Discourse.Category.list()[0],
topic = Discourse.Topic.create({id: 1111, category_id: category.get('id') });
equal(topic.get('category'), category);
});
test("updateFromJson", function() {
var topic = Discourse.Topic.create({id: 1234});
var topic = Discourse.Topic.create({id: 1234}),
category = Discourse.Category.list()[0];
topic.updateFromJson({
post_stream: [1,2,3],

View File

@@ -42,7 +42,7 @@
//= require sinon-qunit-1.0.0
//= require jshint
//= require helpers/qunit_helpers
//= require helpers/qunit-helpers
//= require helpers/assertions
//= require helpers/init-ember-qunit
@@ -50,7 +50,6 @@
//= require_tree ./lib
//= require_tree .
//= require_self
//= require jshint_all
// sinon settings
sinon.config = {
@@ -87,6 +86,7 @@ if (window.Logster) {
var origDebounce = Ember.run.debounce,
createPretendServer = require('helpers/create-pretender', null, null, false).default,
fixtures = require('fixtures/site_fixtures', null, null, false).default,
server;
QUnit.testStart(function(ctx) {
@@ -97,6 +97,7 @@ QUnit.testStart(function(ctx) {
Discourse.BaseUri = "/";
Discourse.BaseUrl = "";
Discourse.User.resetCurrent();
Discourse.Site.resetCurrent(Discourse.Site.create(fixtures['site.json'].site));
PreloadStore.reset();
window.sandbox = sinon.sandbox.create();
@@ -121,6 +122,15 @@ QUnit.testDone(function() {
});
// Load ES6 tests
var helpers = require("helpers/qunit-helpers");
// TODO: Replace with proper imports rather than globals
window.asyncTestDiscourse = helpers.asyncTestDiscourse;
window.controllerFor = helpers.controllerFor;
window.fixture = helpers.fixture;
window.integration = helpers.integration;
Ember.keys(requirejs.entries).forEach(function(entry) {
if ((/\-test/).test(entry)) {
require(entry, null, null, true);