Skip to content
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

Merged
merged 10 commits into from
Jun 3, 2019
Merged

Add new tests for models #610

merged 10 commits into from
Jun 3, 2019

Conversation

kaustubh-nair
Copy link
Member

Part of #594

Make sure these boxes are checked before your pull request (PR) is ready to be reviewed and merged. Thanks!

  • PR is descriptively titled 📑 and links the original issue above 🔗
  • tests pass -- look for a green checkbox ✔️ a few minutes after opening your PR -- or run tests locally with rake test
  • code is in uniquely-named feature branch and has no merge conflicts 📁
  • screenshots/GIFs are attached 📎 in case of UI updation
  • ask @publiclab/reviewers for help, in a comment below

We're happy to help you get this ready -- don't be afraid to ask for help, and don't be discouraged if your tests fail at first!

If tests do fail, click on the red X to learn why by reading the logs.

Please be sure you've reviewed our contribution guidelines at https://publiclab.org/contributing-to-public-lab-software

Thanks!

app/models/map.rb Outdated Show resolved Hide resolved
test/unit/map_test.rb Outdated Show resolved Hide resolved
test/unit/map_test.rb Outdated Show resolved Hide resolved
test/unit/warpable_test.rb Outdated Show resolved Hide resolved
@codeclimate
Copy link

codeclimate bot commented May 15, 2019

Code Climate has analyzed commit e0c305b and detected 6 issues on this pull request.

Here's the issue category breakdown:

Category Count
Style 5
Complexity 1

View more on Code Climate.

end
filenames
end
end
Copy link
Member Author

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.


def validate
self.name != 'untitled'
self.lat >= -90 && self.lat <= 90 && self.lon >= -180 && self.lat <= 180
end

# Hash the password before saving the record
#Hash the password before saving the record
def before_create
self.password = Password::update(self.password) if self.password != ""
end
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is supposed to Hash the password but before_create is never called????
Map passwords are stored in plain text???
Is this okay???

Copy link
Member

Choose a reason for hiding this comment

The 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

Copy link
Member Author

Choose a reason for hiding this comment

The 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.
Security concern?

Copy link
Member

Choose a reason for hiding this comment

The 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?

def bbox=(bbox)
# counting from left, counter-clockwise
self.lon1,self.lat2,self.lon2,self.lat1 = bbox
end
end
Copy link
Member Author

@kaustubh-nair kaustubh-nair May 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is redundant too.
What is the Way model supposed to do anyway?
It is not being used anywhere

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it may be used in annotations, but am not sure! Can you look at the annotations interface which may be a bit broken?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But we could address this in another issue later. You could also look at the commits around that time using the history or blame view - see? Yes, this is VERY old! And, i think, can go!

https://github.com/publiclab/mapknitter/blame/e0c305b89a53828006f20de422da2bbffb53a21b/app/models/way.rb

@codecov
Copy link

codecov bot commented May 15, 2019

Codecov Report

Merging #610 into main will increase coverage by 0.25%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##            main     #610      +/-   ##
=========================================
+ Coverage   41.1%   41.36%   +0.25%     
=========================================
  Files         34       34              
  Lines       1321     1308      -13     
=========================================
- Hits         543      541       -2     
+ Misses       778      767      -11
Impacted Files Coverage Δ
app/models/user.rb 75% <ø> (+6.25%) ⬆️
app/models/map.rb 39% <100%> (+1.67%) ⬆️

@kaustubh-nair
Copy link
Member Author

@jywarren @sashadev-sky @SidharthBansal @cesswairimu @alaxalves
I've removed some redundant code which was not being used anywhere.
Please check them out.
Coverage for models is at 95% now 🎈 🎈


def validate
self.name != 'untitled'
self.lat >= -90 && self.lat <= 90 && self.lon >= -180 && self.lat <= 180
end

# Hash the password before saving the record
#Hash the password before saving the record
def before_create
self.password = Password::update(self.password) if self.password != ""
end
Copy link
Member

Choose a reason for hiding this comment

The 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

app/models/user.rb Show resolved Hide resolved
test/unit/map_test.rb Outdated Show resolved Hide resolved
@cesswairimu
Copy link
Collaborator

Awesome!

@jywarren
Copy link
Member

jywarren commented May 22, 2019 via email

@kaustubh-nair
Copy link
Member Author

kaustubh-nair commented May 27, 2019

Yes, I think so. But gosh this is old. Do we even allow people to make passworded maps anymore?

Oh yeah, I did not notice that.
Let's not change any password code here and create a new issue to discuss this. ( #641)

@kaustubh-nair
Copy link
Member Author

kaustubh-nair commented May 27, 2019

Also, @publiclab/mapknitter-reviewers @jywarren this is ready for merge!

.rubocop.yml Outdated
@@ -0,0 +1,2 @@
Metrics/BlockLength:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -17,6 +17,16 @@ def setup
end

test 'geometry type' do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I wait for these last couple things before merging? Thanks!!!!

@alaxalves
Copy link
Member

alaxalves commented May 31, 2019

BTW @kaustubh-nair I could work on this one and you could work on #615. What do you think? There are only small patches left for both. Let's get those merged today 💪 💪 💪 💪

@kaustubh-nair
Copy link
Member Author

BTW @kaustubh-nair I could work on this one and you could work on #615. What do you think? There are only small patched left for both. Let's get those merged today muscle muscle muscle muscle

@alaxalves Awesome go ahead
Thanks!

@alaxalves
Copy link
Member

BTW @kaustubh-nair I could work on this one and you could work on #615. What do you think? There are only small patched left for both. Let's get those merged today muscle muscle muscle muscle

@alaxalves Awesome go ahead
Thanks!

Done! @jywarren This is ready to merge

@alaxalves alaxalves force-pushed the model-tests branch 2 times, most recently from 75fa2f1 to 2507f16 Compare June 1, 2019 02:13
@jywarren
Copy link
Member

jywarren commented Jun 3, 2019

Hi! I believe this just needs a rebase - thank you!!!!

@jywarren
Copy link
Member

jywarren commented Jun 3, 2019

Perfect, thank you!!!!

@jywarren jywarren merged commit 03deef1 into main Jun 3, 2019
@alaxalves alaxalves deleted the model-tests branch June 3, 2019 19:12
chen-robert pushed a commit to chen-robert/mapknitter that referenced this pull request Dec 5, 2019
* Add annotation tests and remove redundant code

* Add export tests

* Remove some code

* Fix codeclimate issues

* Fix codeclimate issues

* Fix rubocop block length

* Removing rubocop cfg since publiclab#547 and renaming tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants