mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-17 06:52:27 +01:00
Merge branch 'dev' for release 2.6.2
This commit is contained in:
commit
f04ee8cbdf
@ -1 +1 @@
|
|||||||
2.6.1
|
2.6.2
|
||||||
|
@ -1,5 +1,13 @@
|
|||||||
# Changelog Fab Manager
|
# Changelog Fab Manager
|
||||||
|
|
||||||
|
## v2.6.2 2017 December 21
|
||||||
|
|
||||||
|
- Support for internet explorer 11
|
||||||
|
- Fix a bug: events order in public list
|
||||||
|
- Fix a bug: unable to create a training credit
|
||||||
|
- Corrected typos in documentation (#96)
|
||||||
|
- Improved test suite coverage
|
||||||
|
|
||||||
## v2.6.1 2017 December 14
|
## v2.6.1 2017 December 14
|
||||||
|
|
||||||
- Updated Portuguese translations (#91)
|
- Updated Portuguese translations (#91)
|
||||||
|
@ -127,7 +127,7 @@ This procedure is not easy to follow so if you don't need to write some code for
|
|||||||
```bash
|
```bash
|
||||||
rake db:create
|
rake db:create
|
||||||
rake db:migrate
|
rake db:migrate
|
||||||
ADMIN_EMAIL=youradminemail ADMIN_PASSWORD=youradminpassword rake db:seed
|
ADMIN_EMAIL='youradminemail' ADMIN_PASSWORD='youradminpassword' rake db:seed
|
||||||
```
|
```
|
||||||
|
|
||||||
9. Create the pids folder used by Sidekiq. If you want to use a different location, you can configure it in `config/sidekiq.yml`
|
9. Create the pids folder used by Sidekiq. If you want to use a different location, you can configure it in `config/sidekiq.yml`
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
//= require jquery
|
//= require jquery
|
||||||
//= require jquery_ujs
|
//= require jquery_ujs
|
||||||
//= require bootstrap
|
//= require bootstrap
|
||||||
|
//= require polyfill
|
||||||
//= require jquery-ui/ui/jquery.ui.core
|
//= require jquery-ui/ui/jquery.ui.core
|
||||||
//= require jquery-ui/ui/jquery.ui.widget
|
//= require jquery-ui/ui/jquery.ui.widget
|
||||||
//= require jquery-ui/ui/jquery.ui.mouse
|
//= require jquery-ui/ui/jquery.ui.mouse
|
||||||
|
@ -31,7 +31,7 @@ Application.Controllers.controller "EventsController", ["$scope", "$state", 'Eve
|
|||||||
theme_id: null
|
theme_id: null
|
||||||
age_range_id: null
|
age_range_id: null
|
||||||
|
|
||||||
|
$scope.monthNames = [<%= t('date.month_names')[1..-1].map { |m| "\"#{m}\"" }.join(', ') %>]
|
||||||
|
|
||||||
##
|
##
|
||||||
# Adds a resultset of events to the bottom of the page, grouped by month
|
# Adds a resultset of events to the bottom of the page, grouped by month
|
||||||
@ -106,19 +106,10 @@ Application.Controllers.controller "EventsController", ["$scope", "$state", 'Eve
|
|||||||
groupEvents = (events) ->
|
groupEvents = (events) ->
|
||||||
if events.length > 0
|
if events.length > 0
|
||||||
eventsGroupedByMonth = _.groupBy(events, (obj) ->
|
eventsGroupedByMonth = _.groupBy(events, (obj) ->
|
||||||
_.map ['month', 'year'], (key, value) -> obj[key]
|
_.map ['month_id', 'year'], (key, value) -> obj[key]
|
||||||
)
|
)
|
||||||
$scope.eventsGroupByMonth = Object.assign($scope.eventsGroupByMonth, eventsGroupedByMonth)
|
$scope.eventsGroupByMonth = Object.assign($scope.eventsGroupByMonth, eventsGroupedByMonth)
|
||||||
|
$scope.monthOrder = Object.keys($scope.eventsGroupByMonth)
|
||||||
monthsOrder = _.sortBy _.keys($scope.eventsGroupByMonth), (k)->
|
|
||||||
monthYearArray = k.split(',')
|
|
||||||
date = new Date()
|
|
||||||
date.setMonth(monthYearArray[0])
|
|
||||||
date.setYear(monthYearArray[1])
|
|
||||||
return -date.getTime()
|
|
||||||
|
|
||||||
$scope.monthOrder = monthsOrder
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## !!! MUST BE CALLED AT THE END of the controller
|
## !!! MUST BE CALLED AT THE END of the controller
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div ng-repeat="month in monthOrder">
|
<div ng-repeat="month in monthOrder">
|
||||||
<h1>{{month.split(',')[0]}}, {{month.split(',')[1]}}</h1>
|
<h1>{{monthNames[month.split(',')[0] - 1]}}, {{month.split(',')[1]}}</h1>
|
||||||
|
|
||||||
<div class="row" ng-repeat="event in (eventsGroupByMonth[month].length/3 | array)">
|
<div class="row" ng-repeat="event in (eventsGroupByMonth[month].length/3 | array)">
|
||||||
|
|
||||||
|
@ -4,5 +4,9 @@ class Credit < ActiveRecord::Base
|
|||||||
has_many :users_credits, dependent: :destroy
|
has_many :users_credits, dependent: :destroy
|
||||||
|
|
||||||
validates :creditable_id, uniqueness: { scope: [:creditable_type, :plan_id] }
|
validates :creditable_id, uniqueness: { scope: [:creditable_type, :plan_id] }
|
||||||
validates :hours, numericality: { greater_than_or_equal_to: 0 }
|
validates :hours, numericality: { greater_than_or_equal_to: 0 }, if: :is_not_training_credit?
|
||||||
|
|
||||||
|
def is_not_training_credit?
|
||||||
|
not (creditable_type === 'Training')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -307,7 +307,7 @@ sudo systemctl list-timers
|
|||||||
|
|
||||||
### Example of command passing env variables
|
### Example of command passing env variables
|
||||||
|
|
||||||
docker-compose run --rm -e ADMIN_EMAIL=xxx ADMIN_PASSWORD=xxx fabmanager bundle exec rake db:seed
|
docker-compose run --rm -e ADMIN_EMAIL=xxx -e ADMIN_PASSWORD=xxx fabmanager bundle exec rake db:seed
|
||||||
|
|
||||||
<a name="update-fabmanager"></a>
|
<a name="update-fabmanager"></a>
|
||||||
## Update Fab-manager
|
## Update Fab-manager
|
||||||
|
35
lib/assets/javascripts/polyfill.js
Normal file
35
lib/assets/javascripts/polyfill.js
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
if (typeof Object.assign !== 'function') {
|
||||||
|
// Must be writable: true, enumerable: false, configurable: true
|
||||||
|
Object.defineProperty(Object, "assign", {
|
||||||
|
value: function assign(target, varArgs) { // .length of function is 2
|
||||||
|
'use strict';
|
||||||
|
if (target == null) { // TypeError if undefined or null
|
||||||
|
throw new TypeError('Cannot convert undefined or null to object');
|
||||||
|
}
|
||||||
|
|
||||||
|
var to = Object(target);
|
||||||
|
|
||||||
|
for (var index = 1; index < arguments.length; index++) {
|
||||||
|
var nextSource = arguments[index];
|
||||||
|
|
||||||
|
if (nextSource != null) { // Skip over if undefined or null
|
||||||
|
for (var nextKey in nextSource) {
|
||||||
|
// Avoid bugs when hasOwnProperty is shadowed
|
||||||
|
if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
|
||||||
|
to[nextKey] = nextSource[nextKey];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return to;
|
||||||
|
},
|
||||||
|
writable: true,
|
||||||
|
configurable: true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Number.isInteger = Number.isInteger || function(value) {
|
||||||
|
return typeof value === 'number' &&
|
||||||
|
isFinite(value) &&
|
||||||
|
Math.floor(value) === value;
|
||||||
|
};
|
63
test/integration/credits/machine_test.rb
Normal file
63
test/integration/credits/machine_test.rb
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
module Credits
|
||||||
|
class TrainingTest < ActionDispatch::IntegrationTest
|
||||||
|
|
||||||
|
# Called before every test method runs. Can be used
|
||||||
|
# to set up fixture information.
|
||||||
|
def setup
|
||||||
|
admin = User.with_role(:admin).first
|
||||||
|
login_as(admin, scope: :user)
|
||||||
|
end
|
||||||
|
|
||||||
|
test 'create machine credit' do
|
||||||
|
|
||||||
|
# First, we create a new credit
|
||||||
|
post '/api/credits',
|
||||||
|
{
|
||||||
|
credit: {
|
||||||
|
creditable_id: 5,
|
||||||
|
creditable_type: 'Machine',
|
||||||
|
hours: 1,
|
||||||
|
plan_id: 1,
|
||||||
|
}
|
||||||
|
}.to_json,
|
||||||
|
default_headers
|
||||||
|
|
||||||
|
# Check response format & status
|
||||||
|
assert_equal 201, response.status, response.body
|
||||||
|
assert_equal Mime::JSON, response.content_type
|
||||||
|
|
||||||
|
# Check the credit was created correctly
|
||||||
|
credit = json_response(response.body)
|
||||||
|
c = Credit.where(id: credit[:id]).first
|
||||||
|
assert_not_nil c, 'Credit was not created in database'
|
||||||
|
|
||||||
|
# Check that 1 hour is associated with the credit
|
||||||
|
assert_equal 1, c.hours
|
||||||
|
end
|
||||||
|
|
||||||
|
test 'update a credit' do
|
||||||
|
put '/api/credits/13',
|
||||||
|
{
|
||||||
|
credit: {
|
||||||
|
creditable_id: 4,
|
||||||
|
creditable_type: 'Machine',
|
||||||
|
hours: 5,
|
||||||
|
plan_id: 3,
|
||||||
|
}
|
||||||
|
}.to_json,
|
||||||
|
default_headers
|
||||||
|
|
||||||
|
# Check response format & status
|
||||||
|
assert_equal 200, response.status, response.body
|
||||||
|
assert_equal Mime::JSON, response.content_type
|
||||||
|
|
||||||
|
# Check the credit was correctly updated
|
||||||
|
credit = json_response(response.body)
|
||||||
|
assert_equal 13, credit[:id]
|
||||||
|
c = Credit.find(credit[:id])
|
||||||
|
assert Time.now - c.updated_at < 1.minute
|
||||||
|
|
||||||
|
assert_equal 5, c.hours
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
53
test/integration/credits/training_test.rb
Normal file
53
test/integration/credits/training_test.rb
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
module Credits
|
||||||
|
class TrainingTest < ActionDispatch::IntegrationTest
|
||||||
|
|
||||||
|
# Called before every test method runs. Can be used
|
||||||
|
# to set up fixture information.
|
||||||
|
def setup
|
||||||
|
admin = User.with_role(:admin).first
|
||||||
|
login_as(admin, scope: :user)
|
||||||
|
end
|
||||||
|
|
||||||
|
test 'create training credit' do
|
||||||
|
|
||||||
|
# First, we create a new credit
|
||||||
|
post '/api/credits',
|
||||||
|
{
|
||||||
|
credit: {
|
||||||
|
creditable_id: 4,
|
||||||
|
creditable_type: 'Training',
|
||||||
|
plan_id: '1',
|
||||||
|
}
|
||||||
|
}.to_json,
|
||||||
|
default_headers
|
||||||
|
|
||||||
|
# Check response format & status
|
||||||
|
assert_equal 201, response.status, response.body
|
||||||
|
assert_equal Mime::JSON, response.content_type
|
||||||
|
|
||||||
|
# Check the credit was created correctly
|
||||||
|
credit = json_response(response.body)
|
||||||
|
c = Credit.where(id: credit[:id]).first
|
||||||
|
assert_not_nil c, 'Credit was not created in database'
|
||||||
|
|
||||||
|
# Check that no hours were associated with the credit
|
||||||
|
assert_nil c.hours
|
||||||
|
end
|
||||||
|
|
||||||
|
test 'create a existing credit' do
|
||||||
|
post '/api/credits',
|
||||||
|
{
|
||||||
|
credit: {
|
||||||
|
creditable_id: 4,
|
||||||
|
creditable_type: 'Training',
|
||||||
|
plan_id: '2',
|
||||||
|
}
|
||||||
|
}.to_json,
|
||||||
|
default_headers
|
||||||
|
|
||||||
|
# Check response format & status
|
||||||
|
assert_equal 422, response.status, response.body
|
||||||
|
assert_equal Mime::JSON, response.content_type
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
x
Reference in New Issue
Block a user