Merge pull request #295 from opf/feature/rails3_improve_member_search_additions

Feature/rails3 improve member search additions
pull/290/head
sschu 11 years ago
commit c34f979132
  1. 14
      app/models/principal.rb
  2. 33
      features/members/membership.feature

@ -26,17 +26,25 @@ class Principal < ActiveRecord::Base
scope :not_in_project, lambda { |project| {:conditions => "id NOT IN (select m.user_id FROM members as m where m.project_id = #{project.id})"}}
scope :like, lambda {|q|
scope :like, lambda { |q|
firstnamelastname = "((firstname || ' ') || lastname)"
lastnamefirstname = "((lastname || ' ') || firstname)"
# special concat for mysql
if ChiliProject::Database.mysql?
firstnamelastname = "CONCAT(CONCAT(firstname, ' '), lastname)"
lastnamefirstname = "CONCAT(CONCAT(lastname, ' '), firstname)"
end
s = "%#{q.to_s.downcase.strip.tr(',','')}%"
{:conditions => ["LOWER(login) LIKE :s OR LOWER(firstname) LIKE :s OR LOWER(lastname) LIKE :s OR LOWER(#{firstnamelastname}) LIKE :s OR LOWER(#{lastnamefirstname}) LIKE :s OR LOWER(mail) LIKE :s", {:s => s}],
:order => 'type, login, lastname, firstname, mail'
{
:conditions => ["LOWER(login) LIKE :s OR " +
"LOWER(#{firstnamelastname}) LIKE :s OR " +
"LOWER(#{lastnamefirstname}) LIKE :s OR " +
"LOWER(mail) LIKE :s",
{:s => s}],
:order => 'type, login, lastname, firstname, mail'
}
}

@ -18,7 +18,6 @@ Feature: Membership
And there is a role "Developer"
And there is 1 project with the following:
| Name | Project1 |
| Identifier | project1 |
And there is 1 User with:
@ -35,13 +34,11 @@ Feature: Membership
| peter |
| hannibal |
@javascript
Scenario: Adding and Removing a Group as Member, non impaired
When I go to the settings page of the project called "Project1"
And I click on "tab-members"
When I go to the members tab of the settings page of the project "project1"
And I add the principal "A-Team" as "Manager"
Then I should be on the settings page of the project called "Project1"
Then I should be on the members tab of the settings page of the project "project1"
And I should see "Successful creation." within ".flash.notice"
And I should see "A-Team" within ".members"
@ -51,8 +48,7 @@ Feature: Membership
@javascript
Scenario: Adding and removing a User as Member, non impaired
When I go to the settings page of the project called "Project1"
And I click on "tab-members"
When I go to the members tab of the settings page of the project "project1"
And I add the principal "Hannibal Smith" as "Manager"
Then I should see "Successful creation." within ".flash.notice"
And I should see "Hannibal Smith" within ".members"
@ -63,25 +59,22 @@ Feature: Membership
@javascript
Scenario: Entering a Username as Member in firstname, lastname order, non impaired
When I go to the settings page of the project called "Project1"
And I click on "tab-members"
When I go to the members tab of the settings page of the project "project1"
And I enter the principal name "Hannibal S"
Then I should see "Hannibal Smith"
@javascript
Scenario: Entering a Username as Member in lastname, firstname order, non impaired
When I go to the settings page of the project called "Project1"
And I click on "tab-members"
When I go to the members tab of the settings page of the project "project1"
And I enter the principal name "Smith, H"
Then I should see "Hannibal Smith"
@javascript
Scenario: Adding and Removing a Group as Member, impaired
When I am impaired
And I go to the settings page of the project called "Project1"
And I click on "tab-members"
And I go to the members tab of the settings page of the project "project1"
And I add the principal "A-Team" as "Manager"
Then I should be on the settings page of the project called "Project1"
Then I should be on the members tab of the settings page of the project "project1"
And I should see "Successful creation." within ".flash.notice"
And I should see "A-Team" within ".members"
@ -89,28 +82,24 @@ Feature: Membership
And I wait for the AJAX requests to finish
Then I should see "No data to display"
@firebug
@javascript
@javascript
Scenario: Entering a Username as Member in firstname, lastname order, impaired
When I am impaired
And I go to the settings page of the project called "Project1"
And I click on "tab-members"
And I go to the members tab of the settings page of the project "project1"
And I enter the principal name "Hannibal S"
Then I should see "Hannibal Smith"
@javascript
Scenario: Entering a Username as Member in lastname, firstname order, impaired
When I am impaired
And I go to the settings page of the project called "Project1"
And I click on "tab-members"
And I go to the members tab of the settings page of the project "project1"
And I enter the principal name "Smith, H"
Then I should see "Hannibal Smith"
@javascript
Scenario: Adding and removing a User as Member, impaired
When I am impaired
And I go to the settings page of the project called "Project1"
And I click on "tab-members"
And I go to the members tab of the settings page of the project "project1"
And I add the principal "Hannibal Smith" as "Manager"
Then I should see "Successful creation." within ".flash.notice"
And I should see "Hannibal Smith" within ".members"

Loading…
Cancel
Save