Maarten van den Berg 6 years ago
parent
commit
ee99c95ca7

+ 0 - 75
.rubocop.yml

34
   Exclude:
34
   Exclude:
35
     - 'app/models/activity.rb'
35
     - 'app/models/activity.rb'
36
 
36
 
37
-# Offense count: 2
38
-# Cop supports --auto-correct.
39
-# Configuration parameters: EnforcedStyle.
40
-# SupportedStyles: space, no_space
41
-Layout/SpaceAroundEqualsInParameterDefault:
42
-  Exclude:
43
-    - 'app/helpers/authentication_helper.rb'
44
-    - 'app/models/activity.rb'
45
-
46
-# Offense count: 1
47
-# Cop supports --auto-correct.
48
-# Configuration parameters: AllowForAlignment.
49
-Layout/SpaceAroundOperators:
50
-  Exclude:
51
-    - 'app/controllers/activities_controller.rb'
52
-
53
-# Offense count: 7
54
-# Cop supports --auto-correct.
55
-# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces.
56
-# SupportedStyles: space, no_space
57
-# SupportedStylesForEmptyBraces: space, no_space
58
-Layout/SpaceBeforeBlockBraces:
59
-  Exclude:
60
-    - 'app/controllers/activities_controller.rb'
61
-    - 'app/controllers/api/activities_controller.rb'
62
-    - 'app/controllers/groups_controller.rb'
63
-
64
-# Offense count: 4
65
-# Cop supports --auto-correct.
66
-# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBrackets.
67
-# SupportedStyles: space, no_space, compact
68
-# SupportedStylesForEmptyBrackets: space, no_space
69
-Layout/SpaceInsideArrayLiteralBrackets:
70
-  Exclude:
71
-    - 'app/controllers/members_controller.rb'
72
-    - 'config/environments/production.rb'
73
-
74
-# Offense count: 9
75
-# Cop supports --auto-correct.
76
-# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
77
-# SupportedStyles: space, no_space
78
-# SupportedStylesForEmptyBraces: space, no_space
79
-Layout/SpaceInsideBlockBraces:
80
-  Exclude:
81
-    - 'app/controllers/activities_controller.rb'
82
-    - 'app/controllers/api/activities_controller.rb'
83
-    - 'app/controllers/groups_controller.rb'
84
-    - 'config/puma.rb'
85
-
86
-# Offense count: 20
87
-# Cop supports --auto-correct.
88
-# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces.
89
-# SupportedStyles: space, no_space, compact
90
-# SupportedStylesForEmptyBraces: space, no_space
91
-Layout/SpaceInsideHashLiteralBraces:
92
-  Exclude:
93
-    - 'app/models/activity.rb'
94
-    - 'app/models/person.rb'
95
-    - 'config/environments/production.rb'
96
-    - 'test/controllers/activities_controller_test.rb'
97
-    - 'test/controllers/api/activities_controller_test.rb'
98
-    - 'test/controllers/api/groups_controller_test.rb'
99
-    - 'test/controllers/api/people_controller_test.rb'
100
-    - 'test/controllers/groups_controller_test.rb'
101
-    - 'test/controllers/members_controller_test.rb'
102
-    - 'test/controllers/people_controller_test.rb'
103
-
104
-# Offense count: 4
105
-# Cop supports --auto-correct.
106
-# Configuration parameters: EnforcedStyle.
107
-# SupportedStyles: space, no_space
108
-Layout/SpaceInsideParens:
109
-  Exclude:
110
-    - 'app/controllers/activities_controller.rb'
111
-
112
 # Offense count: 1
37
 # Offense count: 1
113
 # Cop supports --auto-correct.
38
 # Cop supports --auto-correct.
114
 # Configuration parameters: IndentationWidth.
39
 # Configuration parameters: IndentationWidth.

+ 5 - 5
app/controllers/activities_controller.rb

48
                            .joins(:person)
48
                            .joins(:person)
49
                            .where(is_organizer: true)
49
                            .where(is_organizer: true)
50
                            .order('people.first_name ASC')
50
                            .order('people.first_name ASC')
51
-                           .map{|p| p.person.full_name}
51
+                           .map { |p| p.person.full_name }
52
                            .join(', ')
52
                            .join(', ')
53
     @ownparticipant = @activity.participants
53
     @ownparticipant = @activity.participants
54
                                .find_by(person: current_person)
54
                                .find_by(person: current_person)
61
     @subgroup_ids = @activity.subgroups
61
     @subgroup_ids = @activity.subgroups
