Skip to content

Commit 4d58da4

Browse files
authored
Merge pull request #499 from coopdevs/develop
Release v1.14.0
2 parents f3e99f4 + ad9a8f0 commit 4d58da4

File tree

70 files changed

+1140
-195
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+1140
-195
lines changed

.travis.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
language: ruby
22
cache: bundler
3-
bundler_args: '--without production development'
4-
env: DATABASE_URL=postgres://postgres@localhost/timeoverflow_test
3+
bundler_args: '--without development'
4+
env:
5+
global:
6+
- DATABASE_URL=postgres://postgres@localhost/timeoverflow_test
7+
- CC_TEST_REPORTER_ID=025bc15a0fa9afa52d86ee24fea845cf1d363f48a466bcf2cef8ab80c29acb28
58
before_script:
69
- bundle exec rake db:setup
10+
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
11+
- chmod +x ./cc-test-reporter
12+
- ./cc-test-reporter before-build
713
# allow elasticsearch to be ready - https://docs.travis-ci.com/user/database-setup/#ElasticSearch
814
- sleep 10
15+
after_script:
16+
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
917
services:
1018
- elasticsearch
1119
addons:

Gemfile

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,6 @@ group :test do
6363
gem 'faker', '~> 1.9'
6464
gem 'capybara', '~> 3.13'
6565
gem 'selenium-webdriver', '~> 3.141'
66-
gem 'chromedriver-helper', '~> 2.1'
66+
gem 'webdrivers', '~> 3.0'
6767
gem 'simplecov', '~> 0.16.1', require: false
6868
end
69-
70-
group :production do
71-
gem 'rails_12factor', '0.0.3'
72-
end

Gemfile.lock

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ GEM
5353
sshkit (>= 1.6.1, != 1.7.0)
5454
arbre (1.1.1)
5555
activesupport (>= 3.0.0)
56-
archive-zip (0.11.0)
57-
io-like (~> 0.3.0)
5856
arel (6.0.4)
5957
ast (2.4.0)
6058
autoprefixer-rails (6.3.1)
@@ -96,9 +94,6 @@ GEM
9694
xpath (~> 3.2)
9795
childprocess (0.9.0)
9896
ffi (~> 1.0, >= 1.0.11)
99-
chromedriver-helper (2.1.0)
100-
archive-zip (~> 0.10)
101-
nokogiri (~> 1.8)
10297
chronic (0.10.2)
10398
coderay (1.1.2)
10499
coffee-rails (4.1.0)
@@ -175,7 +170,6 @@ GEM
175170
has_scope (~> 0.6)
176171
railties (>= 4.2, <= 5.2)
177172
responders
178-
io-like (0.3.0)
179173
jquery-rails (4.3.1)
180174
rails-dom-testing (>= 1, < 3)
181175
railties (>= 4.2.0)
@@ -219,6 +213,7 @@ GEM
219213
net-scp (1.2.1)
220214
net-ssh (>= 2.6.5)
221215
net-ssh (2.9.2)
216+
net_http_ssl_fix (0.0.10)
222217
netrc (0.11.0)
223218
nokogiri (1.8.5)
224219
mini_portile2 (~> 2.3.0)
@@ -266,11 +261,6 @@ GEM
266261
rails-i18n (4.0.3)
267262
i18n (~> 0.6)
268263
railties (~> 4.0)
269-
rails_12factor (0.0.3)
270-
rails_serve_static_assets
271-
rails_stdout_logging
272-
rails_serve_static_assets (0.0.3)
273-
rails_stdout_logging (0.0.3)
274264
railties (4.2.11)
275265
actionpack (= 4.2.11)
276266
activesupport (= 4.2.11)
@@ -393,6 +383,11 @@ GEM
393383
binding_of_caller (>= 0.7.2)
394384
railties (>= 4.0)
395385
sprockets-rails (>= 2.0, < 4.0)
386+
webdrivers (3.7.2)
387+
net_http_ssl_fix
388+
nokogiri (~> 1.6)
389+
rubyzip (~> 1.0)
390+
selenium-webdriver (~> 3.0)
396391
whenever (0.9.4)
397392
chronic (>= 0.6.3)
398393
xpath (3.2.0)
@@ -412,7 +407,6 @@ DEPENDENCIES
412407
capistrano-rails (~> 1.1)
413408
capistrano-rbenv (~> 2.1)
414409
capybara (~> 3.13)
415-
chromedriver-helper (~> 2.1)
416410
coffee-rails
417411
dalli
418412
database_cleaner (= 1.6.2)
@@ -435,7 +429,6 @@ DEPENDENCIES
435429
pundit (~> 2.0.0)
436430
rails (~> 4.2)
437431
rails-i18n
438-
rails_12factor (= 0.0.3)
439432
rdiscount
440433
rollbar (= 2.8.3)
441434
rspec-rails (~> 3.8.2)
@@ -453,6 +446,7 @@ DEPENDENCIES
453446
uglifier (= 2.7.2)
454447
unicorn
455448
web-console (= 2.1.3)
449+
webdrivers (~> 3.0)
456450
whenever
457451

