your_platform 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/app/helpers/corporate_vita_helper.rb +4 -4
- data/app/models/concerns/user_corporations.rb +1 -1
- data/app/models/flagable.rb +2 -6
- data/app/models/group_mixins/memberships.rb +12 -12
- data/app/models/profile_field_types/address.rb +1 -1
- data/app/models/profileable.rb +1 -1
- data/app/models/user_mixins/identification.rb +12 -10
- data/app/models/user_mixins/memberships.rb +14 -14
- data/app/views/events/_event_details.html.haml +5 -5
- data/app/views/groups/show.html.haml +1 -1
- data/app/views/pages/_page.html.haml +2 -2
- data/app/views/profile_fields/_profile_field.html.haml +4 -4
- data/lib/your_platform/version.rb +1 -1
- data/spec/factories/mail_message.rb +2 -2
- data/spec/factories/user.rb +1 -1
- data/spec/factories/workflow.rb +1 -1
- data/spec/models/geo_location_spec.rb +1 -1
- metadata +3 -7
- data/app/models/active_record_find_by_extension.rb +0 -20
- data/config/initializers/active_record_find_by_extension.rb +0 -1
- data/spec/models/active_record_find_by_extension_spec.rb +0 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 885faa86efc2aa424a99b5e5347a5776a5f487fc
|
4
|
+
data.tar.gz: 1e268cea5b6b923ccdcdae9ca7f21e4b45e92fd8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8cfe1bc0d55464b938e545a4dafe305596a20776c4fc6722302f75f1e213b5563a7b8141fe323ac08cce7ecfd366629beb2edd9e213a275787f98141b6487395
|
7
|
+
data.tar.gz: 2db144d068a210992ea8469ee65e253a943f05c4f9553b7cd260fe19d4e70a000e65d3cca0191507f901fc0d3aa8e2ea5fb8b34d05b26243278ff9896cc7224f
|
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# YourPlatform
|
2
2
|
|
3
3
|
[![Join the chat at https://gitter.im/fiedl/your_platform](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/fiedl/your_platform?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/your_platform.svg)](http://badge.fury.io/rb/your_platform)
|
4
5
|
[![Build Status](https://travis-ci.org/fiedl/your_platform.svg?branch=master)](https://travis-ci.org/fiedl/your_platform)
|
5
6
|
[![Code Climate](https://codeclimate.com/github/fiedl/your_platform/badges/gpa.svg)](https://codeclimate.com/github/fiedl/your_platform)
|
6
7
|
[![Dependency Status](https://gemnasium.com/fiedl/your_platform.svg)](https://gemnasium.com/fiedl/your_platform)
|
@@ -8,12 +8,12 @@ module CorporateVitaHelper
|
|
8
8
|
def status_group_membership_valid_from_best_in_place( membership )
|
9
9
|
best_in_place( membership,
|
10
10
|
:valid_from_localized_date, # type: :date,
|
11
|
-
|
11
|
+
url: user_group_membership_path( id: membership.id,
|
12
12
|
controller: :user_group_memberships,
|
13
13
|
action: :update,
|
14
14
|
format: :json
|
15
15
|
),
|
16
|
-
:
|
16
|
+
:class => "status_group_date_of_joining"
|
17
17
|
)
|
18
18
|
end
|
19
19
|
|
@@ -21,8 +21,8 @@ module CorporateVitaHelper
|
|
21
21
|
event = membership.event
|
22
22
|
best_in_place( membership,
|
23
23
|
:event_by_name,
|
24
|
-
|
25
|
-
|
24
|
+
url: status_group_membership_path(membership),
|
25
|
+
class: 'status_event_by_name',
|
26
26
|
# display_with does more harm than it's good for. We wait for angular!
|
27
27
|
# display_with: lambda do |v|
|
28
28
|
# link_to membership.event.name, membership.event, :class => 'status_event_label'
|
@@ -38,7 +38,7 @@ module UserCorporations
|
|
38
38
|
# The user is added as member to this corporation.
|
39
39
|
#
|
40
40
|
def corporation_name=(new_corporation_name)
|
41
|
-
Corporation.
|
41
|
+
Corporation.find_or_create_by(name: new_corporation_name).assign_user self
|
42
42
|
end
|
43
43
|
|
44
44
|
end
|
data/app/models/flagable.rb
CHANGED
@@ -33,12 +33,8 @@ module Flagable
|
|
33
33
|
self.add_flags new_flag
|
34
34
|
end
|
35
35
|
|
36
|
-
def remove_flags(
|
37
|
-
|
38
|
-
self.flags.find_all_by_key( flag_to_remove ).each do |flag|
|
39
|
-
flag.destroy
|
40
|
-
end
|
41
|
-
end
|
36
|
+
def remove_flags(*flags_to_remove)
|
37
|
+
self.flags.where(key: flags_to_remove).destroy_all
|
42
38
|
end
|
43
39
|
|
44
40
|
def remove_flag( flag_to_remove )
|
@@ -6,9 +6,6 @@ module GroupMixins::Memberships
|
|
6
6
|
|
7
7
|
extend ActiveSupport::Concern
|
8
8
|
|
9
|
-
# TODO: Refactor conditions to rails 4 standard when migrating to rails 4.
|
10
|
-
# See, for example, https://github.com/fiedl/neo4j_ancestry/blob/master/lib/models/neo4j_ancestry/active_record_additions.rb#L117.
|
11
|
-
|
12
9
|
included do
|
13
10
|
|
14
11
|
# User Group Memberships
|
@@ -18,23 +15,26 @@ module GroupMixins::Memberships
|
|
18
15
|
# memberships.
|
19
16
|
#
|
20
17
|
has_many( :memberships,
|
18
|
+
-> { where ancestor_type: 'Group', descendant_type: 'User' },
|
21
19
|
class_name: 'UserGroupMembership',
|
22
|
-
foreign_key: :ancestor_id
|
20
|
+
foreign_key: :ancestor_id )
|
23
21
|
|
24
22
|
# This associates all memberships of the group that are direct, i.e. direct
|
25
23
|
# parent_group-child_user memberships.
|
26
24
|
#
|
27
25
|
has_many( :direct_memberships,
|
26
|
+
-> { where ancestor_type: 'Group', descendant_type: 'User', direct: true },
|
28
27
|
class_name: 'UserGroupMembership',
|
29
|
-
foreign_key: :ancestor_id
|
28
|
+
foreign_key: :ancestor_id )
|
30
29
|
|
31
30
|
# This associates all memberships of the group that are indirect, i.e.
|
32
31
|
# ancestor_group-descendant_user memberships, where groups are between the
|
33
32
|
# ancestor_group and the descendant_user.
|
34
33
|
#
|
35
34
|
has_many( :indirect_memberships,
|
35
|
+
-> { where ancestor_type: 'Group', descendant_type: 'User', direct: false },
|
36
36
|
class_name: 'UserGroupMembership',
|
37
|
-
foreign_key: :ancestor_id
|
37
|
+
foreign_key: :ancestor_id )
|
38
38
|
|
39
39
|
|
40
40
|
# This method builds a new membership having this group (self) as group associated.
|
@@ -182,25 +182,25 @@ module GroupMixins::Memberships
|
|
182
182
|
# when generating the SQL query. This is why the conditions have to be repeated here.
|
183
183
|
#
|
184
184
|
has_many(:members,
|
185
|
+
-> { where('dag_links.ancestor_type' => 'Group').uniq },
|
185
186
|
through: :memberships,
|
186
|
-
source: :descendant, source_type: 'User'
|
187
|
-
conditions: { 'dag_links.ancestor_type' => 'Group' }
|
187
|
+
source: :descendant, source_type: 'User'
|
188
188
|
)
|
189
189
|
|
190
190
|
# This associates only the direct group members (users).
|
191
191
|
#
|
192
192
|
has_many(:direct_members,
|
193
|
+
-> { where('dag_links.ancestor_type' => 'Group', 'dag_links.direct' => true).uniq },
|
193
194
|
through: :direct_memberships,
|
194
|
-
source: :descendant, source_type: 'User'
|
195
|
-
conditions: { 'dag_links.ancestor_type' => 'Group', 'dag_links.direct' => true }
|
195
|
+
source: :descendant, source_type: 'User'
|
196
196
|
)
|
197
197
|
|
198
198
|
# This associates only the indirect group members (users).
|
199
199
|
#
|
200
200
|
has_many(:indirect_members,
|
201
|
+
-> { where('dag_links.ancestor_type' => 'Group', 'dag_links.direct' => false).uniq },
|
201
202
|
through: :indirect_memberships,
|
202
|
-
source: :descendant, source_type: 'User'
|
203
|
-
conditions: { 'dag_links.ancestor_type' => 'Group', 'dag_links.direct' => false }
|
203
|
+
source: :descendant, source_type: 'User'
|
204
204
|
)
|
205
205
|
|
206
206
|
end
|
@@ -20,7 +20,7 @@ module ProfileFieldTypes
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def find_or_create_geo_location
|
23
|
-
@geo_location ||= GeoLocation.
|
23
|
+
@geo_location ||= GeoLocation.find_or_create_by address: value if self.value && self.value != "—"
|
24
24
|
end
|
25
25
|
|
26
26
|
def display_html
|
data/app/models/profileable.rb
CHANGED
@@ -13,7 +13,7 @@ module Profileable
|
|
13
13
|
def is_profileable( options = {} )
|
14
14
|
@profile_section_titles = options[:profile_sections] || default_profile_section_titles
|
15
15
|
has_many :profile_fields, as: :profileable, dependent: :destroy, autosave: true
|
16
|
-
has_many :address_profile_fields,
|
16
|
+
has_many :address_profile_fields, -> { where type: 'ProfileFieldTypes::Address' }, class_name: 'ProfileFieldTypes::Address', as: :profileable, dependent: :destroy, autosave: true
|
17
17
|
|
18
18
|
include InstanceMethodsForProfileables
|
19
19
|
end
|
@@ -1,16 +1,15 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
1
|
# This module extends the User class. Its purpose is to provide methods to identify a user using
|
4
|
-
# a given login string. The user may identify himself using his
|
5
|
-
#
|
2
|
+
# a given login string. The user may identify himself using his:
|
3
|
+
#
|
4
|
+
# * first name plus last name
|
5
|
+
# * last name only
|
6
|
+
# * email address
|
7
|
+
# * alias
|
6
8
|
#
|
7
9
|
module UserMixins::Identification
|
8
10
|
|
9
11
|
extend ActiveSupport::Concern
|
10
12
|
|
11
|
-
included do
|
12
|
-
end
|
13
|
-
|
14
13
|
module ClassMethods
|
15
14
|
|
16
15
|
# The user may identify himself using one of these attributes.
|
@@ -27,9 +26,12 @@ module UserMixins::Identification
|
|
27
26
|
# returns a user object if the match was unique.
|
28
27
|
#
|
29
28
|
def find_all_by_identification_string( identification_string )
|
30
|
-
|
31
|
-
|
32
|
-
|
29
|
+
(
|
30
|
+
User.where(alias: identification_string) +
|
31
|
+
User.where(last_name: identification_string) +
|
32
|
+
User.find_all_by_name(identification_string) +
|
33
|
+
User.find_all_by_email(identification_string)
|
34
|
+
).uniq
|
33
35
|
end
|
34
36
|
|
35
37
|
end
|
@@ -6,9 +6,6 @@ module UserMixins::Memberships
|
|
6
6
|
|
7
7
|
extend ActiveSupport::Concern
|
8
8
|
|
9
|
-
# TODO: Refactor conditions to rails 4 standard when migrating to rails 4.
|
10
|
-
# See, for example, https://github.com/fiedl/neo4j_ancestry/blob/master/lib/models/neo4j_ancestry/active_record_additions.rb#L117.
|
11
|
-
|
12
9
|
included do
|
13
10
|
|
14
11
|
# User Group Memberships
|
@@ -17,24 +14,27 @@ module UserMixins::Memberships
|
|
17
14
|
# This associates all UserGroupMembership objects of the group, including indirect
|
18
15
|
# memberships.
|
19
16
|
#
|
20
|
-
has_many( :memberships,
|
17
|
+
has_many( :memberships,
|
18
|
+
-> { where ancestor_type: 'Group', descendant_type: 'User' },
|
21
19
|
class_name: 'UserGroupMembership',
|
22
|
-
foreign_key: :descendant_id
|
20
|
+
foreign_key: :descendant_id )
|
23
21
|
|
24
22
|
# This associates all memberships of the group that are direct, i.e. direct
|
25
23
|
# parent_group-child_user memberships.
|
26
24
|
#
|
27
25
|
has_many( :direct_memberships,
|
26
|
+
-> { where ancestor_type: 'Group', descendant_type: 'User', direct: true },
|
28
27
|
class_name: 'UserGroupMembership',
|
29
|
-
foreign_key: :descendant_id
|
28
|
+
foreign_key: :descendant_id )
|
30
29
|
|
31
30
|
# This associates all memberships of the group that are indirect, i.e.
|
32
31
|
# ancestor_group-descendant_user memberships, where groups are between the
|
33
32
|
# ancestor_group and the descendant_user.
|
34
33
|
#
|
35
34
|
has_many( :indirect_memberships,
|
35
|
+
-> { where ancestor_type: 'Group', descendant_type: 'User', direct: false },
|
36
36
|
class_name: 'UserGroupMembership',
|
37
|
-
foreign_key: :descendant_id
|
37
|
+
foreign_key: :descendant_id )
|
38
38
|
|
39
39
|
|
40
40
|
# This returns the membership of the user in the given group if existant.
|
@@ -49,26 +49,26 @@ module UserMixins::Memberships
|
|
49
49
|
|
50
50
|
# This associates the groups the user is member of, direct as well as indirect.
|
51
51
|
#
|
52
|
-
has_many(:groups,
|
52
|
+
has_many(:groups,
|
53
|
+
-> { where('dag_links.descendant_type' => 'User').uniq },
|
53
54
|
through: :memberships,
|
54
|
-
source: :ancestor, source_type: 'Group'
|
55
|
-
conditions: { 'dag_links.descendant_type' => 'User' }
|
55
|
+
source: :ancestor, source_type: 'Group'
|
56
56
|
)
|
57
57
|
|
58
58
|
# This associates only the direct groups.
|
59
59
|
#
|
60
60
|
has_many(:direct_groups,
|
61
|
+
-> { where('dag_links.descendant_type' => 'User', 'dag_links.direct' => true).uniq },
|
61
62
|
through: :direct_memberships,
|
62
|
-
source: :ancestor, source_type: 'Group'
|
63
|
-
conditions: { 'dag_links.descendant_type' => 'User', 'dag_links.direct' => true }
|
63
|
+
source: :ancestor, source_type: 'Group'
|
64
64
|
)
|
65
65
|
|
66
66
|
# This associates only the indirect groups.
|
67
67
|
#
|
68
68
|
has_many(:indirect_groups,
|
69
|
+
-> { where('dag_links.descendant_type' => 'User', 'dag_links.direct' => false).uniq },
|
69
70
|
through: :indirect_memberships,
|
70
|
-
source: :ancestor, source_type: 'Group'
|
71
|
-
conditions: { 'dag_links.descendant_type' => 'User', 'dag_links.direct' => false }
|
71
|
+
source: :ancestor, source_type: 'Group'
|
72
72
|
)
|
73
73
|
|
74
74
|
end
|
@@ -1,17 +1,17 @@
|
|
1
1
|
%table.event_details
|
2
2
|
%tr.description
|
3
3
|
%th=t :description
|
4
|
-
%td= best_in_place_if can?(:update, @event), @event, :description, placeholder: I18n.t(:description),
|
4
|
+
%td= best_in_place_if can?(:update, @event), @event, :description, placeholder: I18n.t(:description), as: :textarea
|
5
5
|
%tr.start_at
|
6
6
|
%th=t :start_at
|
7
|
-
%td= best_in_place_if can?(:update, @event), @event, :localized_start_at,
|
7
|
+
%td= best_in_place_if can?(:update, @event), @event, :localized_start_at, as: :datetime
|
8
8
|
%tr.end_at
|
9
9
|
%th
|
10
10
|
=t :end_at
|
11
11
|
- if can? :update, @event
|
12
12
|
= surround '(', ')' do
|
13
13
|
=t :optional
|
14
|
-
%td= best_in_place_if can?(:update, @event), @event, :localized_end_at,
|
14
|
+
%td= best_in_place_if can?(:update, @event), @event, :localized_end_at, as: :datetime
|
15
15
|
%tr.location
|
16
16
|
%th=t :location
|
17
17
|
%td= best_in_place_if can?(:update, @event), @event, :location
|
@@ -35,7 +35,7 @@
|
|
35
35
|
%tr.publish_on_local_website
|
36
36
|
%th
|
37
37
|
%td
|
38
|
-
= best_in_place @event, :publish_on_local_website,
|
38
|
+
= best_in_place @event, :publish_on_local_website, class: "show_always", as: :select, collection: [['false', "Nicht auf lokaler Homepage veröffentlichen"], ['true', "Auf lokaler Homepage veröffentlichen"]]
|
39
39
|
–
|
40
40
|
= link_to group_events_public_url(group_id: @event.group) do
|
41
41
|
= icon 'list-alt'
|
@@ -45,7 +45,7 @@
|
|
45
45
|
%tr.publish_on_global_website
|
46
46
|
%th
|
47
47
|
%td
|
48
|
-
= best_in_place @event, :publish_on_global_website,
|
48
|
+
= best_in_place @event, :publish_on_global_website, class: "show_always", as: :select, collection: [['false', "Nicht auf öffentlicher Homepage veröffentlichen (#{Page.find_root.title})"], ['true', "Auf öffentlicher Homepage veröffentlichen (#{Page.find_root.title})"]]
|
49
49
|
–
|
50
50
|
= link_to public_events_url do
|
51
51
|
= icon 'list-alt'
|
@@ -1,7 +1,7 @@
|
|
1
1
|
- set_title @group.title
|
2
2
|
%h1= best_in_place_if can?(:rename, @group), @group, :name
|
3
3
|
%div
|
4
|
-
= best_in_place_if can?(:update, @group), @group, :body,
|
4
|
+
= best_in_place_if can?(:update, @group), @group, :body, as: :textarea
|
5
5
|
.show_only_in_edit_mode
|
6
6
|
= render partial: 'shared/markdown_help'
|
7
7
|
|
@@ -3,7 +3,7 @@
|
|
3
3
|
= best_in_place_if can?(:update, page), page, :title
|
4
4
|
- else # Blog Entries:
|
5
5
|
= link_to(page) do
|
6
|
-
= best_in_place_if can?(:update, page), page, :title,
|
6
|
+
= best_in_place_if can?(:update, page), page, :title, class: 'click_does_not_trigger_edit', activator: 'only_manual'
|
7
7
|
%div.page
|
8
8
|
%div.page_header
|
9
9
|
- if page.author
|
@@ -18,7 +18,7 @@
|
|
18
18
|
= localize(page.updated_at)
|
19
19
|
%div.page_body
|
20
20
|
%div{ id: 'page_content', data: { mercury: 'full' } }
|
21
|
-
= best_in_place_if can?(:update, page), page, :content,
|
21
|
+
= best_in_place_if can?(:update, page), page, :content, as: :textarea, sanitize: false
|
22
22
|
.show_only_in_edit_mode
|
23
23
|
= render partial: 'shared/markdown_help'
|
24
24
|
|
@@ -4,8 +4,8 @@
|
|
4
4
|
-#
|
5
5
|
- profile_field_css_class = profile_field.parent ? 'attribute profile_field profile_field_child' : 'attribute profile_field profile_field_parent'
|
6
6
|
- profile_field_css_class += " #{profile_field.key}" if profile_field.parent_id
|
7
|
-
- input_type =
|
8
|
-
- input_type =
|
7
|
+
- input_type = :input
|
8
|
+
- input_type = :textarea if %w(ProfileFieldTypes::Address ProfileFieldTypes::Description ProfileFieldTypes::About).include? profile_field.type
|
9
9
|
-# # For the moment, no 'date' type. The date selector does not work properly with edit_mode.
|
10
10
|
-# input_type = 'date' if profile_field.type == "ProfileFieldTypes::Date"
|
11
11
|
- no_remove ||= false
|
@@ -25,12 +25,12 @@
|
|
25
25
|
- if profile_field.parent || lock_label || cannot?(:update, profile_field)
|
26
26
|
%span.label.profile_field_label= profile_field.label
|
27
27
|
- else
|
28
|
-
= best_in_place profile_field, :label,
|
28
|
+
= best_in_place profile_field, :label, class: 'profile_field_label label', html_attrs: { placeholder: I18n.t(profile_field.underscored_type) }
|
29
29
|
|
30
30
|
- # value
|
31
31
|
%span.value-wrapper
|
32
32
|
- if profile_field.children_count == 0
|
33
|
-
= best_in_place_if can?(:update, profile_field), profile_field, :value, {
|
33
|
+
= best_in_place_if can?(:update, profile_field), profile_field, :value, {as: input_type, class: 'value'}
|
34
34
|
|
35
35
|
- if profile_field.children_count > 0
|
36
36
|
%ul
|
@@ -6,7 +6,7 @@ FactoryGirl.define do
|
|
6
6
|
#
|
7
7
|
factory :mail_message_to_group, :class => Mail do
|
8
8
|
|
9
|
-
|
9
|
+
transient do
|
10
10
|
message "Date: Fri, 29 Mar 2013 23:55:00 +0100\n" +
|
11
11
|
"From: foo@exampe.org\n" +
|
12
12
|
"Subject: Testing Group Email Lists\n" +
|
@@ -19,7 +19,7 @@ FactoryGirl.define do
|
|
19
19
|
|
20
20
|
factory :html_mail_message, :class => Mail do
|
21
21
|
|
22
|
-
|
22
|
+
transient do
|
23
23
|
email_file_name = File.join(File.dirname(__FILE__), './html_email.eml')
|
24
24
|
message File.open(email_file_name, "r").read
|
25
25
|
end
|
data/spec/factories/user.rb
CHANGED
data/spec/factories/workflow.rb
CHANGED
@@ -73,7 +73,7 @@ describe GeoLocation do
|
|
73
73
|
# ==========================================================================================
|
74
74
|
|
75
75
|
describe ".find_or_create_by_address" do
|
76
|
-
subject { GeoLocation.
|
76
|
+
subject { GeoLocation.find_or_create_by address: @address_string }
|
77
77
|
describe "for an existing record" do
|
78
78
|
before { @geo_location = GeoLocation.create( address: @address_string ) }
|
79
79
|
it "should find the existing one" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: your_platform
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sebastian Fiedlschuster
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -911,7 +911,6 @@ files:
|
|
911
911
|
- app/models/ability.rb
|
912
912
|
- app/models/active_record_associations_patches.rb
|
913
913
|
- app/models/active_record_cache_extension.rb
|
914
|
-
- app/models/active_record_find_by_extension.rb
|
915
914
|
- app/models/active_record_json_url_extension.rb
|
916
915
|
- app/models/active_record_metric_events_extension.rb
|
917
916
|
- app/models/active_record_read_only_extension.rb
|
@@ -1123,7 +1122,6 @@ files:
|
|
1123
1122
|
- app/views/users/show.html.haml
|
1124
1123
|
- config/environment.rb
|
1125
1124
|
- config/initializers/active_record_cache_extension.rb
|
1126
|
-
- config/initializers/active_record_find_by_extension.rb
|
1127
1125
|
- config/initializers/active_record_flagable_extension.rb
|
1128
1126
|
- config/initializers/active_record_json_url_extension.rb
|
1129
1127
|
- config/initializers/active_record_may_need_review_extension.rb
|
@@ -1305,7 +1303,6 @@ files:
|
|
1305
1303
|
- spec/helpers/attachments_helper_spec.rb
|
1306
1304
|
- spec/models/ability_spec.rb
|
1307
1305
|
- spec/models/active_record_cache_extension_spec.rb
|
1308
|
-
- spec/models/active_record_find_by_extension_spec.rb
|
1309
1306
|
- spec/models/active_record_json_url_extension_spec.rb
|
1310
1307
|
- spec/models/address_label_spec.rb
|
1311
1308
|
- spec/models/app_version_spec.rb
|
@@ -1450,7 +1447,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
1450
1447
|
version: '0'
|
1451
1448
|
requirements: []
|
1452
1449
|
rubyforge_project:
|
1453
|
-
rubygems_version: 2.
|
1450
|
+
rubygems_version: 2.4.5
|
1454
1451
|
signing_key:
|
1455
1452
|
specification_version: 4
|
1456
1453
|
summary: Administrative and social network platform for closed user groups.
|
@@ -1497,7 +1494,6 @@ test_files:
|
|
1497
1494
|
- spec/helpers/attachments_helper_spec.rb
|
1498
1495
|
- spec/models/ability_spec.rb
|
1499
1496
|
- spec/models/active_record_cache_extension_spec.rb
|
1500
|
-
- spec/models/active_record_find_by_extension_spec.rb
|
1501
1497
|
- spec/models/active_record_json_url_extension_spec.rb
|
1502
1498
|
- spec/models/address_label_spec.rb
|
1503
1499
|
- spec/models/app_version_spec.rb
|
@@ -1,20 +0,0 @@
|
|
1
|
-
module ActiveRecordFindByExtension
|
2
|
-
extend ActiveSupport::Concern
|
3
|
-
|
4
|
-
module ClassMethods
|
5
|
-
|
6
|
-
# A Rails 4 alias for `where`.
|
7
|
-
# See: https://github.com/rails/rails/blob/master/activerecord/lib/active_record/relation/finder_methods.rb
|
8
|
-
#
|
9
|
-
# It will return the first matching object and return the object, not an ActiveRecord::Relation.
|
10
|
-
# If an ActiveRecord::Relation, which is chainable, is needed, use where().
|
11
|
-
#
|
12
|
-
def find_by( args )
|
13
|
-
where( args ).limit( 1 ).first
|
14
|
-
end
|
15
|
-
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
19
|
-
|
20
|
-
ActiveRecord::Base.send( :include, ActiveRecordFindByExtension ) if Rails.version < "4.0"
|
@@ -1 +0,0 @@
|
|
1
|
-
require 'active_record_find_by_extension'
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe ActiveRecordFindByExtension do
|
4
|
-
|
5
|
-
# The extension described here applies to all ActiveRecord::Base models.
|
6
|
-
# Therefore, we pick the user model, here.
|
7
|
-
|
8
|
-
before do
|
9
|
-
@user = create( :user )
|
10
|
-
@other_user = create( :user )
|
11
|
-
end
|
12
|
-
|
13
|
-
describe ".find_by" do
|
14
|
-
subject { User.find_by( first_name: @user.first_name, last_name: @user.last_name ) }
|
15
|
-
it "should return an object" do
|
16
|
-
subject.should be_kind_of User
|
17
|
-
end
|
18
|
-
it "should not return an ActiveRecord::Relation" do
|
19
|
-
subject.should_not be_kind_of ActiveRecord::Relation
|
20
|
-
end
|
21
|
-
it "should find the correct object" do
|
22
|
-
subject.should == @user
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|