Skip to content

Commit

Permalink
Mark AR specific tests with AR tag
Browse files Browse the repository at this point in the history
  • Loading branch information
nbulaj committed Mar 26, 2024
1 parent 424b885 commit 9c2b1d3
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 69 deletions.
82 changes: 43 additions & 39 deletions spec/lib/config_spec.rb
Expand Up @@ -360,60 +360,64 @@
expect(Doorkeeper.config.enable_application_owner?).not_to be(true)
end

context "when enabled without confirmation", active_record: true do
class ApplicationWithOwner < ActiveRecord::Base
include Doorkeeper::Orm::ActiveRecord::Mixins::Application
end
if DOORKEEPER_ORM == :active_record
context "when enabled without confirmation", active_record: true do
class ApplicationWithOwner < ActiveRecord::Base
include Doorkeeper::Orm::ActiveRecord::Mixins::Application
end

before do
Doorkeeper.configure do
orm DOORKEEPER_ORM
enable_application_owner
before do
Doorkeeper.configure do
orm DOORKEEPER_ORM
enable_application_owner

application_class "ApplicationWithOwner"
end
application_class "ApplicationWithOwner"
end

Doorkeeper.run_orm_hooks
end
Doorkeeper.run_orm_hooks
end

it "adds support for application owner" do
instance = ApplicationWithOwner.new(FactoryBot.attributes_for(:application))
it "adds support for application owner" do
instance = ApplicationWithOwner.new(FactoryBot.attributes_for(:application))

expect(instance).to respond_to :owner
expect(instance).to be_valid
end
expect(instance).to respond_to :owner
expect(instance).to be_valid
end

it "Doorkeeper.configuration.confirm_application_owner? returns false" do
expect(Doorkeeper.config.confirm_application_owner?).not_to be(true)
it "Doorkeeper.configuration.confirm_application_owner? returns false" do
expect(Doorkeeper.config.confirm_application_owner?).not_to be(true)
end
end
end

context "when enabled with confirmation set to true", active_record: true do
class ApplicationWithOwner < ActiveRecord::Base
include Doorkeeper::Orm::ActiveRecord::Mixins::Application
end
if DOORKEEPER_ORM == :active_record
context "when enabled with confirmation set to true", active_record: true do
class ApplicationWithOwner < ActiveRecord::Base
include Doorkeeper::Orm::ActiveRecord::Mixins::Application
end

before do
Doorkeeper.configure do
orm DOORKEEPER_ORM
enable_application_owner confirmation: true
before do
Doorkeeper.configure do
orm DOORKEEPER_ORM
enable_application_owner confirmation: true

application_class "ApplicationWithOwner"
end
application_class "ApplicationWithOwner"
end

Doorkeeper.run_orm_hooks
end
Doorkeeper.run_orm_hooks
end

it "adds support for application owner" do
instance = ApplicationWithOwner.new(FactoryBot.attributes_for(:application))
it "adds support for application owner" do
instance = ApplicationWithOwner.new(FactoryBot.attributes_for(:application))

expect(instance).to respond_to :owner
expect(instance).not_to be_valid
expect(instance.errors[:owner]).to be_present
end
expect(instance).to respond_to :owner
expect(instance).not_to be_valid
expect(instance.errors[:owner]).to be_present
end

it "Doorkeeper.configuration.confirm_application_owner? returns true" do
expect(Doorkeeper.config.confirm_application_owner?).to be(true)
it "Doorkeeper.configuration.confirm_application_owner? returns true" do
expect(Doorkeeper.config.confirm_application_owner?).to be(true)
end
end
end
end
Expand Down
61 changes: 31 additions & 30 deletions spec/models/doorkeeper/application_spec.rb
Expand Up @@ -518,46 +518,47 @@ def self.generate
end
end

context "when custom model class configured", active_record: true do
class CustomApp < ::ActiveRecord::Base
include Doorkeeper::Orm::ActiveRecord::Mixins::Application
end
if DOORKEEPER_ORM == :active_record
context "when custom model class configured", active_record: true do
class CustomApp < ::ActiveRecord::Base
include Doorkeeper::Orm::ActiveRecord::Mixins::Application
end

let(:new_application) { CustomApp.new(FactoryBot.attributes_for(:application)) }
let(:new_application) { CustomApp.new(FactoryBot.attributes_for(:application)) }

context "without confirmation" do
before do
Doorkeeper.configure do
orm DOORKEEPER_ORM
application_class "CustomApp"
enable_application_owner confirmation: false
context "without confirmation" do
before do
Doorkeeper.configure do
orm DOORKEEPER_ORM
application_class "CustomApp"
enable_application_owner confirmation: false
end

Doorkeeper.run_orm_hooks
end

Doorkeeper.run_orm_hooks
it "is valid given valid attributes" do
expect(new_application).to be_valid
end
end

it "is valid given valid attributes" do
expect(new_application).to be_valid
end
end
context "without confirmation" do
before do
Doorkeeper.configure do
orm DOORKEEPER_ORM
application_class "CustomApp"
enable_application_owner confirmation: true
end

context "without confirmation" do
before do
Doorkeeper.configure do
orm DOORKEEPER_ORM
application_class "CustomApp"
enable_application_owner confirmation: true
Doorkeeper.run_orm_hooks
end

Doorkeeper.run_orm_hooks
end

it "is invalid without owner" do
expect(new_application).not_to be_valid
new_application.owner = owner
expect(new_application).to be_valid
it "is invalid without owner" do
expect(new_application).not_to be_valid
new_application.owner = owner
expect(new_application).to be_valid
end
end
end

end
end

0 comments on commit 9c2b1d3

Please sign in to comment.