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

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
Release of Version 1.0
  • Loading branch information
eedrummer committed Jul 12, 2017
2 parents 301aad6 + bdb1118 commit 268cff7
Show file tree
Hide file tree
Showing 82 changed files with 518 additions and 265 deletions.
1 change: 0 additions & 1 deletion app/controllers/elasticsearch_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,3 @@ def index
end
end
# rubocop:enable Metrics/AbcSize
# rubocop:enable Metrics/PerceivedComplexity
2 changes: 2 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class User < ApplicationRecord

def apply_omniauth(omniauth)
self.email = omniauth['info']['email'] if email.blank? && omniauth['info']
self.first_name = omniauth['info']['given_name'] if omniauth['info']['given_name'] && !omniauth['info']['given_name'].blank?
self.last_name = omniauth['info']['family_name'] if omniauth['info']['family_name'] && !omniauth['info']['family_name'].blank?
authentications.build(provider: omniauth['provider'], uid: omniauth['uid'])
end

Expand Down
2 changes: 1 addition & 1 deletion config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ oid_prefix:
elasticsearch:
log: false

app_version: 0.7
app_version: '1.0'

concept_service_url: 'http://concept-manager.129.83.185.216.xip.io'
2 changes: 2 additions & 0 deletions features/edit_forms.feature
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ Feature: Edit Forms
And I fill in the "search" field with "What"
And I set search filter to "question"
And I click on the "search-btn" button
And I should not see "Result Already Added"
And I use the question search to select "What is your gender?"
And I use the response set search modal to select "Gender Partial"
When I select the add program variable option for the Question "What is your gender?"
Expand All @@ -93,6 +94,7 @@ Feature: Edit Forms
And I use the question search to select "What is your name?"
And I move the Question "What is your name?" up
And I should see "TEST VAR"
And I should see "Result Already Added"
And I click on the "Save" button
And I should see "What is your gender?"
Then I wait 1 seconds
Expand Down
2 changes: 2 additions & 0 deletions features/manage_surveys.feature
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,13 @@ Feature: Manage Surveys
And I click on the option to Revise the Survey with the name "Test Survey"
And I fill in the "search" field with "Form"
And I click on the "search-btn" button
And I should not see "Result Already Added"
And I use the form search to select "Gender Form"
And I use the form search to select "Demographics Form"
And I wait 3 seconds
And I move the Form "Gender Form" down
And I move the Form "Gender Form" up
And I should see "Result Already Added"
And I click on the "Save" button
And I should see "Gender Form"
And I should see "Demographics Form"
Expand Down
19 changes: 8 additions & 11 deletions lib/tasks/data.rake
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ namespace :data do
exit(-1)
end

boolean_rt = ResponseType.where(name: 'Boolean').first

if boolean_rt.blank?
STDERR.puts "Unable to Boolean ResponseType. Did you seed the database?"
exit(-1)
end

rs = ResponseSet.new(created_by: user, status: 'draft',
name: '30 Code Response Set')
responses = []
Expand All @@ -17,23 +24,13 @@ namespace :data do
rs.responses = responses
rs.save!

form = Form.new(name: '500 Question Form', created_by: user, status: 'draft')
500.times do |i|
position = i + 1
q = Question.create(content: "Is your favorite number #{position}?",
created_by: user, status: 'draft')
fq = FormQuestion.new(question: q, position: position)
form.form_questions << fq
end
form.save!

