Skip to content

Commit

Permalink
wth - (SPARCRequest) Replace FactoryGirl with FactoryBot
Browse files Browse the repository at this point in the history
  • Loading branch information
wtholt committed Jun 12, 2018
1 parent 0bce713 commit d6b961d
Show file tree
Hide file tree
Showing 81 changed files with 196 additions and 196 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ group :test do
gem 'capybara-webkit'
gem 'database_cleaner'
gem 'email_spec'
gem 'factory_girl_rails'
gem "factory_bot_rails"
gem 'rails-controller-testing', require: false
gem 'rspec-activemodel-mocks'
gem 'rspec-html-matchers'
Expand Down
8 changes: 4 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,10 @@ GEM
actionmailer (>= 4.0, < 6)
activesupport (>= 4.0, < 6)
execjs (2.7.0)
factory_girl (4.9.0)
factory_bot (4.10.0)
activesupport (>= 3.0.0)
factory_girl_rails (4.9.0)
factory_girl (~> 4.9.0)
factory_bot_rails (4.10.0)
factory_bot (~> 4.10.0)
railties (>= 3.0.0)
faker (1.8.7)
i18n (>= 0.7)
Expand Down Expand Up @@ -613,7 +613,7 @@ DEPENDENCIES
equivalent-xml
exception_notification
execjs
factory_girl_rails
factory_bot_rails
faker
filterrific!
gon (~> 6.1)
Expand Down
4 changes: 2 additions & 2 deletions app/models/survey.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ def self.for_dropdown_select
}
end

# Added because version could not be written as an attribute by FactoryGirl. Possible keyword issue?
# Added because version could not be written as an attribute by FactoryBot. Possible keyword issue?
def version=(v)
write_attribute(:version, v)
end

# Added because version could not be read as an attribute by FactoryGirl. Possible keyword issue?
# Added because version could not be read as an attribute by FactoryBot. Possible keyword issue?
def version
read_attribute(:version)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
describe 'GET /v1/human_subjects_infos/:id.json' do

before do
human_subjects_info = FactoryGirl.build(:human_subjects_info, pro_number: nil, hr_number: nil)
@study = FactoryGirl.build(:study, human_subjects_info: human_subjects_info)
human_subjects_info = FactoryBot.build(:human_subjects_info, pro_number: nil, hr_number: nil)
@study = FactoryBot.build(:study, human_subjects_info: human_subjects_info)
@study.save(validate: false)

end
Expand Down Expand Up @@ -65,7 +65,7 @@

it 'should respond with a HumanSubjectsInfo' do
parsed_body = JSON.parse(response.body)
expected_attributes = FactoryGirl.build(:human_subjects_info).attributes.
expected_attributes = FactoryBot.build(:human_subjects_info).attributes.
keys.
reject { |key| ['id','created_at', 'updated_at', 'deleted_at'].include?(key) }.
push('callback_url', 'sparc_id').
Expand All @@ -81,7 +81,7 @@

it 'should respond with an array of human_subjects_info and their attributes and their shallow reflections' do
parsed_body = JSON.parse(response.body)
expected_attributes = FactoryGirl.build(:human_subjects_info).attributes.
expected_attributes = FactoryBot.build(:human_subjects_info).attributes.
keys.
reject { |key| ['id', 'created_at', 'updated_at', 'deleted_at'].include?(key) }.
push('callback_url', 'sparc_id', 'protocol').
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@

before do
5.times do
human_subjects_info = FactoryGirl.build(:human_subjects_info, pro_number: nil, hr_number: nil)
@study = FactoryGirl.build(:study, human_subjects_info: human_subjects_info)
human_subjects_info = FactoryBot.build(:human_subjects_info, pro_number: nil, hr_number: nil)
@study = FactoryBot.build(:study, human_subjects_info: human_subjects_info)
@study.save(validate: false)
end
end
Expand Down Expand Up @@ -76,7 +76,7 @@

it 'should respond with an array of human_subjects_info and their attributes' do
parsed_body = JSON.parse(response.body)
expected_attributes = FactoryGirl.build(:human_subjects_info).attributes.
expected_attributes = FactoryBot.build(:human_subjects_info).attributes.
keys.
reject { |key| ['id', 'created_at', 'updated_at', 'deleted_at'].include?(key) }.
push('callback_url', 'sparc_id').
Expand All @@ -92,7 +92,7 @@

it 'should respond with an array of human_subjects_info and their attributes and their shallow reflections' do
parsed_body = JSON.parse(response.body)
expected_attributes = FactoryGirl.build(:human_subjects_info).attributes.
expected_attributes = FactoryBot.build(:human_subjects_info).attributes.
keys.
reject { |key| ['id', 'created_at', 'updated_at', 'deleted_at'].include?(key) }.
push('callback_url', 'sparc_id', 'protocol').
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@

