Skip to content

Commit

Permalink
JM - (SPARCDashboard) Tie Search field Option with RMID configuration…
Browse files Browse the repository at this point in the history
… [#151658427]
  • Loading branch information
jwiel86 committed Oct 30, 2017
1 parent be8f0a6 commit 7405b7f
Show file tree
Hide file tree
Showing 6 changed files with 162 additions and 69 deletions.
8 changes: 8 additions & 0 deletions app/models/protocol_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,12 @@ def href
}
)
end

def self.search_filters
if Setting.find_by_key("research_master_enabled").value
['Authorized User', 'HR#', 'PI', 'Protocol ID', 'PRO#', 'RMID', 'Short/Long Title']
else
['Authorized User', 'HR#', 'PI', 'Protocol ID', 'PRO#', 'Short/Long Title']
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
= form.fields_for :search_query do |search|
.input-group-btn
.dd_select
= search.select :search_drop, options_for_select(t(:dashboard)[:protocol_filters][:search_by_options], filterrific.search_query.try(:search_drop)), { prompt: t(:dashboard)[:protocol_filters][:search_by] }, class: "form-control selectpicker ", data: { style: 'dropdown_filter' }
= search.select :search_drop, options_for_select(ProtocolFilter.search_filters, filterrific.search_query.try(:search_drop)), { prompt: t(:dashboard)[:protocol_filters][:search_by] }, class: "form-control selectpicker ", data: { style: 'dropdown_filter' }
= search.text_field :search_text, value: filterrific.search_query.try(:search_text), class: 'form-control'

.form-group.row
Expand Down
1 change: 0 additions & 1 deletion config/locales/dashboard.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ en:
protocol_filters:
header: "Filter Protocols"
search_by: "Search All"
search_by_options: ['Authorized User', 'HR#', 'PI', 'Protocol ID', 'PRO#', 'RMID', 'Short/Long Title']
archived: "Archived"
inactive: "(inactive)"
status: "Status"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,35 +263,66 @@


context "RMID search" do
before :each do
@protocol1 = create(:study_without_validations, primary_pi: jug2, title: "title%", short_title: "Protocol1")
@protocol2 = create(:study_without_validations, primary_pi: jug2, title: "xTitle", short_title: "Protocol2")
@protocol3 = create(:study_without_validations, primary_pi: jug2, title: "a%a", short_title: "Protocol3", research_master_id: 1234)

service_request1 = create(:service_request_without_validations, protocol: @protocol1)
service_request2 = create(:service_request_without_validations, protocol: @protocol2)
service_request3 = create(:service_request_without_validations, protocol: @protocol3)
context 'Setting.find_by_key("research_master_enabled").update_attribute(:value, true)' do
before :each do
Setting.find_by_key("research_master_enabled").update_attribute(:value, true)
@protocol1 = create(:study_without_validations, primary_pi: jug2, title: "title%", short_title: "Protocol1")
@protocol2 = create(:study_without_validations, primary_pi: jug2, title: "xTitle", short_title: "Protocol2")
@protocol3 = create(:study_without_validations, primary_pi: jug2, title: "a%a", short_title: "Protocol3", research_master_id: 1234)

service_request1 = create(:service_request_without_validations, protocol: @protocol1)
service_request2 = create(:service_request_without_validations, protocol: @protocol2)
service_request3 = create(:service_request_without_validations, protocol: @protocol3)

create(:sub_service_request, service_request: service_request1, organization: organization1)
create(:sub_service_request, service_request: service_request2, organization: organization2)
create(:sub_service_request, service_request: service_request3, organization: organization3)

visit dashboard_protocols_path
wait_for_javascript_to_finish

create(:sub_service_request, service_request: service_request1, organization: organization1)
create(:sub_service_request, service_request: service_request2, organization: organization2)
create(:sub_service_request, service_request: service_request3, organization: organization3)
expect(page).to have_selector(".protocols_index_row", count: 3)
end

visit dashboard_protocols_path
wait_for_javascript_to_finish
it "should match against RMID" do
bootstrap_select '#filterrific_search_query_search_drop', 'RMID'
fill_in 'filterrific_search_query_search_text', with: @protocol3.research_master_id
find('#apply-filter-button').click
wait_for_javascript_to_finish

expect(page).to have_selector(".protocols_index_row", count: 3)
expect(page).to have_selector(".protocols_index_row", count: 1)
expect(page).to_not have_content(@protocol1.short_title)
expect(page).to_not have_content(@protocol2.short_title)
expect(page).to have_content(@protocol3.short_title)
end
end

