Skip to content

Commit

Permalink
removed ENABLE_OJ from tests and travis config
Browse files Browse the repository at this point in the history
  • Loading branch information
ddnexus committed Apr 10, 2021
1 parent dede255 commit 9efb908
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 35 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,5 @@ matrix:
- rvm: 3.0
gemfile: ci-gemfiles/ruby-3.0
env:
- ENABLE_OJ=true
- RUN_RUBOCOP=true
- RUN_CODECOV=true
3 changes: 2 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ define_test_task :test_extra_overflow, 'test/**/overflow_test.rb'
define_test_task :test_extra_trim, 'test/**/trim_test.rb'
define_test_task :test_extra_elasticsearch, 'test/**/elasticsearch_rails_test.rb', 'test/**/searchkick_test.rb'
define_test_task :test_support, 'test/**/support_test.rb'
define_test_task :test_shared,'test/**/oj_shared_test.rb'
define_test_task :test_shared,'test/**/shared_test.rb'
define_test_task :test_shared_combo, 'test/**/shared_combo_test.rb'
define_test_task :test_shared_items_trim, 'test/**/shared_items_trim_test.rb'

# We exclude the files of the other tasks from the :test_main task
Rake::TestTask.new(:test_main) do |t|
Expand Down
7 changes: 7 additions & 0 deletions test/pagy/extras/oj_shared_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

require 'oj'
require_relative '../../test_helper'
require 'pagy/extras/shared'

require_relative 'shared_test'
File renamed without changes.
60 changes: 27 additions & 33 deletions test/pagy/extras/shared_test.rb
Original file line number Diff line number Diff line change
@@ -1,53 +1,47 @@
# frozen_string_literal: true

if ENV['ENABLE_OJ'] == 'true'
require_relative '../../test_helper'
require 'pagy/extras/shared'

require_relative '../../test_helper'
require 'oj' # all the other tests run without Oj
require 'pagy/extras/shared'
describe Pagy::Frontend do

describe Pagy::Frontend do
let(:view) { MockView.new('http://example.com:3000/foo?') }

let(:view) { MockView.new('http://example.com:3000/foo?') }

describe '#pagy_json_tag' do

it 'should use oj' do
_(view.pagy_json_tag(Pagy.new(count: 10), :test_function, 'some-id', 'some-string', 123, true)).must_equal \
"<script type=\"application/json\" class=\"pagy-json\">[\"test_function\",\"some-id\",\"some-string\",123,true,null]</script>"
end
describe '#pagy_json_tag' do

it 'should use oj/json' do
_(view.pagy_json_tag(Pagy.new(count: 10), :test_function, 'some-id', 'some-string', 123, true)).must_equal \
"<script type=\"application/json\" class=\"pagy-json\">[\"test_function\",\"some-id\",\"some-string\",123,true,null]</script>"
end

end

describe '#pagy_id' do

it 'should return different SHA1 ids' do
id1 = call_pagy_id
id2 = call_pagy_id
_(id1).must_be_kind_of String
_(id2).must_be_kind_of String
_(id1).must_be :!=, id2
end
describe '#pagy_id' do

it 'should return different SHA1 ids' do
id1 = call_pagy_id
id2 = call_pagy_id
_(id1).must_be_kind_of String
_(id2).must_be_kind_of String
_(id1).must_be :!=, id2
end

describe '#pagy_marked_link' do
end

it 'should return only the "standard" link' do
pagy = Pagy.new(count: 100, page: 4)
_(view.pagy_marked_link(view.pagy_link_proc(pagy))).must_equal("<a href=\"/foo?page=__pagy_page__\" style=\"display: none;\"></a>")
pagy = Pagy.new(count: 100, page: 4, page_param: 'p')
_(view.pagy_marked_link(view.pagy_link_proc(pagy))).must_equal("<a href=\"/foo?p=__pagy_page__\" style=\"display: none;\"></a>")
end
describe '#pagy_marked_link' do

it 'should return only the "standard" link' do
pagy = Pagy.new(count: 100, page: 4)
_(view.pagy_marked_link(view.pagy_link_proc(pagy))).must_equal("<a href=\"/foo?page=__pagy_page__\" style=\"display: none;\"></a>")
pagy = Pagy.new(count: 100, page: 4, page_param: 'p')
_(view.pagy_marked_link(view.pagy_link_proc(pagy))).must_equal("<a href=\"/foo?p=__pagy_page__\" style=\"display: none;\"></a>")
end

# we need an intermediate call to get the right caller
def call_pagy_id
view.pagy_id
end
end

# we need an intermediate call to get the right caller
def call_pagy_id
view.pagy_id
end

end

0 comments on commit 9efb908

Please sign in to comment.