This repository has been archived by the owner on Apr 11, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
adddc8f
commit 9ce5135
Showing
7 changed files
with
106 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
require 'spec_helper' | ||
require "spec_helper" | ||
|
||
describe 'Periscope::Adapters::ActiveRecord', :adapter => 'active_record' do | ||
let(:model){ User } | ||
describe "Periscope::Adapters::ActiveRecord", adapter: "active_record" do | ||
let(:model) { User } | ||
|
||
include_examples 'periscopic' | ||
include_examples 'databasic' | ||
include_examples "periscopic" | ||
include_examples "databasic" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
require 'spec_helper' | ||
require "spec_helper" | ||
|
||
describe 'Periscope::Adapters::DataMapper', :adapter => 'data_mapper' do | ||
let(:model){ User } | ||
describe "Periscope::Adapters::DataMapper", adapter: "data_mapper" do | ||
let(:model) { User } | ||
|
||
include_examples 'periscopic' | ||
include_examples 'databasic' | ||
include_examples "periscopic" | ||
include_examples "databasic" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
require 'spec_helper' | ||
require "spec_helper" | ||
|
||
describe 'Periscope::Adapters::MongoMapper', :adapter => 'mongo_mapper' do | ||
let(:model){ User } | ||
describe "Periscope::Adapters::MongoMapper", adapter: "mongo_mapper" do | ||
let(:model) { User } | ||
|
||
include_examples 'periscopic' | ||
include_examples 'databasic' | ||
include_examples "periscopic" | ||
include_examples "databasic" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
require 'spec_helper' | ||
require "spec_helper" | ||
|
||
describe 'Periscope::Adapters::Mongoid', :adapter => 'mongoid' do | ||
let(:model){ User } | ||
describe "Periscope::Adapters::Mongoid", adapter: "mongoid" do | ||
let(:model) { User } | ||
|
||
include_examples 'periscopic' | ||
include_examples 'databasic' | ||
include_examples "periscopic" | ||
include_examples "databasic" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
require 'spec_helper' | ||
require "spec_helper" | ||
|
||
describe Periscope, :adapter => nil do | ||
describe Periscope, adapter: nil do | ||
let(:model) do | ||
klass = MockModel.new | ||
klass.extend(Periscope) | ||
klass | ||
end | ||
|
||
include_examples 'periscopic' | ||
include_examples "periscopic" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,37 @@ | ||
shared_examples 'databasic' do | ||
context 'with a database' do | ||
shared_examples "databasic" do | ||
context "with a database" do | ||
before do | ||
create(:user, :gender => 'male', :salary => 1_000_000) | ||
create(:user, :gender => 'female', :salary => 2_000_000) | ||
create(:user, :gender => 'female', :salary => 3_000_000) | ||
create(:user, gender: "male", salary: 1_000_000) | ||
create(:user, gender: "female", salary: 2_000_000) | ||
create(:user, gender: "female", salary: 3_000_000) | ||
end | ||
|
||
it 'returns all records for no params' do | ||
it "returns all records for no params" do | ||
User.periscope.count.should == 3 | ||
end | ||
|
||
it 'respects existing scoping' do | ||
it "respects existing scoping" do | ||
User.female.periscope.count.should == 2 | ||
end | ||
|
||
it 'links to existing scoping' do | ||
it "links to existing scoping" do | ||
User.scope_accessible(:makes) | ||
User.female.periscope(:makes => 3_000_000).count.should == 1 | ||
User.female.periscope(makes: 3_000_000).count.should == 1 | ||
end | ||
|
||
it 'applies named scopes' do | ||
User.scope_accessible(:male, :boolean => true) | ||
User.periscope(:male => true).count.should == 1 | ||
it "applies named scopes" do | ||
User.scope_accessible(:male, boolean: true) | ||
User.periscope(male: true).count.should == 1 | ||
end | ||
|
||
it 'applies class methods' do | ||
it "applies class methods" do | ||
User.scope_accessible(:gender) | ||
User.periscope(:gender => 'male').count.should == 1 | ||
User.periscope(gender: "male").count.should == 1 | ||
end | ||
|
||
it 'chains scopes' do | ||
it "chains scopes" do | ||
User.scope_accessible(:gender, :makes) | ||
User.periscope(:gender => 'female', :makes => 3_000_000).count.should == 1 | ||
User.periscope(gender: "female", makes: 3_000_000).count.should == 1 | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters