Skip to content

Commit

Permalink
Add basic coverage to sortable function and fix it
Browse files Browse the repository at this point in the history
  • Loading branch information
barnabyalter committed Mar 27, 2019
1 parent f783817 commit c3acc31
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def sortable(column, title = nil)
css_class = column == sort_column ? "current #{sort_direction}" : nil
direction = column == sort_column && sort_direction == "asc" ? "desc" : "asc"
direction_icon = (direction.eql? "desc") ? :sort_desc : :sort_asc
html = link_to title, params.merge(:sort => column, :direction => direction, :page => nil, :id => ""), {:class => css_class}
html = link_to(title, users_url(sort: column, direction: direction, page: nil, id: ""), { class: css_class })
html << icon_tag(direction_icon) if column == sort_column
return html
end
Expand Down
11 changes: 6 additions & 5 deletions spec/helpers/application_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@
end
end

# describe '#sortable' do
# let(:sort_column) { 'title' }
# subject { sortable('title') }
# it { is_expected.to eql '' }
# end
describe '#sortable' do
let(:sort_direction) { 'asc' }
let(:sort_column) { 'author' }
subject { sortable('title') }
it { is_expected.to eql '<a href="http://test.host/admin/users?direction=asc&amp;id=&amp;sort=title">Title</a>' }
end

describe '#user_status' do
subject { user_status(user) }
Expand Down

0 comments on commit c3acc31

Please sign in to comment.