-
Notifications
You must be signed in to change notification settings - Fork 206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new tests for models #610
Changes from all commits
cfafdcf
162ef37
e0c305b
f2510de
ca68997
0ca6dec
5d14d23
0c69df6
1d78bb4
cc84b28
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,29 +32,15 @@ class Map < ActiveRecord::Base | |
has_many :annotations, dependent: :destroy | ||
belongs_to :user | ||
|
||
has_many :warpables | ||
scope :active, -> { where(archived: false) } | ||
scope :has_user, -> { where('user_id != ?', 0) } | ||
|
||
has_many :warpables do | ||
def public_filenames | ||
filenames = {} | ||
each do |warpable| | ||
filenames[warpable.id] = {} | ||
sizes = Array.new(Warpable::THUMBNAILS.keys).push(nil) | ||
sizes.each do |size| | ||
key = !size.nil? ? size : "original" | ||
filenames[warpable.id][key] = warpable.public_filename(size) | ||
end | ||
end | ||
filenames | ||
end | ||
end | ||
|
||
def validate | ||
lat >= -90 && lat <= 90 && lon >= -180 && lat <= 180 if name != 'untitled' | ||
end | ||
|
||
# Hash the password before saving the record | ||
# Hash the password before saving the record. | ||
def before_create | ||
self.password = Password.update(password) if password != "" | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is supposed to Hash the password but There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Password needs to be encrypted with one way hash functions. This should be problem as per theory There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jywarren Map passwords are not being hashed. They're stored in plain text. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is quite an old feature, but the problem is that we may have existing maps that use it. Can we confirm that there is no way to /make/ a new passworded map? |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,21 @@ | ||
require 'test_helper' | ||
|
||
class ExportTest < ActiveSupport::TestCase | ||
test "count methods" do | ||
test 'should count methods' do | ||
average = Export.all.map(&:cm_per_pixel).sum/Export.count | ||
assert_not_nil Export.average_cm_per_pixel | ||
assert_equal average, Export.average_cm_per_pixel | ||
assert_not_nil Export.histogram_cm_per_pixel | ||
assert_not_nil Export.histogram_cm_per_pixel_in_tens | ||
assert_not_nil Export.export_count | ||
assert_not_nil Export.exporting | ||
|
||
Export.delete_all | ||
assert_empty Export.histogram_cm_per_pixel | ||
assert_equal 0, Export.average_cm_per_pixel | ||
end | ||
|
||
test "export running" do | ||
test 'should export running' do | ||
assert !Export.last.running? | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,4 @@ | ||
require 'test_helper' | ||
|
||
class NodeTest < ActiveSupport::TestCase | ||
# Replace this with your real tests. | ||
test "the truth" do | ||
assert true | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've removed this method since it is not being used anywhere else.
Here is the relevent commit aadd8b5
I couldn't find
public_filenames
being called in the current code.