458452
RUBY VERSION

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
# TimeOverflow [![View performance data on Skylight](https://badges.skylight.io/problem/grDTNuzZRnyu.svg)](https://oss.skylight.io/app/applications/grDTNuzZRnyu) [![Build Status](https://travis-ci.org/coopdevs/timeoverflow.svg)](https://travis-ci.org/coopdevs/timeoverflow) [![Code Climate](https://codeclimate.com/github/timeoverflow/timeoverflow/badges/gpa.svg)](https://codeclimate.com/github/timeoverflow/timeoverflow)
1+
# TimeOverflow
2+
[![View performance data on Skylight](https://badges.skylight.io/problem/grDTNuzZRnyu.svg)](https://oss.skylight.io/app/applications/grDTNuzZRnyu)
3+
[![Build Status](https://travis-ci.org/coopdevs/timeoverflow.svg)](https://travis-ci.org/coopdevs/timeoverflow)
4+
[![Maintainability](https://api.codeclimate.com/v1/badges/f82c6d98a2441c84f2ef/maintainability)](https://codeclimate.com/github/coopdevs/timeoverflow/maintainability)
5+
[![Test Coverage](https://api.codeclimate.com/v1/badges/f82c6d98a2441c84f2ef/test_coverage)](https://codeclimate.com/github/coopdevs/timeoverflow/test_coverage)
6+
27
#### www.timeoverflow.org
38

49
:globe_with_meridians: Read this [in English](docs/README.en.md)

app/assets/javascripts/application.js.coffee

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#= require give_time
22
#= require tags
33
#= require mobile_app_libs
4+
#= require multi_select2
45

56
$(document).on 'click', 'a[data-popup]', (event) ->
67
window.open($(this).attr('href'), 'popup', 'width=600,height=600')
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
$( document ).ready(function () {
2+
jQuery.validator.addMethod(
3+
"either-hours-minutes-informed",
4+
function (value, element) {
5+
return Boolean($("#transfer_hours").val() || $("#transfer_minutes").val());
6+
},
7+
"Hours or minutes should be informed"
8+
);
9+
10+
function submitHandler(form) {
11+
// just submit when fields are not visible, in order to not break the multi
12+
// transfer wizard
13+
if (!$("#transfer_hours").is(":visible")) {
14+
form.submit();
15+
return;
16+
}
17+
18+
var amount = $("#transfer_hours").val() * 3600 + $("#transfer_minutes").val() * 60;
19+
$("#transfer_amount").val(amount);
20+
21+
if (amount == 0) {
22+
$(form).find('.js-error-amount').removeClass('invisible').show();
23+
return;
24+
}
25+
26+
if ($(form).valid()) {
27+
form.submit();
28+
}
29+
}
30+
31+
var config = {
32+
submitHandler: submitHandler
33+
};
34+
35+
$("#multi_transfer, #new_transfer").validate(config);
36+
})

app/assets/javascripts/give_time.js.coffee

Lines changed: 0 additions & 18 deletions
This file was deleted.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
* A setup function to make select2 jquery plugin play as an ordinary form when
3+
* using the "multiple" flag.
4+
*
5+
* Also allows options to be disabled.
6+
*
7+
*
8+
* @param {String} selector - CSS selector pointing to a <select /> element
9+
* @param {Object} options
10+
* @param {Array<String>} options.value - initial value
11+
* @param {Array<String>} options.disabledOptions - disabled option values to disable
12+
* @param {Array<String>} options.noMatchesFormat - i18n'd string to show when no matches found when filtering
13+
*/
14+
window.initializeSelect2 = function(selector, options) {
15+
var $select = $(selector);
16+
17+
var optionsToDisableSelector = (options.disabledOptions || []).map(function (optionId) {
18+
return "option[value=" + optionId + "]";
19+
}).join(',');
20+
21+
var $options = $select.find(optionsToDisableSelector);
22+
$options.attr('disabled', 'disabled');
23+
24+
$select.select2({
25+
formatNoMatches: function () {
26+
return options.noMatchesFormat
27+
}
28+
});
29+
30+
$select.val(options.value.length === 0 ? null : options.value);
31+
$select.trigger('change');
32+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module WithTransferParams
2+
def transfer_params
3+
permitted_transfer_params = [
4+
:destination,
5+
:amount,
6+
:reason,
7+
:post_id,
8+
]
9+
10+
permitted_transfer_params.push(:source) if admin?
11+
12+
params.
13+
require(:transfer).
14+
permit(*permitted_transfer_params)
15+
end
16+
end
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
class MultiTransfersController < ApplicationController
2+
include WithTransferParams
3+
4+
STEPS = [
5+
'select_type',
6+
'select_source',
7+
'select_target',
8+
'set_params',
9+
'confirm'
10+
]
11+
12+
def step
13+
authorize :multi_transfer
14+
15+
set_steps_info
16+
propagate_params
17+
prepare_template_vars
18+
end
19+
20+
def create
21+
authorize :multi_transfer
22+
23+
operation = Operations::Transfers.create(
24+
from: params[:from],
25+
to: params[:to],
26+
transfer_params: params[:transfer].to_hash
27+
)
28+
operation.perform
29+
end
30+
31+
private
32+
33+
def set_steps_info
34+
@steps = STEPS
35+
@step_name = step_name
36+
@form_action = if @step_name == @steps.last
37+
multi_transfers_create_path
38+
else
39+
multi_transfers_step_path(step: next_step)
40+
end
41+
@is_last_step = is_last_step
42+
end
43+
44+
def propagate_params
45+
@type_of_transfer = (params[:type_of_transfer] || :many_to_one).to_sym
46+
@from = params[:from] || []
47+
@to = params[:to] || []
48+
49+
@transfer_amount = params[:transfer] && params[:transfer][:amount]
50+
@transfer_post_id = params[:transfer] && params[:transfer][:post_id]
51+
@transfer_reason = params[:transfer] && params[:transfer][:reason]
52+
@transfer_minutes = params[:transfer] && params[:transfer][:minutes]
53+
@transfer_hours = params[:transfer] && params[:transfer][:hours]
54+
end
55+
56+
def prepare_template_vars
57+
@accounts = [current_organization.account] + current_organization.member_accounts.merge(Member.active)
58+
59+
if @type_of_transfer == :many_to_one && @to.length == 1
60+
@target_accountable = Account.find(@to.first).accountable
61+
end
62+
63+
@should_render_offer_selector = (
64+
@type_of_transfer.to_sym == :many_to_one &&
65+
@target_accountable &&
66+
@target_accountable.offers.length > 0
67+
)
68+
69+
@from_names = Account.find(@from).map(&:accountable).map(&:to_s)
70+
@to_names = Account.find(@to).map(&:accountable).map(&:to_s)
71+
@post_title = @transfer_post_id && Post.find(@transfer_post_id).title
72+
end
73+
74+
def step_index
75+
params[:step].to_i - 1
76+
end
77+
78+
def next_step
79+
params[:step].to_i + 1
80+
end
81+
82+
def step_name
83+
STEPS[step_index]
84+
end
85+
86+
def is_last_step
87+
step_index == STEPS.length - 1
88+
end
89+
end

0 commit comments

Comments
 (0)