summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2016-05-21 10:04:28 -0600
committermo khan <mo@mokhan.ca>2016-05-21 10:04:28 -0600
commit3f106db4211bf2d9879263d7bae445a84b69a1ea (patch)
treee641a7c76a996c2a75572507a06c894a638e5ce7 /spec
parenta4352210c65e2370a20a9c8c1c25be8cbe3b9bef (diff)
skip import if gyms in city already exist.
Diffstat (limited to 'spec')
-rw-r--r--spec/jobs/import_gyms_job_spec.rb9
-rw-r--r--spec/models/gym_spec.rb5
2 files changed, 11 insertions, 3 deletions
diff --git a/spec/jobs/import_gyms_job_spec.rb b/spec/jobs/import_gyms_job_spec.rb
index 3605993..69e3969 100644
--- a/spec/jobs/import_gyms_job_spec.rb
+++ b/spec/jobs/import_gyms_job_spec.rb
@@ -15,4 +15,13 @@ describe ImportGymsJob do
subject.perform(nil)
expect(Gym).to_not have_received(:import)
end
+
+ it 'skips the import of gyms in the city are already present' do
+ allow(Gym).to receive(:import)
+ create(:gym, location: location)
+
+ subject.perform(location)
+
+ expect(Gym).to_not have_received(:import)
+ end
end
diff --git a/spec/models/gym_spec.rb b/spec/models/gym_spec.rb
index c2fc2a5..c8968e7 100644
--- a/spec/models/gym_spec.rb
+++ b/spec/models/gym_spec.rb
@@ -124,15 +124,14 @@ describe Gym do
it "returns true when a dup is found" do
subject.location = create(:portland)
subject.save!
- other = create(:gym, location: create(:portland))
+ create(:gym, location: create(:portland))
expect(subject.duplicate?).to be_truthy
end
it 'returns true when another gym has the same yelp id' do
subject.yelp_id = "hello-world"
- subject.save!
- other = create(:gym, yelp_id: subject.yelp_id)
+ create(:gym, yelp_id: subject.yelp_id)
expect(subject.duplicate?).to be_truthy
end