tb_core 1.4.beta2 → 1.4.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d3e651f6ff813c429d0d61895739a668b1962417
4
- data.tar.gz: 9d4675ce88f2341883c9e07634f8896ff0b871e0
3
+ metadata.gz: 94d2db866f51de6c90377e7b45b255deb84e1c2e
4
+ data.tar.gz: 281c43074a1a1de7098a84e5bbd3ba5cc71239e6
5
5
  SHA512:
6
- metadata.gz: 7fbe679221366bfeb8aa9050fc32ff06922ee0e394c1c0be637bd9da5cf424d7ea8947e1ba2b075b1c61b3931249f18fad04a60056e435565fe712f9e5a80a3e
7
- data.tar.gz: 20240e4966b8ac2446d36629b60a8b01b641493d01bec75b81c5699bae3332c10ea2acce680392049ee19bfb22be712f0d440add299517f9b779b2eb9a277753
6
+ metadata.gz: ae37cc5ceeefdd1a0001af643b2059e56cb3b82dbd968ab5708c3990fbc57b0fbbae0a088d537fea50fd9fd413f4b0622ac8d3430023a824e5532543b40acd10
7
+ data.tar.gz: e863b1df22a455f397d6d586c86b7a6dddbe1149a2b1db802cc52c9849f27273373cb4ae06fc9c0b754262448d7e001bc079b7a5b2b1f45f05abfa4c2f446618
@@ -95,20 +95,24 @@ class Spud::SpudUserModel < ActiveRecord::Base
95
95
 
96
96
  # Returns an ActiveRecord::Relation performing a LIKE query against name columns
97
97
  def self.where_name_like(string)
98
- like = '%' + string + '%'
99
- return self.where('login like ? or concat(`first_name`, " ", `last_name`) like ?', like, like)
98
+ full_name = Arel::Nodes::NamedFunction.new(
99
+ 'concat',
100
+ [arel_table[:first_name], Arel::Nodes.build_quoted(' '), arel_table[:last_name]]
101
+ )
102
+ search = '%' + string + '%'
103
+ where(full_name.matches(search))
100
104
  end
101
105
 
102
106
  # Return an array of users who have the requested permission
103
107
  #
104
108
  # * tag - Desired permission tag string (required)
105
109
  # * include_supers - Whether to include super user (default: true)
106
- def self.with_permission(tag, include_supers:true)
110
+ def self.with_permission(tag, include_supers: true)
107
111
  role_ids = SpudRolePermission.where(spud_permission_tag: tag).pluck(:spud_role_id).uniq()
108
112
  if include_supers
109
- return SpudUser.where('super_admin = 1 OR spud_role_id IN (?)', role_ids)
113
+ where(super_admin: true).or(where(spud_role_id: role_ids))
110
114
  else
111
- return SpudUser.where(spud_role_id: role_ids)
115
+ where(spud_role_id: role_ids)
112
116
  end
113
117
  end
114
118
 
@@ -15,7 +15,7 @@
15
15
  <th>&nbsp;</th>
16
16
  </thead>
17
17
  <tbody>
18
- <% cache [:admin, @spud_users] do %>
18
+ <% cache @spud_users.to_a do %>
19
19
  <% @spud_users.each do |spud_user| %>
20
20
  <tr>
21
21
  <td><%= spud_user.full_name %></td>
@@ -1,6 +1,6 @@
1
1
  <h1>Hello <%= @user.full_name %>,</h1>
2
2
 
3
- <p>A password reset has recently been requested for your user account on <strong><%= Spud::Core.config.site_name %></strong>. Please the link below to set your new password.</p>
3
+ <p>A password reset has recently been requested for your user account on <strong><%= Spud::Core.config.site_name %></strong>. Click the link below to set your new password.</p>
4
4
 
5
5
  <p><%= link_to @url, @url %></p>
6
6
 
@@ -1,5 +1,5 @@
1
1
  module Spud
2
2
  module Core
3
- VERSION = '1.4.beta2'
3
+ VERSION = '1.4.0.1'
4
4
  end
5
5
  end
@@ -2,7 +2,40 @@ require 'rails_helper'
2
2
 
3
3
  describe SpudUser, type: :model do
4
4
 
5
- describe '.full_name' do
5
+ describe '.where_name_like' do
6
+ it 'matches on the concatenated first and last name' do
7
+ 2.times { FactoryGirl.create(:spud_user) }
8
+ user = FactoryGirl.create(:spud_user, first_name: 'Some', last_name: 'User')
9
+ result = SpudUser.where_name_like('Some User')
10
+ expect(result.length).to eq(1)
11
+ expect(result.first).to eq(user)
12
+ end
13
+ end
14
+
15
+ describe '.with_permission' do
16
+ before :each do
17
+ role = FactoryGirl.create(:spud_role,
18
+ permission_tags: ['hello']
19
+ )
20
+ @super_user = FactoryGirl.create(:spud_user, super_admin: true)
21
+ @admin_user = FactoryGirl.create(:spud_user, super_admin: false, role: role)
22
+ @normal_user = FactoryGirl.create(:spud_user, super_admin: false)
23
+ end
24
+
25
+ it 'should include the admin user' do
26
+ result = SpudUser.with_permission('hello', include_supers: false)
27
+ expect(result.length).to eq(1)
28
+ expect(result.first).to eq(@admin_user)
29
+ end
30
+
31
+ it 'should include the admin and the super user' do
32
+ result = SpudUser.with_permission('hello')
33
+ expect(result.length).to eq(2)
34
+ expect(result).to_not include(@normal_user)
35
+ end
36
+ end
37
+
38
+ describe '#full_name' do
6
39
  it 'should return the full name if the first and last name are not blank' do
7
40
  u = FactoryGirl.build(:spud_user)
8
41
  expect(u.full_name).to eq("#{u.first_name} #{u.last_name}")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tb_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.beta2
4
+ version: 1.4.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greg Woods
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-16 00:00:00.000000000 Z
11
+ date: 2016-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -485,9 +485,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
485
485
  version: '2.1'
486
486
  required_rubygems_version: !ruby/object:Gem::Requirement
487
487
  requirements:
488
- - - ">"
488
+ - - ">="
489
489
  - !ruby/object:Gem::Version
490
- version: 1.3.1
490
+ version: '0'
491
491
  requirements: []
492
492
  rubyforge_project:
493
493
  rubygems_version: 2.5.1