62
                              .order(name: :asc)
62
                              .order(name: :asc)
63
                              .pluck(:name, :id)
63
                              .pluck(:name, :id)
64
-    @subgroup_ids.prepend( [I18n.t('activities.subgroups.filter_nofilter'), 'all'] )
65
-    @subgroup_ids.append( [I18n.t('activities.subgroups.filter_nogroup'), 'withoutgroup'] )
64
+    @subgroup_ids.prepend([I18n.t('activities.subgroups.filter_nofilter'), 'all'])
65
+    @subgroup_ids.append([I18n.t('activities.subgroups.filter_nogroup'), 'withoutgroup'])
66
   end
66
   end
67
 
67
 
68
   # GET /activities/new
68
   # GET /activities/new
155
     @non_organizers = @activity.participants.where(is_organizer: [false, nil])
155
     @non_organizers = @activity.participants.where(is_organizer: [false, nil])
156
     @organizers = @activity.organizers
156
     @organizers = @activity.organizers
157
 
157
 
158
-    @non_organizers_options = @non_organizers.map{|p| [p.person.full_name, p.id] }
159
-    @organizers_options     = @organizers.map{|p| [p.person.full_name, p.id] }
158
+    @non_organizers_options = @non_organizers.map { |p| [p.person.full_name, p.id] }
159
+    @organizers_options     = @organizers.map { |p| [p.person.full_name, p.id] }
160
 
160
 
161
     @non_organizers_options.sort!
161
     @non_organizers_options.sort!
162
     @organizers_options.sort!
162
     @organizers_options.sort!

+ 3 - 3
app/controllers/api/activities_controller.rb

33
 
33
 
34
     absent = as.where(attending: false)
34
     absent = as.where(attending: false)
35
 
35
 
36
-    presentnames = present.map{|p| p.person.first_name }
36
+    presentnames = present.map { |p| p.person.first_name }
37
 
37
 
38
-    unknownnames = unknown.map{|p| p.person.first_name }
38
+    unknownnames = unknown.map { |p| p.person.first_name }
39
 
39
 
40
-    absentnames = absent.map{|p| p.person.first_name }
40
+    absentnames = absent.map { |p| p.person.first_name }
41
 
41
 
42
     if presentnames.positive?
42
     if presentnames.positive?
43
       present_mess = I18n.t('activities.participant.these_present', count: present.count, names: presentnames.join(', '))
43
       present_mess = I18n.t('activities.participant.these_present', count: present.count, names: presentnames.join(', '))

+ 1 - 1
app/controllers/groups_controller.rb

39
     @upcoming_ps = Participant
39
     @upcoming_ps = Participant
40
                    .where(person: current_person)
40
                    .where(person: current_person)
41
                    .where(activity: @upcoming)
41
                    .where(activity: @upcoming)
42
-                   .map{ |p| [p.activity_id, p]}
42
+                   .map { |p| [p.activity_id, p] }
43
                    .to_h
43
                    .to_h
44
   end
44
   end
45
 
45
 

+ 1 - 1
app/controllers/members_controller.rb

2
   include GroupsHelper
2
   include GroupsHelper
3
   before_action :set_group
3
   before_action :set_group
4
   before_action :set_member, only: [:show, :edit, :update, :destroy, :promote, :demote]
4
   before_action :set_member, only: [:show, :edit, :update, :destroy, :promote, :demote]
5
-  before_action :require_leader!, except: [ :index ]
5
+  before_action :require_leader!, except: [:index]
6
 
6
 
7
   # GET /members
7
   # GET /members
8
   # GET /members.json
8
   # GET /members.json

+ 1 - 1
app/helpers/authentication_helper.rb

1
 module AuthenticationHelper
1
 module AuthenticationHelper
2
   # Create a new Session and set the relevant cookies.
2
   # Create a new Session and set the relevant cookies.
3
-  def log_in(user, remember, new=true)
3
+  def log_in(user, remember, new = true)
4
     reset_session
4
     reset_session
5
 
5
 
6
     expiry = 6.hours.since
6
     expiry = 6.hours.since

+ 2 - 2
app/models/activity.rb

165
 
165
 
166
   # Create multiple Activities from data in a CSV file, assign to a group, return.
166
   # Create multiple Activities from data in a CSV file, assign to a group, return.
167
   def self.from_csv(content, group)
167
   def self.from_csv(content, group)
168
-    reader = CSV.parse(content, {headers: true, skip_blanks: true})
168
+    reader = CSV.parse(content, { headers: true, skip_blanks: true })
169
 
