CodeMontageHQ/codemontage

Add URL Validation

Opened this issue · 1 comments

Description
URLs are stored, displayed, and linked to for Organizations and for individual Projects. They're entered into the database primarily in Admin by admin users, but also created through the public project submission form. It would be great to test their validity before rendering links (and ideally before saving to the database at all).

Ask
Add validation logic and test to verify stored :url on both the Organization and Project models.

To Do

  • Add validation logic and test to verify Organization#url
  • Add validaiton logic and test to verify Project#url

Additional Info
Sample test code from #226 (Measure and Improve Test Coverage), though this may change if you decide to validate in the models themselves.

      it "returns an empty string if its url is invalid" do
        organization.stub(url: "random thing")
        expect(organization.display_url).to eq(nil)
      end

Possible suggestion (also quite possibly overkill): https://gist.github.com/johnjohndoe/7022109