Skip to content

Commit

Permalink
spec fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
orangewolf committed Feb 9, 2024
1 parent 8da78bb commit f7dd4aa
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion app/controllers/bulkrax/importers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def index
# NOTE: We're paginating this in the browser.
if api_request?
@importers = Importer.order(created_at: :desc).all
json_response('index')
json_response('index')
elsif defined?(::Hyrax)
add_importer_breadcrumbs
end
Expand Down
16 changes: 8 additions & 8 deletions app/controllers/concerns/bulkrax/datatables_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ def entry_table_search
column = Arel::Nodes::NamedFunction.new('CAST', [column.as('text')])
column = Arel::Nodes::NamedFunction.new('LOWER', [column])
@entry_table_search = if @entry_table_search
@entry_table_search.or(column.matches("%#{table_search_value}%"))
else
column.matches("%#{table_search_value}%")
end
@entry_table_search.or(column.matches("%#{table_search_value}%"))
else
column.matches("%#{table_search_value}%")
end
end

@entry_table_search
Expand All @@ -53,10 +53,10 @@ def importer_table_search
column = Arel::Nodes::NamedFunction.new('CAST', [column.as('text')])
column = Arel::Nodes::NamedFunction.new('LOWER', [column])
@importer_table_search = if @importer_table_search
@importer_table_search.or(column.matches("%#{table_search_value}%"))
else
column.matches("%#{table_search_value}%")
end
@importer_table_search.or(column.matches("%#{table_search_value}%"))
else
column.matches("%#{table_search_value}%")
end
end

@importer_table_search
Expand Down
24 changes: 12 additions & 12 deletions spec/controllers/concerns/bulkrax/datatables_behavior_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ def current_user
end
end

describe '#table_search' do
describe '#entry_table_search' do
it 'returns false when params[:search][:value] is blank' do
get :index, params: { search: { value: '' } }
expect(controller.table_search).to eq(false)
expect(controller.entry_table_search).to eq(false)
end

it 'returns a Arel::Nodes::Grouping node when params[:search][:value] is not blank' do
get :index, params: { search: { value: 'some_value' } }
expect(controller.table_search).to be_a(Arel::Nodes::Grouping)
expect(controller.entry_table_search).to be_a(Arel::Nodes::Grouping)
end
end

Expand All @@ -95,15 +95,15 @@ def current_user
end
end

describe '#util_links' do
describe '#entry_util_links' do
include Bulkrax::Engine.routes.url_helpers

let(:item) { FactoryBot.create(:bulkrax_importer) }
let(:entry) { FactoryBot.create(:bulkrax_entry, importerexporter: item) }

it 'returns a string of HTML links' do
get :index
result = controller.util_links(entry, item)
result = controller.entry_util_links(entry, item)
expect(result).to be_a(String)
expect(result).to include('glyphicon-info-sign')
expect(result).to include('glyphicon-repeat')
Expand All @@ -112,46 +112,46 @@ def current_user

it 'includes a link to the entry' do
get :index
result = controller.util_links(entry, item)
result = controller.entry_util_links(entry, item)
expect(result).to include(importer_entry_path(item, entry))
end

it 'includes a delete link to the entry' do
get :index
result = controller.util_links(entry, item)
result = controller.entry_util_links(entry, item)
expect(result).to include(importer_entry_path(item, entry))
expect(result).to include('method="delete"')
end
end

describe '#entry_status' do
describe '#status_message_for' do
let(:item) { FactoryBot.create(:bulkrax_importer) }

it 'returns a string of HTML with a green checkmark when status_message is "Complete"' do
entry = FactoryBot.create(:bulkrax_entry, importerexporter: item, status_message: 'Complete')
get :index
result = controller.entry_status(entry)
result = controller.status_message_for(entry)
expect(result).to include('<span class=\'glyphicon glyphicon-ok\' style=\'color: green;\'></span> Complete')
end

it 'returns a string of HTML with a blue "horizontal ellipsis" icon when status_message is "Pending"' do
entry = FactoryBot.create(:bulkrax_entry, importerexporter: item, status_message: 'Pending')
get :index
result = controller.entry_status(entry)
result = controller.status_message_for(entry)
expect(result).to include('<span class=\'glyphicon glyphicon-option-horizontal\' style=\'color: blue;\'></span> Pending')
end

it 'returns a string of HTML with a red "remove" icon when status_message is neither "Complete" nor "Pending"' do
entry = FactoryBot.create(:bulkrax_entry, importerexporter: item, status_message: 'Error')
get :index
result = controller.entry_status(entry)
result = controller.status_message_for(entry)
expect(result).to include('<span class=\'glyphicon glyphicon-remove\' style=\'color: red;\'></span> Error')
end

it 'returns a string of HTML with a red "remove" icon when status_message is "Deleted"' do
entry = FactoryBot.create(:bulkrax_entry, importerexporter: item, status_message: 'Deleted')
get :index
result = controller.entry_status(entry)
result = controller.status_message_for(entry)
expect(result).to include('<span class=\'glyphicon glyphicon-remove\' style=\'color: red;\'></span> Deleted')
end
end
Expand Down

0 comments on commit f7dd4aa

Please sign in to comment.