169
 
170
     result = []
170
     result = []
171
     reader.each do |row|
171
     reader.each do |row|
238
   end
238
   end
239
 
239
 
240
   # Assign a subgroup to all attending participants without one.
240
   # Assign a subgroup to all attending participants without one.
241
-  def assign_subgroups!(mail= false)
241
+  def assign_subgroups!(mail = false)
242
     # Sanity check: we need subgroups to divide into.
242
     # Sanity check: we need subgroups to divide into.
243
     return unless self.subgroups.any?
243
     return unless self.subgroups.any?
244
 
244
 

+ 1 - 1
app/models/person.rb

77
 
77
 
78
   # Create multiple Persons from data found in a csv file, return those.
78
   # Create multiple Persons from data found in a csv file, return those.
79
   def self.from_csv(content)
79
   def self.from_csv(content)
80
-    reader = CSV.parse(content, {headers: true, skip_blanks: true})
80
+    reader = CSV.parse(content, { headers: true, skip_blanks: true })
81
 
81
 
82
     result = []
82
     result = []
83
     reader.each do |row|
83
     reader.each do |row|

+ 2 - 2
config/environments/production.rb

19
   config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
19
   config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
20
 
20
 
21
   # Compress JavaScripts and CSS.
21
   # Compress JavaScripts and CSS.
22
-  config.assets.js_compressor = Uglifier.new({harmony: true})
22
+  config.assets.js_compressor = Uglifier.new({ harmony: true })
23
   # config.assets.css_compressor = :sass
23
   # config.assets.css_compressor = :sass
24
 
24
 
25
   # Do not fallback to assets pipeline if a precompiled asset is missed.
25
   # Do not fallback to assets pipeline if a precompiled asset is missed.
47
   config.log_level = :debug
47
   config.log_level = :debug
48
 
48
 
49
   # Prepend all log lines with the following tags.
49
   # Prepend all log lines with the following tags.
50
-  config.log_tags = [ :request_id ]
50
+  config.log_tags = [:request_id]
51
 
51
 
52
   # Use a different cache store in production.
52
   # Use a different cache store in production.
53
   # config.cache_store = :mem_cache_store
53
   # config.cache_store = :mem_cache_store

+ 1 - 1
config/puma.rb

9
 
9
 
10
 # Specifies the `port` that Puma will listen on to receive requests, default is 3000.
10
 # Specifies the `port` that Puma will listen on to receive requests, default is 3000.
11
 #
11
 #
12
-bind	ENV.fetch("PUMA_BIND") { 'tcp://127.0.0.1:3000'}
12
+bind	ENV.fetch("PUMA_BIND") { 'tcp://127.0.0.1:3000' }
13
 
13
 
14
 # Specifies the `environment` that Puma will run in.
14
 # Specifies the `environment` that Puma will run in.
15
 #
15
 #

+ 2 - 2
test/controllers/activities_controller_test.rb

17
 
17
 
18
   test "should create activity" do
18
   test "should create activity" do
19
     assert_difference('Activity.count') do
19
     assert_difference('Activity.count') do
20
-      post activities_url, params: { activity: { } }
20
+      post activities_url, params: { activity: {} }
21
     end
21
     end
22
 
22
 
23
     assert_redirected_to activity_url(Activity.last)
23
     assert_redirected_to activity_url(Activity.last)
34
   end
34
   end
35
 
35
 
36
   test "should update activity" do
36
   test "should update activity" do
37
-    patch activity_url(@activity), params: { activity: { } }
37
+    patch activity_url(@activity), params: { activity: {} }
38
     assert_redirected_to activity_url(@activity)
38
     assert_redirected_to activity_url(@activity)
39
   end
39
   end
40
 
40
 

+ 2 - 2
test/controllers/api/activities_controller_test.rb

17
 
17
 
18
   test "should create api_activity" do
18
   test "should create api_activity" do
19
     assert_difference('Api::Activity.count') do
19
     assert_difference('Api::Activity.count') do
20
-      post api_activities_url, params: { api_activity: { } }
20
+      post api_activities_url, params: { api_activity: {} }
21
     end
21
     end
22
 
22
 
23
     assert_redirected_to api_activity_url(Api::Activity.last)
23
     assert_redirected_to api_activity_url(Api::Activity.last)
34
   end
34
   end
35
 
35
 
36
   test "should update api_activity" do
36
   test "should update api_activity" do
37
-    patch api_activity_url(@api_activity), params: { api_activity: { } }
37
+    patch api_activity_url(@api_activity), params: { api_activity: {} }
38
     assert_redirected_to api_activity_url(@api_activity)