it "should match against RMID" do
bootstrap_select '#filterrific_search_query_search_drop', 'RMID'
fill_in 'filterrific_search_query_search_text', with: @protocol3.research_master_id
find('#apply-filter-button').click
wait_for_javascript_to_finish
context 'Setting.find_by_key("research_master_enabled").update_attribute(:value, false)' do
before :each do
Setting.find_by_key("research_master_enabled").update_attribute(:value, false)
@protocol1 = create(:study_without_validations, primary_pi: jug2, title: "title%", short_title: "Protocol1")
@protocol2 = create(:study_without_validations, primary_pi: jug2, title: "xTitle", short_title: "Protocol2")
@protocol3 = create(:study_without_validations, primary_pi: jug2, title: "a%a", short_title: "Protocol3", research_master_id: 1234)

expect(page).to have_selector(".protocols_index_row", count: 1)
expect(page).to_not have_content(@protocol1.short_title)
expect(page).to_not have_content(@protocol2.short_title)
expect(page).to have_content(@protocol3.short_title)
service_request1 = create(:service_request_without_validations, protocol: @protocol1)
service_request2 = create(:service_request_without_validations, protocol: @protocol2)
service_request3 = create(:service_request_without_validations, protocol: @protocol3)

create(:sub_service_request, service_request: service_request1, organization: organization1)
create(:sub_service_request, service_request: service_request2, organization: organization2)
create(:sub_service_request, service_request: service_request3, organization: organization3)

visit dashboard_protocols_path
wait_for_javascript_to_finish

expect(page).to have_selector(".protocols_index_row", count: 3)
end

it "should not display RMID as a filter option" do
bootstrap_select = page.find("select#filterrific_search_query_search_drop + .bootstrap-select")
bootstrap_select.click
expect(page).to_not have_content('RMID')
end
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,39 +263,68 @@


context "RMID search" do
before :each do
@protocol1 = create(:study_without_validations, primary_pi: jug2, title: "title%", short_title: "Protocol1")
@protocol2 = create(:study_without_validations, primary_pi: jug2, title: "xTitle", short_title: "Protocol2")
@protocol3 = create(:study_without_validations, primary_pi: jug2, title: "a%a", short_title: "Protocol3", research_master_id: 1234)
context 'Setting.find_by_key("research_master_enabled").update_attribute(:value, true)' do
before :each do
Setting.find_by_key("research_master_enabled").update_attribute(:value, true)
@protocol1 = create(:study_without_validations, primary_pi: jug2, title: "title%", short_title: "Protocol1")
@protocol2 = create(:study_without_validations, primary_pi: jug2, title: "xTitle", short_title: "Protocol2")
@protocol3 = create(:study_without_validations, primary_pi: jug2, title: "a%a", short_title: "Protocol3", research_master_id: 1234)

service_request1 = create(:service_request_without_validations, protocol: @protocol1)
service_request2 = create(:service_request_without_validations, protocol: @protocol2)
service_request3 = create(:service_request_without_validations, protocol: @protocol3)

visit dashboard_protocols_path
wait_for_javascript_to_finish

service_request1 = create(:service_request_without_validations, protocol: @protocol1)
service_request2 = create(:service_request_without_validations, protocol: @protocol2)
service_request3 = create(:service_request_without_validations, protocol: @protocol3)
find("#filterrific_admin_filter_for_identity_#{jug2.id}").click
find('#apply-filter-button').click
wait_for_javascript_to_finish

visit dashboard_protocols_path
wait_for_javascript_to_finish
expect(page).to have_selector(".protocols_index_row", count: 3)
end

find("#filterrific_admin_filter_for_identity_#{jug2.id}").click
find('#apply-filter-button').click
wait_for_javascript_to_finish
it "should match against RMID" do
bootstrap_select '#filterrific_search_query_search_drop', 'RMID'
fill_in 'filterrific_search_query_search_text', with: @protocol3.research_master_id
find('#apply-filter-button').click
wait_for_javascript_to_finish

expect(page).to have_selector(".protocols_index_row", count: 3)
expect(page).to have_selector(".protocols_index_row", count: 1)
expect(page).to_not have_content(@protocol1.short_title)
expect(page).to_not have_content(@protocol2.short_title)
expect(page).to have_content(@protocol3.short_title)
end
end

it "should match against RMID" do
bootstrap_select '#filterrific_search_query_search_drop', 'RMID'
fill_in 'filterrific_search_query_search_text', with: @protocol3.research_master_id
find('#apply-filter-button').click
wait_for_javascript_to_finish
context 'Setting.find_by_key("research_master_enabled").update_attribute(:value, false)' do
before :each do
Setting.find_by_key("research_master_enabled").update_attribute(:value, false)
@protocol1 = create(:study_without_validations, primary_pi: jug2, title: "title%", short_title: "Protocol1")
@protocol2 = create(:study_without_validations, primary_pi: jug2, title: "xTitle", short_title: "Protocol2")
@protocol3 = create(:study_without_validations, primary_pi: jug2, title: "a%a", short_title: "Protocol3", research_master_id: 1234)

