Skip to content

Commit e19286e

Browse files
author
Natacha Ségala
committed
Add locale data, update user decorator
1 parent e97f821 commit e19286e

File tree

79 files changed

+1310
-549
lines changed

Some content is hidden

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

79 files changed

+1310
-549
lines changed

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ group :development, :test do
6666
end
6767

6868
group :development do
69+
gem 'guard-rspec', require: false
6970
# Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
7071
gem 'web-console', '>= 3.3.0'
7172
gem 'listen', '>= 3.0.5', '< 3.2'

Gemfile.lock

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ GEM
7373
climate_control (0.2.0)
7474
cocaine (0.5.8)
7575
climate_control (>= 0.0.3, < 1.0)
76+
coderay (1.1.2)
7677
coffee-rails (4.2.2)
7778
coffee-script (>= 2.2.0)
7879
railties (>= 4.0.0)
@@ -111,10 +112,25 @@ GEM
111112
factory_girl (~> 4.9.0)
112113
railties (>= 3.0.0)
113114
ffi (1.9.18)
115+
formatador (0.2.5)
114116
geocoder (1.4.4)
115117
get_process_mem (0.2.1)
116118
globalid (0.4.1)
117119
activesupport (>= 4.2.0)
120+
guard (2.14.2)
121+
formatador (>= 0.2.4)
122+
listen (>= 2.7, < 4.0)
123+
lumberjack (>= 1.0.12, < 2.0)
124+
nenv (~> 0.1)
125+
notiffany (~> 0.0)
126+
pry (>= 0.9.12)
127+
shellany (~> 0.0)
128+
thor (>= 0.18.1)
129+
guard-compat (1.2.1)
130+
guard-rspec (4.7.3)
131+
guard (~> 2.1)
132+
guard-compat (~> 1.1)
133+
rspec (>= 2.99.0, < 4.0)
118134
heapy (0.1.3)
119135
i18n (0.9.1)
120136
concurrent-ruby (~> 1.0)
@@ -142,6 +158,7 @@ GEM
142158
loofah (2.1.1)
143159
crass (~> 1.0.2)
144160
nokogiri (>= 1.5.9)
161+
lumberjack (1.0.12)
145162
mail (2.7.0)
146163
mini_mime (>= 0.1.1)
147164
memory_profiler (0.9.8)
@@ -155,9 +172,13 @@ GEM
155172
minitest (5.10.3)
156173
multi_json (1.12.2)
157174
mysql2 (0.4.10)
175+
nenv (0.3.0)
158176
nio4r (2.1.0)
159177
nokogiri (1.8.1)
160178
mini_portile2 (~> 2.3.0)
179+
notiffany (0.1.1)
180+
nenv (~> 0.1)
181+
shellany (~> 0.0)
161182
orm_adapter (0.5.0)
162183
paperclip (5.1.0)
163184
activemodel (>= 4.2.0)
@@ -166,6 +187,9 @@ GEM
166187
mime-types
167188
mimemagic (~> 0.3.0)
168189
pg (0.21.0)
190+
pry (0.11.3)
191+
coderay (~> 1.1.0)
192+
method_source (~> 0.9.0)
169193
public_suffix (3.0.1)
170194
puma (3.10.0)
171195
rack (2.0.3)
@@ -203,6 +227,10 @@ GEM
203227
responders (2.4.0)
204228
actionpack (>= 4.2.0, < 5.3)
205229
railties (>= 4.2.0, < 5.3)
230+
rspec (3.7.0)
231+
rspec-core (~> 3.7.0)
232+
rspec-expectations (~> 3.7.0)
233+
rspec-mocks (~> 3.7.0)
206234
rspec-core (3.7.0)
207235
rspec-support (~> 3.7.0)
208236
rspec-expectations (3.7.0)
@@ -236,6 +264,7 @@ GEM
236264
selenium-webdriver (3.7.0)
237265
childprocess (~> 0.5)
238266
rubyzip (~> 1.0)
267+
shellany (0.0.1)
239268
shoulda (3.5.0)
240269
shoulda-context (~> 1.0, >= 1.0.1)
241270
shoulda-matchers (>= 1.4.1, < 3.0)
@@ -300,6 +329,7 @@ DEPENDENCIES
300329
devise
301330
factory_girl_rails
302331
geocoder
332+
guard-rspec
303333
jbuilder (~> 2.5)
304334
jquery-rails
305335
letter_opener_web

