Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GSoC19] Rc articles tests and improvements #9

Open
wants to merge 21 commits into
base: rc_articles
Choose a base branch
from

Conversation

shubhsherl
Copy link
Owner

@shubhsherl shubhsherl commented Jul 17, 2019

This PR adds:

@shubhsherl shubhsherl changed the title [GSoC19] Rc articles tests [GSoC19] Rc articles tests and improvements Jul 17, 2019
setRcTitle(rcTitle) {
// Grab the post and current stored twitter title
let post = this.post;
let currentTitle = post.get('rcTitle');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems post & currentTitle are not mutable, we can use const.

}
this.rcServices.getRoom(newRoom)
.then((room) => {
const existingRCRoom = room.data[0].exist && room.data[0].roomname === newRoom;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as we mentioned in another pull request, please use es6 destructuring feature.

clearRcImage() {
this.set('post.rcImage', '');

if (this.get('post.isNew')) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we extract all

if (this.get('post.isNew')) {
    return;
 }

to a util method, we should not duplicate it.

if (role === 'Contributors') {
isParent = this.currentUser.get('id') === user.parentId && user.roles.get('firstObject').name === 'Contributor';
}
return user.status === 'inactive' && (role ? isParent || user.roles.get('firstObject').name === role : true);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In activeUsers & suspendedUsers has duplicate logic, please think to build common method.

let isParent = false;
if (role === 'Contributors') {
    isParent = this.currentUser.get('id') === user.parentId && user.roles.get('firstObject').name === 'Contributor';
}
return user.status === 'inactive' && (role ? isParent || user.roles.get('firstObject').name === role : true);

return new RSVP.Promise((resolve) => {
if (this.get('settings.isComments') && this.isPublished && !this.discussionRoomId && this.displayName === 'post') {
return this.rcServices.createDiscussion(this.title, this.discussionRoomType).then((room) => {
if (room && room.data[0].created) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can destructing value like [{create, rid, roomname, type}] = room.data;

@shubhsherl
Copy link
Owner Author

@unclebean updated with changes as requested.
0a51782

@unclebean
Copy link

@shubhsherl well done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants