Skip to content

Commit

Permalink
Merge pull request
Browse files Browse the repository at this point in the history
Adicionando testes de unidade
  • Loading branch information
ThalissonMelo authored Dec 9, 2017
2 parents 0d334ea + 6bed806 commit cfa2028
Show file tree
Hide file tree
Showing 40 changed files with 1,530 additions and 121 deletions.
15 changes: 15 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
"opn": "^5.1.0",
"optimize-css-assets-webpack-plugin": "^2.0.0",
"ora": "^1.2.0",
"phantomjs-polyfill-object-assign": "0.0.2",
"phantomjs-prebuilt": "^2.1.15",
"rimraf": "^2.6.0",
"selenium-server": "^3.0.1",
Expand All @@ -88,6 +89,7 @@
"vue-loader": "^13.0.4",
"vue-style-loader": "^3.0.1",
"vue-template-compiler": "^2.4.2",
"vue-test-utils": "^1.0.0-beta.6",
"webpack": "^2.6.1",
"webpack-bundle-analyzer": "^2.2.1",
"webpack-dev-middleware": "^1.10.0",
Expand Down
37 changes: 7 additions & 30 deletions src/components/Authentication/Login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,40 +45,17 @@ export default {
};
},
computed: {
...mapState({
token: state => state.auth.token,
userId: state => state.auth.userId,
}),
},
methods: {
login() {
const thisOne = this;
this.$store.dispatch('login', { email: this.email, password: this.password })
.then(() => {
this.$router.push({ name: 'Projects' });
})
.catch((err) => {
thisOne.errors.add('wrong-credentials', 'Wrong Credentials');
console.log(err); // It goes here!
});
},
isGitHubAuthenticated() {
const headers = { Authorization: this.token };
HTTP.get(`users/${this.userId}`, { headers })
.then((response) => {
if (response.data.access_token != null) {
localStorage.setItem('is_github_authenticated', 'true');
} else {
localStorage.setItem('is_github_authenticated', 'false');
}
})
.catch((err) => {
console.log(err); // It goes here!
});
this.$store.dispatch('login', { email: this.email, password: this.password })
.then((res) => {
this.$router.push({ name: 'Projects' });
})
.catch((err) => {
thisOne.errors.add('wrong-credentials', 'Wrong Credentials');
});
},
},
};
Expand Down
10 changes: 3 additions & 7 deletions src/components/GitHub/GitHubCallBack.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,10 @@ export default {
mounted() {
const code = window.location.search.split('=')[1];
const headers = { Authorization: this.token };
HTTP.post('request_github_token', {
code,
id: this.userId,
}, { headers })
.then((response) => {
this.github_token = response.data.access_token;
this.$store.dispatch('linkGithub', { code, headers, userId: this.userId })
.then(() => {
this.$router.push({ name: 'UserProfile' });
})
})
.catch((e) => {
this.errors.push(e);
});
Expand Down
1 change: 0 additions & 1 deletion src/components/Projects/DeleteProject.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ export default {
computed: {
...mapState({
token: state => state.auth.token,
userId: state => state.auth.userId,
}),
},
methods: {
Expand Down
1 change: 0 additions & 1 deletion src/components/Projects/Projects.vue
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ export default {
refreshProjects() {
this.getProjects();
this.gitHubAuthenticated();
},
isProjectsEmpty() {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Releases/AddRelease.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export default {
this.description = '';
this.initialDate = '';
this.finalDate = '';
EventBus.$emit('added-release', 1);
this.$emit('added');
})
.catch((e) => {
this.errors.push(e);
Expand Down
15 changes: 7 additions & 8 deletions src/components/Releases/Release.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
</li>
<li class="list-inline-item vertical-center small-float-right">
<h5 class="float-left">
{{dateConvert(release.initial_date)}}
{{converted_initial_date}}
|
{{dateConvert(release.final_date)}}
{{converted_final_date}}
</h5>
</li>
<p class="text-justify text-muted">
Expand Down Expand Up @@ -55,6 +55,8 @@ export default {
data() {
return {
release: {},
converted_initial_date: "",
converted_final_date: ""
};
},
Expand All @@ -73,7 +75,8 @@ export default {
HTTP.get(`releases/${this.$route.params.id}`, { headers })
.then((response) => {
this.release = response.data;
this.converted_initial_date = this.dateConvert(this.release.initial_date);
this.converted_final_date = this.dateConvert(this.release.final_date)
this.setReleaseDates();
})
.catch((e) => {
Expand All @@ -91,11 +94,7 @@ export default {
},
},
ready() {
this.dateConvert();
},
mounted() {
created() {
this.getRelease();
},
};
Expand Down
12 changes: 2 additions & 10 deletions src/components/Releases/Releases.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</div>
<div class="row">
<div class="col">
<add-release></add-release>
<add-release v-on:added="getReleases()"></add-release>
</div>
</div>

Expand Down Expand Up @@ -87,7 +87,7 @@ export default {
methods: {
getReleases() {
const headers = { Authorization: this.token };
console.log(headers);
HTTP.get(`projects/${this.$route.params.id}/releases`, { headers })
.then((response) => {
this.releases = response.data;
Expand All @@ -102,17 +102,9 @@ export default {
},
ready() {
this.dateConvert();
},
mounted() {
this.getReleases();
},
updated() {
this.getReleases();
},
};
</script>

Expand Down
2 changes: 1 addition & 1 deletion src/components/Retrospective/DeleteRetrospective.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ export default {
methods: {
async deleteRetrospective() {
const headers = { Authorization: this.token };
try {
const response = await HTTP.get(`/retrospectives/${this.$route.params.id}`, { headers });
const id = response.data.sprint_id;
await HTTP.delete(`/retrospectives/${this.$route.params.id}`, { headers });
this.$router.push({ path: `/Sprints/${id}` });
} catch (err) {
console.log(err);
Expand Down
8 changes: 4 additions & 4 deletions src/components/Sprints/DeleteSprint.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<template>
<div class="delsprint">
<button type="button" class="btn btn-info btn-md falko-button-danger" id="deletebutton" data-toggle="modal" data-target="#delSprintModal">
<button type="button" class="btn btn-info btn-md falko-button-danger" id="deletebutton" data-toggle="modal" data-target="#deleteSprintModal">
Delete
</button>
<div class="modal fade" id ="delSprintModal" role="dialog">
<div class="modal fade" id ="deleteSprintModal" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
Expand All @@ -18,7 +18,7 @@
<p><label> Are you sure?</label></p>
</div>
<div class="modal-footer">
<button v-on:click="delSprint" type="button" class="btn btn-info btn-md falko-button" data-dismiss="modal" >Yes</button>
<button v-on:click="deleteSprint" type="button" class="btn btn-info btn-md falko-button" data-dismiss="modal" >Yes</button>
<button type="button" class="btn btn-info btn-md falko-button-grey" data-dismiss="modal">No</button>
</div>
</div>
Expand All @@ -39,7 +39,7 @@ export default {
}),
},
methods: {
async delSprint() {
async deleteSprint() {
const headers = { Authorization: this.token };
try {
Expand Down
6 changes: 2 additions & 4 deletions src/components/Sprints/Sprint.vue
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,8 @@ export default{
},
getRevision() {
const token = localStorage.getItem('token');
const tokenSimple = token.replace(/"/, '');
const tokenSimple2 = tokenSimple.replace(/"/, '');
const headers = { Authorization: tokenSimple2 };
const headers = { Authorization: this.token };
HTTP.get(`sprints/${this.$route.params.id}/revisions`, { headers })
.then((response) => {
this.sprintRevision = response.data;
Expand Down
22 changes: 21 additions & 1 deletion src/services/auth/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ import { HTTP } from '../../http-common';

const LOGIN = 'LOGIN';
const LOGOUT = 'LOGOUT';

const LINK_GITHUB = 'LINK_GITHUB';
const UNLINK_GITHUB = 'UNLINK_GITHUB';
const auth = {
state() {
return {
authenticated: false,
token: null,
userId: null,
githubAuthenticated: false,
};
},
mutations: {
Expand All @@ -24,6 +26,14 @@ const auth = {
localState.userId = null;
localState.authenticated = false;
},
[LINK_GITHUB](state) {
const localState = state;
localState.githubAuthenticated = true;
},
[UNLINK_GITHUB](state) {
const localState = state;
localState.githubAuthenticated = false;
},
},
actions: {
login({ commit }, credentials) {
Expand All @@ -40,6 +50,16 @@ const auth = {
logout({ commit }) {
commit(LOGOUT);
},

linkGithub({ commit }, credentials) {
return HTTP.post('request_github_token', {
code: credentials.code,
id: credentials.userId,
}, { headers: credentials.headers })
.then(() => {
commit(LINK_GITHUB);
});
},
},
};

Expand Down
4 changes: 3 additions & 1 deletion test/unit/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ module.exports = function (config) {
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['mocha', 'sinon-chai'],
reporters: ['spec', 'coverage'],
files: ['../../node_modules/es6-promise/dist/es6-promise.auto.js', './index.js'],
files: ['../../node_modules/es6-promise/dist/es6-promise.auto.js',
'../../node_modules/phantomjs-polyfill-object-assign/object-assign-polyfill.js',
'./index.js'],
// we will pass the entry file to webpack for bundling.
preprocessors: {
'./index.js': ['webpack', 'sourcemap'],
Expand Down
Loading

0 comments on commit cfa2028

Please sign in to comment.