Files
openfoodnetwork/spec/lib/tasks/users_rake_spec.rb
Pau Perez 80edfe469c Task to remove limit of ent. that can be created
It does so by updating a user's enterprise_limit attribute to the
maximum integer the database supports.

This is used at least in Katuma to remove the limitation of the number
of enterprises a user can create. This is the agreement the community
reached for the pricing plans.

Eventually, this logic could be triggered with a button from the UI but
for now this is for internal usage only.
2019-10-24 15:53:43 +02:00

29 lines
741 B
Ruby

require 'spec_helper'
require 'rake'
describe 'users.rake' do
describe ':remove_enterprise_limit' do
context 'when the user exists' do
it 'sets the enterprise_limit to the maximum integer' do
Rake.application.rake_require 'tasks/users'
Rake::Task.define_task(:environment)
max_integer = 2147483647
user = create(:user)
Rake.application.invoke_task "ofn:remove_enterprise_limit[#{user.id}]"
expect(user.reload.enterprise_limit).to eq(max_integer)
end
end
context 'when the user does not exist' do
it 'raises' do
expect {
RemoveEnterpriseLimit.new(-1).call
}.to raise_error(ActiveRecord::RecordNotFound)
end
end
end
end