Skip to content

Commit

Permalink
Merge pull request #129 from sproogen/develop
Browse files Browse the repository at this point in the history
Version 2.2.0
  • Loading branch information
sproogen committed Nov 14, 2017
2 parents e87e882 + 9b0b8cd commit fddb646
Show file tree
Hide file tree
Showing 96 changed files with 12,278 additions and 2,387 deletions.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ GET /api/polls
"identifier": "v90034d6",
"question": "Is this a question?",
"multipleChoice": false,
"endDate": {
"date": "2017-05-18 13:45:37.000000",
"timezone_type": 3,
"timezone": "Europe/London"
},
"ended": false,
"deleted": false,
"created": {
"date": "2017-05-18 13:45:37.000000",
Expand Down Expand Up @@ -83,6 +89,12 @@ GET /api/polls/:identifier
"identifier": "v90034d6",
"question": "Is this a question?",
"multipleChoice": false,
"endDate": {
"date": "2017-05-18 13:45:37.000000",
"timezone_type": 3,
"timezone": "Europe/London"
},
"ended": false,
"deleted": false,
"created": {
"date": "2017-05-18 13:45:37.000000",
Expand Down Expand Up @@ -131,13 +143,20 @@ POST /api/polls
| question | string | true | The question text.
| answers | array | true | Array of answers for the poll. Each answer should be a string |
| multipleChoice | boolean | false | Is the poll multiple choice. Default: false |
| endDate | string | false | The end date for the poll. Format: DateTime::ATOM (e.g. 2017-05-18T15:52:01+00:00). Default: null |
###### Response
```
{
"id": 1,
"identifier": "v90034d6",
"question": "Is this a question?",
"multipleChoice": false,
"endDate": {
"date": "2017-05-18 13:45:37.000000",
"timezone_type": 3,
"timezone": "Europe/London"
},
"ended": false,
"deleted": false,
"created": {
"date": "2017-05-18 13:45:37.000000",
Expand Down Expand Up @@ -186,6 +205,12 @@ DELETE /api/polls/:identifier
"identifier": "v90034d6",
"question": "Is this a question?",
"multipleChoice": false,
"endDate": {
"date": "2017-05-18 13:45:37.000000",
"timezone_type": 3,
"timezone": "Europe/London"
},
"ended": false,
"deleted": true,
"created": {
"date": "2017-05-18 13:45:37.000000",
Expand Down
34 changes: 34 additions & 0 deletions app/DoctrineMigrations/Version20170814224911.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace Application\Migrations;

use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;

/**
* Auto-generated Migration: Please modify to your needs!
*/
class Version20170814224911 extends AbstractMigration
{
/**
* @param Schema $schema
*/
public function up(Schema $schema)
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');

$this->addSql('ALTER TABLE poll ADD end_date DATETIME DEFAULT NULL, ADD ended TINYINT(1) NOT NULL');
}

/**
* @param Schema $schema
*/
public function down(Schema $schema)
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');

$this->addSql('ALTER TABLE poll DROP end_date, DROP ended');
}
}
2 changes: 1 addition & 1 deletion app/Resources/client/.storybook/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ module.exports = {
options: { limit: 8192 }
},
{
test: /\.(sass|scss)$/,
test: /\.(sass|scss|css)$/,
loader: extractStyles.extract({
fallback: 'style-loader',
use: [
Expand Down
17 changes: 10 additions & 7 deletions app/Resources/client/build/karma.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const argv = require('yargs').argv
const webpackConfig = require('./webpack.config')
const project = require('../project.config')
const moduleConfig = webpackConfig.module
const TEST_BUNDLER = './tests/test-bundler.js'
const TEST_BUNDLER = './build/test-bundler.js'

moduleConfig.rules.push({
enforce: 'post',
Expand All @@ -25,12 +25,15 @@ const karmaConfig = {
fixWebpackSourcePaths: true,
skipFilesWithNoCoverage: false
},
files: [{
pattern : TEST_BUNDLER,
watched : false,
served : true,
included : true
}],
files: [
'../../../node_modules/babel-polyfill/browser.js',
{
pattern : TEST_BUNDLER,
watched : false,
served : true,
included : true
}
],
frameworks: ['mocha'],
reporters: ['mocha', 'coverage-istanbul'],
preprocessors: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-env mocha */
import 'normalize.js'
import chai from 'chai'
import sinon from 'sinon'
Expand Down
2 changes: 1 addition & 1 deletion app/Resources/client/build/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ const extractStyles = new ExtractTextPlugin({
})

config.module.rules.push({
test: /\.(sass|scss)$/,
test: /\.(sass|scss|css)$/,
loader: extractStyles.extract({
fallback: 'style-loader',
use: [
Expand Down
2 changes: 1 addition & 1 deletion app/Resources/client/src/components/Back/Back.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react'
import { browserHistory } from 'react-router'
import './Back.scss'

export const Back = () => {
export function Back () {
const submit = () => {
browserHistory.push('/')
}
Expand Down
38 changes: 38 additions & 0 deletions app/Resources/client/src/components/Back/Back.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/* eslint-env mocha */
/* global expect, sinon */
import React from 'react'
import { browserHistory } from 'react-router'
import Back from 'components/Back'
import { shallow, mount } from 'enzyme'

describe('(Component) Back', () => {
const wrapper = shallow(<Back />)

describe('(Render) Back', () => {
it('renders as a Back', () => {
const wrapper = mount(<Back />)

expect(wrapper.name()).to.equal('Back')
})

it('renders as a .container', () => {
expect(wrapper.name()).to.equal('div')
expect(wrapper.hasClass('container')).to.equal(true)
})

it('Should render the icon and text', () => {
wrapper.find('a').should.contain(<i className='fa fa-arrow-left' />)
expect(wrapper.find('a').text()).to.equal(' New Poll')
})

describe('clickEvent', () => {
const wrapper = mount(<Back />)
const spy = sinon.spy(browserHistory, 'push')

it('Should call submit', () => {
wrapper.find('a').simulate('click')
spy.should.have.been.calledWith('/')
})
})
})
})
3 changes: 3 additions & 0 deletions app/Resources/client/src/components/Back/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Back from './Back'

export default Back
36 changes: 22 additions & 14 deletions app/Resources/client/src/components/Button/Button.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import PropTypes from 'prop-types'
import EventBus from 'components/EventBus'
import Spinner from 'components/Spinner/Spinner'
import Spinner from 'components/Spinner'
import './Button.scss'

class Button extends React.Component {
Expand Down Expand Up @@ -36,7 +36,7 @@ class Button extends React.Component {
if (event) {
event.preventDefault()
}
if (!this.isDisabled()) {
if (!this.isDisabled() && this.props.callback) {
this.setState({
disabled : true,
loading : true
Expand All @@ -52,27 +52,35 @@ class Button extends React.Component {
}
}

render = () => (
<button
className={'btn ' + this.props.className + (this.isDisabled() ? ' disabled' : '')}
disabled={this.props.disabled}
onClick={this.handlePress}>
{this.state.loading && <Spinner />}
{!this.state.loading && <span>{this.props.text}</span>}
</button>
)
render () {
const { className, disabled, text } = this.props
const { loading } = this.state
const isDisabled = this.isDisabled()

return (
<button
className={'btn ' + className + (isDisabled ? ' disabled' : '')}
disabled={disabled}
onClick={this.handlePress}>
{loading && <Spinner />}
{!loading && <span>{text}</span>}
</button>
)
}
}

Button.propTypes = {
text : PropTypes.string.isRequired,
text : PropTypes.string,
className : PropTypes.string,
disabled : PropTypes.bool,
callback : PropTypes.func.isRequired,
callback : PropTypes.func,
submitEvent : PropTypes.string
}

Button.defaultProps = {
disabled : false,
text : '',
className : '',
disabled : false,
}

export default Button
Loading

0 comments on commit fddb646

Please sign in to comment.