38
     assert_redirected_to api_activity_url(@api_activity)
39
   end
39
   end
40
 
40
 

+ 2 - 2
test/controllers/api/groups_controller_test.rb

17
 
17
 
18
   test "should create api_group" do
18
   test "should create api_group" do
19
     assert_difference('Api::Group.count') do
19
     assert_difference('Api::Group.count') do
20
-      post api_groups_url, params: { api_group: { } }
20
+      post api_groups_url, params: { api_group: {} }
21
     end
21
     end
22
 
22
 
23
     assert_redirected_to api_group_url(Api::Group.last)
23
     assert_redirected_to api_group_url(Api::Group.last)
34
   end
34
   end
35
 
35
 
36
   test "should update api_group" do
36
   test "should update api_group" do
37
-    patch api_group_url(@api_group), params: { api_group: { } }
37
+    patch api_group_url(@api_group), params: { api_group: {} }
38
     assert_redirected_to api_group_url(@api_group)
38
     assert_redirected_to api_group_url(@api_group)
39
   end
39
   end
40
 
40
 

+ 2 - 2
test/controllers/api/people_controller_test.rb

17
 
17
 
18
   test "should create api_person" do
18
   test "should create api_person" do
19
     assert_difference('Api::Person.count') do
19
     assert_difference('Api::Person.count') do
20
-      post api_people_url, params: { api_person: { } }
20
+      post api_people_url, params: { api_person: {} }
21
     end
21
     end
22
 
22
 
23
     assert_redirected_to api_person_url(Api::Person.last)
23
     assert_redirected_to api_person_url(Api::Person.last)
34
   end
34
   end
35
 
35
 
36
   test "should update api_person" do
36
   test "should update api_person" do
37
-    patch api_person_url(@api_person), params: { api_person: { } }
37
+    patch api_person_url(@api_person), params: { api_person: {} }
38
     assert_redirected_to api_person_url(@api_person)
38
     assert_redirected_to api_person_url(@api_person)
39
   end
39
   end
40
 
40
 

+ 2 - 2
test/controllers/groups_controller_test.rb

17
 
17
 
18
   test "should create group" do
18
   test "should create group" do
19
     assert_difference('Group.count') do
19
     assert_difference('Group.count') do
20
-      post groups_url, params: { group: { } }
20
+      post groups_url, params: { group: {} }
21
     end
21
     end
22
 
22
 
23
     assert_redirected_to group_url(Group.last)
23
     assert_redirected_to group_url(Group.last)
34
   end
34
   end
35
 
35
 
36
   test "should update group" do
36
   test "should update group" do
37
-    patch group_url(@group), params: { group: { } }
37
+    patch group_url(@group), params: { group: {} }
38
     assert_redirected_to group_url(@group)
38
     assert_redirected_to group_url(@group)
39
   end
39
   end
40
 
40
 

+ 2 - 2
test/controllers/members_controller_test.rb

17
 
17
 
18
   test "should create member" do
18
   test "should create member" do
19
     assert_difference('Member.count') do
19
     assert_difference('Member.count') do
20
-      post members_url, params: { member: { } }
20
+      post members_url, params: { member: {} }
21
     end
21
     end
22
 
22
 
23
     assert_redirected_to member_url(Member.last)
23
     assert_redirected_to member_url(Member.last)
34
   end
34
   end
35
 
35
 
36
   test "should update member" do
36
   test "should update member" do
37
-    patch member_url(@member), params: { member: { } }
37
+    patch member_url(@member), params: { member: {} }
38
     assert_redirected_to member_url(@member)
38
     assert_redirected_to member_url(@member)
39
   end
39
   end
40
 
40
 

+ 2 - 2
test/controllers/people_controller_test.rb

17
 
17
 
18
   test "should create person" do
18
   test "should create person" do
19
     assert_difference('Person.count') do
19
     assert_difference('Person.count') do
20
-      post people_url, params: { person: { } }
20
+      post people_url, params: { person: {} }
21
     end
21
     end
22
 
22
 
23
     assert_redirected_to person_url(Person.last)
23
     assert_redirected_to person_url(Person.last)
34
   end
34
   end
35
 
35
 
36
   test "should update person" do
36
   test "should update person" do
37
-    patch person_url(@person), params: { person: { } }
37
+    patch person_url(@person), params: { person: {} }
38
     assert_redirected_to person_url(@person)
38
     assert_redirected_to person_url(@person)
39
   end
39
   end
40
 
40