survey = Survey.new(name: '500 Question Survey', created_by: user, status: 'draft')
['a', 'b', 'c', 'd', 'e'].each_with_index do |form_letter, survey_position|
f = Form.new(name: "Form #{form_letter} - 100 questions", created_by: user, status: 'draft')
100.times do |i|
position = i + 1
q = Question.create(content: "Is your favorite letter #{form_letter} and number #{position}?",
created_by: user, status: 'draft')
created_by: user, status: 'draft', response_type: boolean_rt)
fq = FormQuestion.new(question: q, position: position)
f.form_questions << fq
end
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@
"lodash": "^4.17.4",
"node-sass": "^3.10.1",
"postcss-loader": "^1.0.0",
"prop-types": "^15.5.10",
"rails-erb-loader": "3.0.0",
"rc-pagination": "^1.9.7",
"react": "^15.4.0",
"react-addons-shallow-compare": "^15.5.2",
"react-bootstrap": "^0.30.7",
"react-bootstrap": "^0.31.0",
"react-dom": "^15.4.0",
"react-joyride": "^1.10.1",
"react-redux": "^4.4.6",
Expand All @@ -58,6 +59,8 @@
"devDependencies": {
"bootstrap-sass": "^3.3.7",
"chai": "^3.5.0",
"chai-spies": "",
"enzyme": "2.9.1",
"chai-jquery": "^2.0.0",
"eslint": "^3.10.2",
"eslint-plugin-react": "^6.7.1",
Expand Down
6 changes: 5 additions & 1 deletion test/controllers/users/omniauth_callbacks_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ class OmniauthCallbacksControllerTest < ActionDispatch::IntegrationTest
OmniAuth.config.test_mode = true
OmniAuth.config.mock_auth[:openid_connect] = OmniAuth::AuthHash.new(provider: 'openid_connect',
uid: '12345',
info: { email: '[email protected]' })
info: { email: '[email protected]',
given_name: 'Mike',
family_name: 'Smith' })