Guardfile

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# A sample Guardfile
2+
# More info at https://github.com/guard/guard#readme
3+
4+
## Uncomment and set this to only include directories you want to watch
5+
# directories %w(app lib config test spec features) \
6+
# .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
7+
8+
## Note: if you are using the `directories` clause above and you are not
9+
## watching the project directory ('.'), then you will want to move
10+
## the Guardfile to a watched dir and symlink it back, e.g.
11+
#
12+
# $ mkdir config
13+
# $ mv Guardfile config/
14+
# $ ln -s config/Guardfile .
15+
#
16+
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
17+
18+
# Note: The cmd option is now required due to the increasing number of ways
19+
# rspec may be run, below are examples of the most common uses.
20+
# * bundler: 'bundle exec rspec'
21+
# * bundler binstubs: 'bin/rspec'
22+
# * spring: 'bin/rspec' (This will use spring if running and you have
23+
# installed the spring binstubs per the docs)
24+
# * zeus: 'zeus rspec' (requires the server to be started separately)
25+
# * 'just' rspec: 'rspec'
26+
27+
guard :rspec, cmd: "bundle exec rspec" do
28+
require "guard/rspec/dsl"
29+
dsl = Guard::RSpec::Dsl.new(self)
30+
31+
# Feel free to open issues for suggestions and improvements
32+
33+
# RSpec files
34+
rspec = dsl.rspec
35+
watch(rspec.spec_helper) { rspec.spec_dir }
36+
watch(rspec.spec_support) { rspec.spec_dir }
37+
watch(rspec.spec_files)
38+
39+
# Ruby files
40+
ruby = dsl.ruby
41+
dsl.watch_spec_files_for(ruby.lib_files)
42+
43+
# Rails files
44+
rails = dsl.rails(view_extensions: %w(erb haml slim))
45+
dsl.watch_spec_files_for(rails.app_files)
46+
dsl.watch_spec_files_for(rails.views)
47+
48+
watch(rails.controllers) do |m|
49+
[
50+
rspec.spec.call("routing/#{m[1]}_routing"),
51+
rspec.spec.call("controllers/#{m[1]}_controller"),
52+
rspec.spec.call("acceptance/#{m[1]}")
53+
]
54+
end
55+
56+
# Rails config changes
57+
watch(rails.spec_helper) { rspec.spec_dir }
58+
watch(rails.routes) { "#{rspec.spec_dir}/routing" }
59+
watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
60+
61+
# Capybara features specs
62+
watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") }
63+
watch(rails.layouts) { |m| rspec.spec.call("features/#{m[1]}") }
64+
65+
# Turnip features and steps
66+
watch(%r{^spec/acceptance/(.+)\.feature$})
67+
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
68+
Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
69+
end
70+
end

ProcFile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
web: bundle exec puma -C config/puma.rb
1+
web: bundle exec rails s
2+
webpacker: webpack-dev-server --port 5001

app/controllers/registrations_controller.rb

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,8 @@ def update
5858
self.resource = resource_class.to_adapter.get!(send(:"current_#{resource_name}").to_key)
5959
prev_unconfirmed_email = resource.unconfirmed_email if resource.respond_to?(:unconfirmed_email)
6060

61-
if account_update_params[:programs].present?
62-
programs = account_update_params[:programs].map { |n| Program.find_by_name(n) }
63-
params = account_update_params.merge!(:programs => programs)
64-
else
65-
params = account_update_params
66-
end
67-
68-
if account_update_params[:password].present?
69-
resource_updated = update_resource(resource, params)
70-
else
71-
params = params.except(:password, :password_confirmation, :current_password)
72-
resource_updated = resource.update_attributes(params)
73-
end
61+
proxy_update_resource = Proc.new { |resource, params| update_resource(resource, params) }
62+
resource_updated = User.update(account_update_params, resource, proxy_update_resource)
7463

7564
yield resource if block_given?
7665
if resource_updated
@@ -136,7 +125,7 @@ def account_update_params
136125
:city,
137126
:thumbnail_image,
138127
:timezone,
139-
:languages => '',
128+
:languages => [],
140129
:programs => []
141130
)
142131
end

app/controllers/test_controller.rb

Whitespace-only changes.

app/controllers/user_profiles_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def show
1313

1414
@data = {
1515
:programs => programs,
16-
:currentUser => user,
16+
:currentUser => current_user,
1717
:timezones => timezones,
1818
:languages => languages
1919
}

app/decorators/user_decorator.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,15 @@ def decorate
4747
:last_logged_in => last_logged_in,
4848
:thumbnail_image => picture,
4949
:description => description,
50-
:timezone => timezone
50+
:timezone => timezone,
51+
:languages => languages
5152
}.merge(availabilities_hash)
5253
end
5354

55+
def languages
56+
user.languages.pluck(:name)
57+
end
58+
5459
def timezone
5560
user.timezone
5661
end