expect(page).to have_selector(".protocols_index_row", count: 1)
expect(page).to_not have_content(@protocol1.short_title)
expect(page).to_not have_content(@protocol2.short_title)
expect(page).to have_content(@protocol3.short_title)
end
end
service_request1 = create(:service_request_without_validations, protocol: @protocol1)
service_request2 = create(:service_request_without_validations, protocol: @protocol2)
service_request3 = create(:service_request_without_validations, protocol: @protocol3)

visit dashboard_protocols_path
wait_for_javascript_to_finish

find("#filterrific_admin_filter_for_identity_#{jug2.id}").click
find('#apply-filter-button').click
wait_for_javascript_to_finish

expect(page).to have_selector(".protocols_index_row", count: 3)
end

it "should not display RMID as a filter option" do
bootstrap_select = page.find("select#filterrific_search_query_search_drop + .bootstrap-select")
bootstrap_select.click
expect(page).to_not have_content('RMID')
end
end
end

context "HR# search" do
before :each do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,36 +240,62 @@


context "RMID search" do
before :each do
@protocol1 = create(:study_without_validations, primary_pi: jug2, title: "title%", short_title: "Protocol1")
@protocol2 = create(:study_without_validations, primary_pi: jug2, title: "xTitle", short_title: "Protocol2")
@protocol3 = create(:study_without_validations, primary_pi: jug2, title: "a%a", short_title: "Protocol3", research_master_id: 1234)
context 'Setting.find_by_key("research_master_enabled").update_attribute(:value, true)' do
before :each do
Setting.find_by_key("research_master_enabled").update_attribute(:value, true)
@protocol1 = create(:study_without_validations, primary_pi: jug2, title: "title%", short_title: "Protocol1")
@protocol2 = create(:study_without_validations, primary_pi: jug2, title: "xTitle", short_title: "Protocol2")
@protocol3 = create(:study_without_validations, primary_pi: jug2, title: "a%a", short_title: "Protocol3", research_master_id: 1234)

service_request1 = create(:service_request_without_validations, protocol: @protocol1)
service_request2 = create(:service_request_without_validations, protocol: @protocol2)
service_request3 = create(:service_request_without_validations, protocol: @protocol3)

visit dashboard_protocols_path
wait_for_javascript_to_finish

service_request1 = create(:service_request_without_validations, protocol: @protocol1)
service_request2 = create(:service_request_without_validations, protocol: @protocol2)
service_request3 = create(:service_request_without_validations, protocol: @protocol3)
expect(page).to have_selector(".protocols_index_row", count: 3)
end

visit dashboard_protocols_path
wait_for_javascript_to_finish
it "should match against RMID" do
bootstrap_select '#filterrific_search_query_search_drop', 'RMID'
fill_in 'filterrific_search_query_search_text', with: @protocol3.research_master_id
find('#apply-filter-button').click
wait_for_javascript_to_finish

expect(page).to have_selector(".protocols_index_row", count: 3)
expect(page).to have_selector(".protocols_index_row", count: 1)
expect(page).to_not have_content(@protocol1.short_title)
expect(page).to_not have_content(@protocol2.short_title)
expect(page).to have_content(@protocol3.short_title)
end
end

it "should match against RMID" do
bootstrap_select '#filterrific_search_query_search_drop', 'RMID'
fill_in 'filterrific_search_query_search_text', with: @protocol3.research_master_id
find('#apply-filter-button').click
wait_for_javascript_to_finish
context 'Setting.find_by_key("research_master_enabled").update_attribute(:value, false)' do
before :each do
Setting.find_by_key("research_master_enabled").update_attribute(:value, false)
@protocol1 = create(:study_without_validations, primary_pi: jug2, title: "title%", short_title: "Protocol1")
@protocol2 = create(:study_without_validations, primary_pi: jug2, title: "xTitle", short_title: "Protocol2")
@protocol3 = create(:study_without_validations, primary_pi: jug2, title: "a%a", short_title: "Protocol3", research_master_id: 1234)

expect(page).to have_selector(".protocols_index_row", count: 1)
expect(page).to_not have_content(@protocol1.short_title)
expect(page).to_not have_content(@protocol2.short_title)
expect(page).to have_content(@protocol3.short_title)
service_request1 = create(:service_request_without_validations, protocol: @protocol1)
service_request2 = create(:service_request_without_validations, protocol: @protocol2)
service_request3 = create(:service_request_without_validations, protocol: @protocol3)

visit dashboard_protocols_path
wait_for_javascript_to_finish

expect(page).to have_selector(".protocols_index_row", count: 3)
end

it "should not display RMID as a filter option" do
bootstrap_select = page.find("select#filterrific_search_query_search_drop + .bootstrap-select")
bootstrap_select.click
expect(page).to_not have_content('RMID')
end
end
end



context "HR# search" do
before :each do
hsi1 = create(:human_subjects_info, hr_number: 111111)
Expand Down

0 comments on commit 7405b7f

Please sign in to comment.