From 2dbf16eeb2c3e4aeaee4eea202489d8a72c16839 Mon Sep 17 00:00:00 2001 From: Mac Siri Date: Tue, 28 Aug 2018 17:37:29 -0400 Subject: [PATCH] Expand README's setup steps (#520) * Remove duplicate key * Improve test specs * Update README --- README.md | 1 + app/liquid_tags/gist_tag.rb | 2 +- db/seeds.rb | 4 ---- docs/installation/linux.md | 2 +- docs/installation/mac-os.md | 2 ++ spec/liquid_tags/gist_tag_spec.rb | 13 ++++++++++--- 6 files changed, 15 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index cfa8e40f4..5a6dccbfe 100644 --- a/README.md +++ b/README.md @@ -171,6 +171,7 @@ This section provides a high-level requirement & quick start guide. For detailed * If you are missing `ENV` variables on bootup, `envied` gem will alert you with messages similar to `'error_on_missing_variables!': The following environment variables should be set: A_MISSING_KEY.`. * You do not need "real" keys for basic development. Some features require certain keys, so you may be able to add them as you go. 1. Run `bin/setup` +1. That's it! Run `bin/startup` to start the application and head to `http://localhost:3000/` #### Starting the application diff --git a/app/liquid_tags/gist_tag.rb b/app/liquid_tags/gist_tag.rb index df8f992a1..406033e30 100644 --- a/app/liquid_tags/gist_tag.rb +++ b/app/liquid_tags/gist_tag.rb @@ -37,7 +37,7 @@ class GistTag < LiquidTagBase end def valid_link?(link) - (link =~ /(http|https):\/\/(gist.github.com).*/)&.zero? + (link =~ /^(http(s)?:)?\/\/(gist.github.com)\/.*/)&.zero? end end diff --git a/db/seeds.rb b/db/seeds.rb index 654ad1955..ed6ca10bb 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -125,7 +125,6 @@ podcast_objects = [ title: "CodingBlocks", description: "", feed_url: "http://feeds.podtrac.com/c8yBGHRafqhz", - image: Faker::Avatar.image, slug: "codingblocks", twitter_username: "CodingBlocks", website_url: "http://codingblocks.net", @@ -138,7 +137,6 @@ podcast_objects = [ title: "Talk Python", description: "", feed_url: "https://talkpython.fm/episodes/rss", - image: Faker::Avatar.image, slug: "talkpython", twitter_username: "TalkPython", website_url: "https://talkpython.fm", @@ -152,7 +150,6 @@ podcast_objects = [ description: "", feed_url: "http://developeronfire.com/rss.xml", itunes_url: "https://itunes.apple.com/us/podcast/developer-on-fire/id1006105326", # rubocop:disable Metrics/LineLength - image: Faker::Avatar.image, slug: "developeronfire", twitter_username: "raelyard", website_url: "http://developeronfire.com", @@ -166,7 +163,6 @@ podcast_objects = [ description: "", feed_url: "https://building.fireside.fm/rss", itunes_url: "https://itunes.apple.com/us/podcast/building-programmers/id1149043456", # rubocop:disable Metrics/LineLength - image: Faker::Avatar.image, slug: "buildingprogrammers", twitter_username: "run_kmc", website_url: "https://building.fireside.fm", diff --git a/docs/installation/linux.md b/docs/installation/linux.md index 0b3d1ba56..3706bd8ba 100644 --- a/docs/installation/linux.md +++ b/docs/installation/linux.md @@ -21,7 +21,7 @@ There are two ways to install Yarn. 1. run `sudo apt update && sudo apt install postgresql postgresql-contrib libpq-dev`. 2. To test the installation you can run `sudo -u postgres psql` which should open a PostgreSQL prompt. Exit the prompt by running `\q` then run `sudo -u postgres createuser -s $YOUR_USERNAME` where $YOUR_USERNAME is the username you are currently logged in as. Lastly, at least on Debian based systems, in the codebase under /config/database.yml you'll want to comment out the `host: localhost` to configure the database to use Unix domain sockets as outlined [here](https://stackoverflow.com/questions/23375740/pgconnectionbad-fe-sendauth-no-password-supplied). -Check out the official [PostgreSQL](https://www.postgresql.org/) site for more information. +There are more than one way to setup Postgres. For additional configuration, check out our [postgres doc](/additional-postgres-setup) or the official [PostgreSQL](https://www.postgresql.org/) site for more information. ## Installing Dev.to diff --git a/docs/installation/mac-os.md b/docs/installation/mac-os.md index 78be10d97..d20620aa5 100644 --- a/docs/installation/mac-os.md +++ b/docs/installation/mac-os.md @@ -13,6 +13,8 @@ Please refer to their [installation guide](https://yarnpkg.com/en/docs/install). Dev.to requires PostgreSQL version 9.4 or higher. The easiest way to get started is to use [Postgres.app](https://postgresapp.com/). Alternatively, check out the official [PostgreSQL](https://www.postgresql.org/) site for more granular version. +For additional configuration, [click here](/additional-postgres-setup) + ## Installing Dev.to 1. Fork dev.to repository, ie. https://github.com/thepracticaldev/dev.to/fork diff --git a/spec/liquid_tags/gist_tag_spec.rb b/spec/liquid_tags/gist_tag_spec.rb index 3bcac191a..ab0d4630c 100644 --- a/spec/liquid_tags/gist_tag_spec.rb +++ b/spec/liquid_tags/gist_tag_spec.rb @@ -3,6 +3,13 @@ require "rails_helper" RSpec.describe GistTag, type: :liquid_template do describe "#link" do let(:gist_link) { "https://gist.github.com/vaidehijoshi/6536e03b81e93a78c56537117791c3f1" } + let(:bad_links) do + [ + "//pastebin.com/raw/b77FrXUA#gist.github.com", + "https://gist.github.com@evil.com", + "https://gist.github.com.evil.com", + ] + end def generate_new_liquid(link) Liquid::Template.register_tag("gist", GistTag) @@ -30,9 +37,9 @@ RSpec.describe GistTag, type: :liquid_template do end it "rejects XSS attempts" do - expect do - generate_new_liquid("//pastebin.com/raw/b77FrXUA#gist.github.com") - end.to raise_error(StandardError) + bad_links.each do |link| + expect { generate_new_liquid(link) } .to raise_error(StandardError) + end end end end