app/javascript/components/AvailabilitiesTable.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,14 @@ class AvailabilitiesTable extends Component {
4545
</TableRowColumn>
4646
<TableRowColumn>
4747
<FormattedMessage
48-
id='Availabilities.tableFrom'
48+
id='from'
4949
defaultMessage='From'
50-
values={ { start_time } }
5150
/>
5251
</TableRowColumn>
5352
<TableRowColumn>
5453
<FormattedMessage
55-
id='Availabilities.tableTo'
54+
id='to'
5655
defaultMessage='To'
57-
values={ { end_time } }
5856
/>
5957
</TableRowColumn>
6058
<TableRowColumn >
@@ -143,13 +141,13 @@ class AvailabilitiesTable extends Component {
143141
</TableHeaderColumn>
144142
<TableHeaderColumn key='start_time'>
145143
<FormattedMessage
146-
id='Availabilities.startTime'
144+
id='startTime'
147145
defaultMessage='Start Time'
148146
/>
149147
</TableHeaderColumn>
150148
<TableHeaderColumn key='end_time'>
151149
<FormattedMessage
152-
id='Availabilities.endTime'
150+
id='endTime'
153151
defaultMessage='End Time'
154152
/>
155153
</TableHeaderColumn>

app/javascript/components/AvailabilityIndexPage.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import React, { Component } from 'react';
33
import PropTypes from 'prop-types';
44
import Paper from 'material-ui/Paper';
55
import RaisedButton from 'material-ui/RaisedButton';
6+
import { FormattedMessage } from 'react-intl';
67

78
import Header from './Header';
89
import AvailabilitiesTable from './AvailabilitiesTable';
@@ -24,9 +25,12 @@ class AvailabilityIndexPage extends Component {
2425
<Header currentUser={ currentUser } />
2526
<Paper zDepth={ 1 } style={ paperMarginOverride } rounded={ false }>
2627
<div className='availabilityIndexContainer'>
27-
I can help with:
28+
<FormattedMessage
29+
id='AvailabilityIndexPage.Help'
30+
defaultMessage='I can help with'
31+
/>
2832
<ul className='availabilityIndexListContainer'>
29-
{ _.map(this.props.programs, ({ name }) => <li className='availabilityListItem' key={name}>{ name }</li>) }
33+
{ _.map(this.props.programs, ({ name }) => <li className='availabilityListItem' key={ name }>{ name }</li>) }
3034
</ul>
3135

3236
{ this.renderAvailabilities() }
@@ -52,7 +56,12 @@ class AvailabilityIndexPage extends Component {
5256
} else {
5357
return (
5458
<a href='/availabilities/new' >
55-
<RaisedButton primary label='Create new availabilities' className='conversationButton' />
59+
<RaisedButton primary className='conversationButton' >
60+
<FormattedMessage
61+
id='availabilityCreateNew'
62+
defaultMessage='Create new availabilities'
63+
/>
64+
</RaisedButton>
5665
</a>
5766
);
5867
}

app/javascript/components/ConversationIndexPage.js

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import MenuItem from 'material-ui/MenuItem';
99
import Subheader from 'material-ui/Subheader';
1010
import Avatar from 'material-ui/Avatar';
1111
import { Link } from 'react-router-dom';
12+
import { FormattedMessage } from 'react-intl';
1213

1314
import { List, ListItem } from 'material-ui/List';
1415
import RaisedButton from 'material-ui/RaisedButton';
@@ -66,21 +67,33 @@ class ConversationIndexPage extends Component {
6667
if (client) {
6768
return (
6869
<a href='/search' >
69-
<RaisedButton primary label='Search for volunteers' className='conversationButton' />
70+
<RaisedButton primary label='' className='conversationButton' >
71+
<FormattedMessage
72+
id='ConversationIndexPage.Search'
73+
defaultMessage='Search for volunteers'
74+
/>
75+
</RaisedButton>
7076
</a>
7177
);
7278
} else if (volunteer) {
7379
return (
7480
<a href='/availabilities/new' >
75-
<RaisedButton primary label='Create new availabilities' className='conversationButton' />
81+
<RaisedButton primary className='conversationButton' >
82+
<FormattedMessage
83+
id='availabilityCreateNew'
84+
/>
85+
</RaisedButton>
7686
</a>
7787
);
7888
}
7989
}();
8090
return (
8191
<List >
8292
<Subheader >
83-
No Message Available
93+
<FormattedMessage
94+
id='ConversationIndexPage.NoMessage'
95+
defaultMessage=' No Message Available'
96+
/>
8497
</Subheader>
8598
{ button }
8699
</List>
@@ -120,7 +133,10 @@ class ConversationIndexPage extends Component {
120133
<IconMenu iconButtonElement={ iconButtonElement } >
121134
<MenuItem>
122135
<Link className='conversationIndexPageLink' to={ { pathname: '/messages/new', query: { recipient: newMessageRecipient, userName: newMessageFirstName } } } >
123-
Reply
136+
<FormattedMessage
137+
id='messageReply'
138+
defaultMessage='Reply'
139+
/>
124140
</Link>
125141
</MenuItem>
126142
</IconMenu>

0 commit comments

Comments
 (0)