before do
5.times do
human_subjects_info = FactoryGirl.build(:human_subjects_info, pro_number: nil, hr_number: nil)
@study = FactoryGirl.build(:study, human_subjects_info: human_subjects_info)
human_subjects_info = FactoryBot.build(:human_subjects_info, pro_number: nil, hr_number: nil)
@study = FactoryBot.build(:study, human_subjects_info: human_subjects_info)
@study.save(validate: false)
end

Expand Down Expand Up @@ -79,7 +79,7 @@
it 'should respond with an array of human_subjects_info and their attributes' do
parsed_body = JSON.parse(response.body)

expected_attributes = FactoryGirl.build(:human_subjects_info).attributes.
expected_attributes = FactoryBot.build(:human_subjects_info).attributes.
keys.
reject { |key| ['id', 'created_at', 'updated_at', 'deleted_at'].include?(key) }.
push('callback_url', 'sparc_id').
Expand All @@ -95,7 +95,7 @@

it 'should respond with an array of human_subjects_info and their attributes and their shallow reflections' do
parsed_body = JSON.parse(response.body)
expected_attributes = FactoryGirl.build(:human_subjects_info).attributes.
expected_attributes = FactoryBot.build(:human_subjects_info).attributes.
keys.
reject { |key| ['id', 'created_at', 'updated_at', 'deleted_at'].include?(key) }.
push('callback_url', 'sparc_id', 'protocol').
Expand Down
18 changes: 9 additions & 9 deletions spec/api/v1/identities/get_identity_by_ldap_uid_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

describe 'GET /v1/identities.json' do
before do
FactoryGirl.create_list(:identity, 5)
FactoryBot.create_list(:identity, 5)
end
##################################
# Shallow records
Expand Down Expand Up @@ -801,9 +801,9 @@
before do
@identity = Identity.first
5.times do
protocol = FactoryGirl.build(:protocol)
protocol = FactoryBot.build(:protocol)
protocol.save validate: false
FactoryGirl.create(:project_role_with_identity_and_protocol, identity: @identity, protocol: protocol)
FactoryBot.create(:project_role_with_identity_and_protocol, identity: @identity, protocol: protocol)
end

