Skip to content

Commit

Permalink
If a user can't be created, use the API user
Browse files Browse the repository at this point in the history
  • Loading branch information
pezholio committed Sep 12, 2014
1 parent cdb065e commit 82ce8f6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
8 changes: 3 additions & 5 deletions app/models/certificate_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,17 +109,15 @@ def generate(create_user = false)

response_set.autocomplete(request_dataset["documentationUrl"])

user = self.user

if response_set.kitten_data && create_user === true
email = response_set.kitten_data[:data][:publishers].first[:mbox] rescue nil
if email
user = User.find_or_create_by_email(email) do |user|
user.password = SecureRandom.base64
end
else
user = User.find(ENV['ODC_ADMIN_IDS'].split(",").first)
end
else
user = self.user
end
end

response_set.dataset.update_attribute(:user, user)
Expand Down
2 changes: 0 additions & 2 deletions features/support/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,5 @@ def load_fixture(file)
end

Before do
user = User.create(email: "admin@example.com", password: "12345678")
ENV['ODC_ADMIN_IDS'] = user.id.to_s
FactoryGirl.create(:survey, full_title:'UnitedKingdam', title:'GB', access_code: 'GB', survey_version: 1)
end

0 comments on commit 82ce8f6

Please sign in to comment.