Skip to content
This repository has been archived by the owner on Oct 1, 2019. It is now read-only.

Commit

Permalink
Merge stable into master
Browse files Browse the repository at this point in the history
  • Loading branch information
indeyets committed Sep 23, 2016
2 parents d85ff73 + 69d7d52 commit 6eb304c
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 30 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
"unexpected-react": "^3.1.1",
"unexpected-sinon": "^10.4.0",
"url-loader": "^0.5.7",
"webpack": "^2.1.0-beta.1",
"webpack": "^2.1.0-beta.24",
"webpack-dev-middleware": "^1.6.1",
"webpack-hot-middleware": "^2.6.0",
"webpack-koa-hot-middleware": "^0.1.2",
Expand Down
4 changes: 1 addition & 3 deletions src/components/follow-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import React, { PropTypes } from 'react';
import { find } from 'lodash';

import {
ArrayOfUsersId as ArrayOfUsersIdPropType,
Expand Down Expand Up @@ -62,8 +61,7 @@ export default class FollowButton extends React.Component {
return null; // do not allow to follow one's self
}

const is_followed = find(following, user.id);
if (is_followed) {
if (following.includes(user.id)) {
return <button className="button button-wide button-yellow" onClick={this.unfollowUser}>Following</button>;
}

Expand Down
5 changes: 3 additions & 2 deletions src/components/register.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,8 @@ export class Register extends React.Component {
{fields.agree.error &&
<Message message={fields.agree.error} />
}
<div className="layout__grid layout__grid-big layout-align_vertical">
<button className="button button-big button-green">Sign up</button>
{/* TODO: Get rid of layout__grid. This is a temporary solution. */}
<div className="layout__grid layout__grid-big layout__grid-responsive layout__grid-row_reverse layout-align_vertical layout-align_right">
<label className="action checkbox">
<input
id="registerAgree"
Expand All @@ -301,6 +301,7 @@ export class Register extends React.Component {
/>
<span className="checkbox__label-right">I agree to Terms &amp; Conditions</span>
</label>
<button className="button button-big button-green">Sign up</button>
</div>
</div>
</form>
Expand Down
5 changes: 4 additions & 1 deletion test-helpers/factories/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ const faker = require('faker');

export default new Factory()
.attr('id', () => uuid.v4())
.attr('created_at', () => faker.date.recent())
.attr('updated_at', () => faker.date.recent())
.attr('username', () => faker.internet.userName().toLowerCase())
.attr('email', () => faker.internet.email())
.attr('password', () => faker.internet.password())
.attr('hashed_password', ['password'], password => bcrypt.hashSync(password, 10))
.attr('email_check_hash', '');
.attr('email_check_hash', '')
.attr('more', { first_login: false });
48 changes: 45 additions & 3 deletions test/unit/components/follow-button.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,57 @@
/*eslint-env node, mocha */
import { shallow } from 'enzyme';
import { v4 as uuid4 } from 'uuid';

import { TestUtils, unexpected, expect, React } from '../../../test-helpers/expect-unit';
import { expect, React } from '../../../test-helpers/expect-unit';
import FollowButton from '../../../src/components/follow-button';
import userFactory from '../../../test-helpers/factories/user';


describe('Follow button Test', function() {
describe('Follow button Test', function () {
const currentUser = userFactory.build();
currentUser.favourites = [];
currentUser.geotags = [];
currentUser.hashtags = [];
currentUser.schools = [];
currentUser.suggested_users = [];
currentUser.followed_geotags = [];
currentUser.followed_hashtags = [];
currentUser.followed_schools = [];
currentUser.liked_geotags = [];
currentUser.liked_hashtags = [];
currentUser.liked_schools = [];
currentUser.likes = [];
currentUser.recent_tags = {
geotags: [],
hashtags: [],
schools: []
};

it('is empty for anonym user or when no current_user in props', function() {
it('is empty for anonym user or when no current_user in props', function () {
const wrapper = shallow(<FollowButton />);

return expect(wrapper.equals(null), 'to be true');
});

it('should render "Follow" for unfollowed users', () => {
const props = {
active_user: currentUser,
following: [uuid4(), uuid4()],
user: userFactory.build()
};
const wrapper = shallow(<FollowButton {...props} />);
return expect(wrapper.text(), 'to be', 'Follow');
});

it('should render "Following" for followed users', () => {
const user = userFactory.build();

const props = {
active_user: currentUser,
following: [uuid4(), uuid4(), user.id],
user
};
const wrapper = shallow(<FollowButton {...props} />);
return expect(wrapper.text(), 'to be', 'Following');
});
});
23 changes: 13 additions & 10 deletions webpack.dev.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module.exports = {
],

resolve: {
extensions: ['', '.js', '.jsx', '.less']
extensions: ['.js', '.jsx', '.less']
},

output: {
Expand All @@ -24,15 +24,14 @@ module.exports = {
},

module: {
postLoaders: [
rules: [
// Fix grapheme-breaker
{
enforce: 'post',
test: /\.js$/,
include: /node_modules\/grapheme-breaker/,
loader: 'transform/cacheable?brfs'
}
],
loaders: [
},
{
test: /\.jsx?$/,
exclude: /node_modules/,
Expand Down Expand Up @@ -69,13 +68,17 @@ module.exports = {
new webpack.NoErrorsPlugin(),
new webpack.DefinePlugin({
__DEV__: true
}),
new webpack.LoaderOptionsPlugin({
debug: true,
options: {
context: __dirname,
postcss: [
autoprefixer
]
}
})
],

postcss: () => {
return [autoprefixer];
},

debug: true,
devtool: 'cheap-module-inline-source-map'
};
23 changes: 13 additions & 10 deletions webpack.prod.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = {
],

resolve: {
extensions: ['', '.js', '.jsx', '.less']
extensions: ['.js', '.jsx', '.less']
},

output: {
Expand All @@ -21,15 +21,14 @@ module.exports = {
},

module: {
postLoaders: [
rules: [
// Fix grapheme-breaker
{
enforce: 'post',
test: /\.js$/,
include: /node_modules\/grapheme-breaker/,
loader: 'transform/cacheable?brfs'
}
],
loaders: [
},
{
test: /\.jsx?$/,
exclude: /node_modules/,
Expand Down Expand Up @@ -62,10 +61,14 @@ module.exports = {
new ExtractTextPlugin({
filename: 'styles.css',
allChunks: true
}),
new webpack.LoaderOptionsPlugin({
options: {
context: __dirname,
postcss: [
autoprefixer
]
}
})
],

postcss: () => {
return [autoprefixer];
}
]
};

0 comments on commit 6eb304c

Please sign in to comment.