params = { :depth => 'full_with_shallow_reflections',
Expand Down Expand Up @@ -831,9 +831,9 @@
before do
@identity = Identity.first
5.times do
protocol = FactoryGirl.build(:protocol)
protocol = FactoryBot.build(:protocol)
protocol.save validate: false
FactoryGirl.create(:project_role_with_identity_and_protocol, identity: @identity, protocol: protocol)
FactoryBot.create(:project_role_with_identity_and_protocol, identity: @identity, protocol: protocol)
end

params = { :depth => 'full_with_shallow_reflections',
Expand Down Expand Up @@ -863,9 +863,9 @@
before do
@identity = Identity.first
5.times do
protocol = FactoryGirl.build(:protocol)
protocol = FactoryBot.build(:protocol)
protocol.save validate: false
FactoryGirl.create(:project_role_with_identity_and_protocol, identity: @identity, protocol: protocol)
FactoryBot.create(:project_role_with_identity_and_protocol, identity: @identity, protocol: protocol)
end

params = { :depth => 'full_with_shallow_reflections',
Expand Down Expand Up @@ -895,9 +895,9 @@
before do
@identity = Identity.first
5.times do
protocol = FactoryGirl.build(:protocol)
protocol = FactoryBot.build(:protocol)
protocol.save validate: false
FactoryGirl.create(:project_role_with_identity_and_protocol, identity: @identity, protocol: protocol)
FactoryBot.create(:project_role_with_identity_and_protocol, identity: @identity, protocol: protocol)
end
# update all identities to have the same institution
Identity.all.each do |identity|
Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/catalog_manager/services_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@

context "Service has pre-existing ServiceLevelComponents" do

before { @service = FactoryGirl.create(:service_with_components) }
before { @service = FactoryBot.create(:service_with_components) }

it "should create new ServiceLevelComponents" do
put :update, params: { id: @service.id, service: { name: "New name" }.merge!(service_level_component_params) }
Expand All @@ -98,7 +98,7 @@
context "Service with pre-existing ServiceLevelComponents" do

it "should build ServiceLevelComponents with the correct :position" do
service = FactoryGirl.create(:service_with_components, organization: organization)
service = FactoryBot.create(:service_with_components, organization: organization)

get :show, params: { id: service.id }

Expand Down
6 changes: 3 additions & 3 deletions spec/extensions/epic_interface_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1192,7 +1192,7 @@ def strip_xml_whitespace!(root)
end

it 'should send an arm as a cell' do
FactoryGirl.create(:service_request_without_validations,
FactoryBot.create(:service_request_without_validations,
protocol: study,
status: 'draft')

Expand Down Expand Up @@ -1273,7 +1273,7 @@ def strip_xml_whitespace!(root)
end

it 'should send two arms as two cells' do
FactoryGirl.create(:service_request_without_validations,
FactoryBot.create(:service_request_without_validations,
protocol: study,
status: 'draft')

Expand Down Expand Up @@ -1405,7 +1405,7 @@ def strip_xml_whitespace!(root)
context 'with line items' do

let!(:service_request) {
FactoryGirl.create(:service_request_without_validations,
FactoryBot.create(:service_request_without_validations,
protocol: study,
status: 'submitted')
}
Expand Down
2 changes: 1 addition & 1 deletion spec/factories/admin_rate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

FactoryGirl.define do
FactoryBot.define do

factory :admin_rate do

Expand Down
2 changes: 1 addition & 1 deletion spec/factories/affiliation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

# The association with protocol must be created manually through the id's
# due to validations on protocol
FactoryGirl.define do
FactoryBot.define do

factory :affiliation do
name { Faker::Lorem.word }
Expand Down
2 changes: 1 addition & 1 deletion spec/factories/approval.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

FactoryGirl.define do
FactoryBot.define do

factory :approval do
approval_date { Time.now }
Expand Down
2 changes: 1 addition & 1 deletion spec/factories/arm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

FactoryGirl.define do
FactoryBot.define do
factory :arm do
sequence(:name) { |n| "Arm #{n}" }
subject_count { 1 }
Expand Down
2 changes: 1 addition & 1 deletion spec/factories/associated_survey.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

FactoryGirl.define do
FactoryBot.define do
factory :associated_survey do
survey { nil }
associable { nil }
Expand Down
2 changes: 1 addition & 1 deletion spec/factories/available_status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

FactoryGirl.define do
FactoryBot.define do

factory :available_status do
selected true
Expand Down
2 changes: 1 addition & 1 deletion spec/factories/catalog_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

FactoryGirl.define do
FactoryBot.define do

factory :catalog_manager do
edit_historic_data { false }
Expand Down
2 changes: 1 addition & 1 deletion spec/factories/charge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

FactoryGirl.define do
FactoryBot.define do

factory :charge do
charge_amount { Random.rand(1000) }
Expand Down
2 changes: 1 addition & 1 deletion spec/factories/clinical_provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

FactoryGirl.define do
FactoryBot.define do

factory :clinical_provider do
identity nil
Expand Down
4 changes: 2 additions & 2 deletions spec/factories/contact_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR~
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.~

FactoryGirl.define do
FactoryBot.define do
factory :contact_form, class: ContactForm do
subject 'SPARC-Request'
email 'example@example.com'
message 'this is a sample message'
end
end
end
2 changes: 1 addition & 1 deletion spec/factories/document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

FactoryGirl.define do
FactoryBot.define do
factory :document do
doc_type { 'other' }
doc_type_other { Faker::Lorem.word }
Expand Down
2 changes: 1 addition & 1 deletion spec/factories/editable_status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

FactoryGirl.define do
FactoryBot.define do
factory :editable_status do
selected true
status { PermissibleValue.get_key_list('status').sample }
Expand Down
4 changes: 2 additions & 2 deletions spec/factories/epic_queue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

FactoryGirl.define do
FactoryBot.define do
factory :epic_queue, aliases: [:eq] do
created_at { Time.now }
updated_at { Time.now }
end
end
end
2 changes: 1 addition & 1 deletion spec/factories/epic_queue_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR~
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.~

FactoryGirl.define do
FactoryBot.define do
factory :epic_queue_record do
protocol_id nil
status 'complete'
Expand Down
2 changes: 1 addition & 1 deletion spec/factories/excluded_funding_source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

FactoryGirl.define do
FactoryBot.define do

factory :excluded_funding_source do
end
Expand Down
2 changes: 1 addition & 1 deletion spec/factories/feedback.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR~
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.~

FactoryGirl.define do
FactoryBot.define do
factory :feedback do
letters Digest::SHA1.hexdigest(Time.now.usec.to_s)[0..16]
name 'name'
Expand Down
2 changes: 1 addition & 1 deletion spec/factories/form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

FactoryGirl.define do
FactoryBot.define do
factory :form do
title { Faker::Lorem.word }
access_code { Faker::Lorem.word }
Expand Down

0 comments on commit d6b961d

Please sign in to comment.