2017-05-30 00:58:26 -04:00
|
|
|
require "spec_helper"
|
2013-11-15 13:54:30 -05:00
|
|
|
|
2017-04-01 20:13:08 -04:00
|
|
|
RSpec.describe JoinedVersion, type: :model, versioning: true do
|
2016-02-15 22:32:40 -05:00
|
|
|
let(:widget) { Widget.create!(name: FFaker::Name.name) }
|
2013-11-15 13:54:30 -05:00
|
|
|
let(:version) { JoinedVersion.first }
|
|
|
|
|
2017-04-01 20:13:08 -04:00
|
|
|
describe "default_scope" do
|
|
|
|
it { expect(JoinedVersion.default_scopes).not_to be_empty }
|
|
|
|
end
|
2013-11-15 13:54:30 -05:00
|
|
|
|
2017-04-01 20:13:08 -04:00
|
|
|
describe "VersionConcern::ClassMethods" do
|
|
|
|
before { widget } # persist a widget
|
2013-11-15 13:54:30 -05:00
|
|
|
|
2017-04-01 20:13:08 -04:00
|
|
|
describe "#subsequent" do
|
|
|
|
it "does not raise error when there is a default_scope that joins" do
|
|
|
|
JoinedVersion.subsequent(version).first
|
2013-11-15 13:54:30 -05:00
|
|
|
end
|
2017-04-01 20:13:08 -04:00
|
|
|
end
|
2013-11-15 13:54:30 -05:00
|
|
|
|
2017-04-01 20:13:08 -04:00
|
|
|
describe "#preceding" do
|
|
|
|
it "does not raise error when there is a default scope that joins" do
|
|
|
|
JoinedVersion.preceding(version).first
|
2013-11-15 13:54:30 -05:00
|
|
|
end
|
2017-04-01 20:13:08 -04:00
|
|
|
end
|
2013-11-15 13:54:30 -05:00
|
|
|
|
2017-04-01 20:13:08 -04:00
|
|
|
describe "#between" do
|
|
|
|
it "does not raise error when there is a default scope that joins" do
|
|
|
|
JoinedVersion.between(Time.now, 1.minute.from_now).first
|
2013-11-15 13:54:30 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-04-01 20:13:08 -04:00
|
|
|
describe "#index" do
|
|
|
|
it { is_expected.to respond_to(:index) }
|
2013-11-15 13:54:30 -05:00
|
|
|
|
2017-04-01 20:13:08 -04:00
|
|
|
it "does not raise error when there is a default scope that joins" do
|
|
|
|
widget # persist a widget
|
|
|
|
version.index
|
2013-11-15 13:54:30 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|