@admin = User.find_by(email: '[email protected]')
@user_count = User.count
Expand All @@ -27,6 +29,8 @@ class OmniauthCallbacksControllerTest < ActionDispatch::IntegrationTest
user = User.first
assert_equal 1, user.authentications.count, 'expected the new user to be associated with a single authentication'
assert_equal '[email protected]', user.email
assert_equal 'Mike', user.first_name
assert_equal 'Smith', user.last_name
assert_authentication(user.authentications[0], 'openid_connect', '12345')
assert_response :redirect
assert_redirected_to root_url
Expand Down
52 changes: 52 additions & 0 deletions test/frontend/components/accounts/settings_modal_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { expect } from '../../test_helper';
import React from 'react';
import SettingsModal from '../../../../webpack/components/accounts/SettingsModal';
import chai from 'chai';
import spies from 'chai-spies';
import { mount } from 'enzyme';
chai.use(spies);
describe('SettingsModal', () => {




it('should display the user update fields for email, first and last names', () => {
let props = { update: function(){},
disableUserUpdate: "false",
show: true,
closer: function(){},
currentUser:{email: "[email protected]", firstName: "Testy", lastName: "Testington",id: 1},
surveillanceSystems: [],
surveillancePrograms: [],
};

let wrapper = mount(
<SettingsModal {...props}/>
);
// Get the component instance
let instance = wrapper.instance();
instance.renderUserInfo = chai.spy(instance.renderUserInfo);
instance.render();
expect(instance.renderUserInfo).to.have.been.called();
});

it('should not display the user update fields for email, first and last names when disableUserUpdate is true', () => {
let props = { update: function(){},
disableUserUpdate: "true",
show: true,
closer: function(){},
currentUser:{email: "[email protected]", firstName: "Testy", lastName: "Testington",id: 1},
surveillanceSystems: [],
surveillancePrograms: [],
};
let wrapper = mount(
<SettingsModal {...props}/>
);
// Get the component instance
let instance = wrapper.instance();
instance.renderUserInfo = chai.spy(instance.renderUserInfo);
instance.render();
expect(instance.renderUserInfo).to.not.have.been.called();

});
});
1 change: 0 additions & 1 deletion test/frontend/components/question_form_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ describe('QuestionForm', () => {
action: 'new',
questionSubmitter: ()=>{},
draftSubmitter: ()=>{},
show: {false},
questionTypes: {},
responseSets: {1: {id: 1, name: "Colors", description: "A list of colors", oid: "2.16.840.1.113883.3.1502.3.1"}},
responseTypes: {1: {id: 1, name: "Integer", description: "A number", code: "integer"},
Expand Down
20 changes: 14 additions & 6 deletions test/frontend/reducers/test_surveys.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { expect } from '../test_helper';
import surveys from '../../../webpack/reducers/surveys_reducer';
import _ from 'lodash';
import {
FETCH_SURVEY_FULFILLED,
FETCH_SURVEYS_FULFILLED,
DELETE_SURVEY_FULFILLED,
ADD_FORM,
REMOVE_FORM
} from '../../../webpack/actions/types';
Expand All @@ -13,12 +12,12 @@ describe('surveys reducer', () => {
const twoSurveys = [
{id: 1, name: "Red Survey", userId: "[email protected]", forms:[]},
{id: 3, name: "Blue Survey", userId: "[email protected]", forms: twoForms}
];
];

it('should fetch surveys', () => {
const payloadData = {data: twoSurveys};
const action = {type: FETCH_SURVEYS_FULFILLED, payload: payloadData};
const startState = {}
const startState = {};
const nextState = surveys(startState, action);
expect(Object.keys(nextState).length).to.equal(2);
});
Expand All @@ -33,7 +32,7 @@ describe('surveys reducer', () => {
});

it('should add a form', () => {
const survey = {id: 1, name: "Red Survey", userId: "[email protected]", surveyForms:[]}
const survey = {id: 1, name: "Red Survey", userId: "[email protected]", surveyForms:[]};
const form = {id: 1, content: "Is this a form?", formType: ""};
const action = {type: ADD_FORM, payload: {survey, form} };
const startState = {};
Expand All @@ -42,7 +41,7 @@ describe('surveys reducer', () => {
});

it('should not add the same form twice', () => {
const survey = {id: 1, name: "Red Survey", userId: "[email protected]", surveyForms:[]}
const survey = {id: 1, name: "Red Survey", userId: "[email protected]", surveyForms:[]};
const form = {id: 1, content: "Is this a form?", formType: ""};
const action = {type: ADD_FORM, payload: {survey, form} };
const nextState = surveys({}, action);
Expand All @@ -58,4 +57,13 @@ describe('surveys reducer', () => {
const nextState = surveys(startState, action);
expect(nextState["1"].surveyForms.length).to.equal(0);
});

it('should delete a survey', () => {
const action = {type: DELETE_SURVEY_FULFILLED, payload: {data: {id: 1}}};
const startState = {1: {id: 1, name: "Red Survey", userId: "[email protected]"},
2: {id: 2, name: "Blue Survey", userId: "[email protected]"}};
const nextState = surveys(startState, action);
expect(nextState["1"]).to.be.undefined;
expect(nextState["2"].name).to.equal("Blue Survey");
});
});
10 changes: 9 additions & 1 deletion webpack/actions/landing.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import axios from 'axios';

import {
FETCH_STATS
FETCH_STATS,
SET_STATS
} from './types';

export function fetchStats() {
Expand All @@ -11,3 +12,10 @@ export function fetchStats() {
{headers: {'X-Key-Inflection': 'camel'}})
};
}

export function setStats(stats) {
return {
type: SET_STATS,
payload: stats
};
}
19 changes: 16 additions & 3 deletions webpack/actions/search_results_actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import routes from '../routes';
import {
FETCH_SEARCH_RESULTS,
FETCH_MORE_SEARCH_RESULTS,
SET_LAST_SEARCH
SET_LAST_SEARCH,
FETCH_LAST_SEARCH
} from './types';

export function fetchSearchResults(context, searchTerms=null, type=null, programFilter=[], systemFilter=[], myStuffFilter=false) {
Expand All @@ -17,6 +18,18 @@ export function fetchSearchResults(context, searchTerms=null, type=null, program
};
}

export function fetchLastSearch(context, searchTerms=null, type=null, programFilter=[], systemFilter=[], myStuffFilter=false, pages) {
let querySize = pages*10;
return {
type: FETCH_LAST_SEARCH,
meta: {context: context},
payload: axios.get(routes.elasticsearchPath(), {
headers: {'Accept': 'application/json', 'X-Key-Inflection': 'camel'},
params: { type: type, search: searchTerms, programs: programFilter, systems: systemFilter, mystuff: myStuffFilter, size: querySize }
})
};
}

export function fetchMoreSearchResults(context, searchTerms=null, type=null, page, programFilter=[], systemFilter=[], myStuffFilter=false) {
return {
type: FETCH_MORE_SEARCH_RESULTS,
Expand All @@ -28,9 +41,9 @@ export function fetchMoreSearchResults(context, searchTerms=null, type=null, pag
};
}

export function setLastSearch(searchTerms=null, type=null, programFilter=[], systemFilter=[], myStuffFilter=false) {
export function setLastSearch(searchTerms=null, type=null, programFilter=[], systemFilter=[], myStuffFilter=false, page=1) {
return {
type: SET_LAST_SEARCH,
payload: { type: type, search: searchTerms, programs: programFilter, systems: systemFilter, mystuff: myStuffFilter }
payload: { type: type, search: searchTerms, programs: programFilter, systems: systemFilter, mystuff: myStuffFilter, page: page }
};
}
5 changes: 5 additions & 0 deletions webpack/actions/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,15 @@ export const SET_STEPS = 'SET_STEPS';
// Landing types
export const FETCH_STATS = 'FETCH_STATS';
export const FETCH_STATS_FULFILLED = 'FETCH_STATS_FULFILLED';
export const SET_STATS = 'SET_STATS';

// Search types
export const FETCH_SEARCH_RESULTS = 'FETCH_SEARCH_RESULTS';
export const FETCH_SEARCH_RESULTS_FULFILLED = 'FETCH_SEARCH_RESULTS_FULFILLED';
export const FETCH_MORE_SEARCH_RESULTS = 'FETCH_MORE_SEARCH_RESULTS';
export const FETCH_MORE_SEARCH_RESULTS_FULFILLED = 'FETCH_MORE_SEARCH_RESULTS_FULFILLED';
export const FETCH_LAST_SEARCH = 'FETCH_LAST_SEARCH';
export const FETCH_LAST_SEARCH_FULFILLED = 'FETCH_LAST_SEARCH_FULFILLED';
export const SET_LAST_SEARCH = 'SET_LAST_SEARCH';

// Notifications
Expand Down Expand Up @@ -127,6 +130,8 @@ export const SAVE_SURVEY_FULFILLED = 'SAVE_SURVEY_FULFILLED';
export const SAVE_DRAFT_SURVEY = 'SAVE_DRAFT_SURVEY';
export const SAVE_DRAFT_SURVEY_FULFILLED = 'SAVE_DRAFT_SURVEY_FULFILLED';
export const CREATE_SURVEY = 'CREATE_SURVEY';
export const DELETE_SURVEY = 'DELETE_SURVEY';
export const DELETE_SURVEY_FULFILLED = 'DELETE_SURVEY_FULFILLED';

// Current User
export const LOG_OUT = 'LOG_OUT';
Expand Down
3 changes: 2 additions & 1 deletion webpack/components/CodedSetTable.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { Component, PropTypes } from 'react';
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import sortBy from 'lodash/sortBy';

export default class CodedSetTable extends Component {
Expand Down
3 changes: 2 additions & 1 deletion webpack/components/Comment.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { Component, PropTypes } from 'react';
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import parse from 'date-fns/parse';
import distanceInWordsToNow from 'date-fns/distance_in_words_to_now';
import { connect } from 'react-redux';
Expand Down
3 changes: 2 additions & 1 deletion webpack/components/CommentForm.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { Component, PropTypes } from 'react';
import React, { Component } from 'react';
import PropTypes from 'prop-types';
export default class CommentForm extends Component {

render() {
Expand Down
3 changes: 2 additions & 1 deletion webpack/components/DashboardSearch.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { Component, PropTypes } from 'react';
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { Link } from 'react-router';
import { Modal, Button } from 'react-bootstrap';
import { surveillanceSystemsProps }from '../prop-types/surveillance_system_props';
Expand Down
3 changes: 2 additions & 1 deletion webpack/components/Errors.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { Component, PropTypes } from 'react';
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import keys from 'lodash/keys';
import map from 'lodash/map';
import reduce from 'lodash/reduce';
Expand Down
Loading

0 comments on commit 268cff7

Please sign in to comment.