forked from sass/sassc-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request sass#14 from RailsRepos/ACT-437
Act-437: add model and migrations for go_links links
- Loading branch information
Showing
22 changed files
with
183 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ tmp/ | |
node_modules/ | ||
*bundle.js | ||
npm-debug.log | ||
config/secrets.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--color | ||
--require spec_helper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,8 @@ gem 'sass-rails', '~> 5.0' | |
gem 'httparty', '0.13.7' | ||
gem 'exception_notification', '~> 4.1' | ||
gem 'rails_logger', git: '[email protected]:RailsRepos/rails_logger.git' | ||
gem 'mysql2', '~> 0.4' | ||
gem 'validate_url', '~> 1.0' | ||
|
||
group :development, :test do | ||
gem 'capybara' | ||
|
@@ -27,7 +29,9 @@ group :development, :test do | |
gem 'awesome_print' | ||
gem 'passenger', '~> 5.0' | ||
end | ||
|
||
group :test do | ||
gem 'rspec-rails' | ||
gem 'rack_session_access', '~> 0.1.1' | ||
gem 'selenium-webdriver' | ||
gem 'shoulda' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class Link < ActiveRecord::Base | ||
validates :url, url: true | ||
validates :alias, uniqueness: true | ||
before_save :change_alias_underscores_to_dashes | ||
|
||
private | ||
|
||
def change_alias_underscores_to_dashes | ||
self.alias.gsub!("_", "-") | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
production: | ||
database: go_links_db | ||
username: go_links_user | ||
password: "<%= Rails.application.secrets.go_links_user_password %>" | ||
host: apex-dbs.liveramp.net | ||
encoding: utf8 | ||
reconnect: 'true' | ||
adapter: mysql2 | ||
retries: 0 | ||
pool: 5 | ||
reaping_frequency: 60 | ||
wait_timeout: 28800 | ||
development: | ||
adapter: mysql2 | ||
username: root | ||
password: | ||
database: go_links_local_db | ||
host: localhost | ||
encoding: utf8 | ||
reconnect: true | ||
test: | ||
adapter: mysql2 | ||
username: root | ||
password: | ||
host: localhost | ||
database: go_links_test_db | ||
encoding: utf8 | ||
reconnect: true |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class CreateLinks < ActiveRecord::Migration[5.0] | ||
def change | ||
create_table :links do |t| | ||
t.string :alias, null: false | ||
t.string :url, null: false | ||
t.string :owner, null: false | ||
t.text :description | ||
t.timestamps | ||
|
||
t.index :alias, unique: true | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# This file is auto-generated from the current state of the database. Instead | ||
# of editing this file, please use the migrations feature of Active Record to | ||
# incrementally modify your database, and then regenerate this schema definition. | ||
# | ||
# Note that this schema.rb definition is the authoritative source for your | ||
# database schema. If you need to create the application database on another | ||
# system, you should be using db:schema:load, not running all the migrations | ||
# from scratch. The latter is a flawed and unsustainable approach (the more migrations | ||
# you'll amass, the slower it'll run and the greater likelihood for issues). | ||
# | ||
# It's strongly recommended that you check this file into your version control system. | ||
|
||
ActiveRecord::Schema.define(version: 20180821101102) do | ||
|
||
create_table "links", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t| | ||
t.string "alias", null: false | ||
t.string "url", null: false | ||
t.string "owner", null: false | ||
t.text "description", limit: 65535 | ||
t.datetime "created_at", null: false | ||
t.datetime "updated_at", null: false | ||
t.index ["alias"], name: "index_links_on_alias", unique: true, using: :btree | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
describe Link do | ||
context "validation" do | ||
let(:link) { FactoryGirl.build(:link) } | ||
|
||
it "does not allow invalid urls" do | ||
[ | ||
"foo.net", | ||
"www.foo.com", | ||
"foo.biz", | ||
"", | ||
"a_word", | ||
"http://a space.com", | ||
nil | ||
].each do |url| | ||
link.url = url | ||
expect(link).not_to be_valid | ||
end | ||
end | ||
|
||
it "allows non-local urls" do | ||
[ | ||
"http://foo.com", | ||
"https://foo.biz", | ||
"http://www.foo.net", | ||
"https://www.foo.com", | ||
].each do |url| | ||
link.url = url | ||
expect(link).to be_valid | ||
end | ||
end | ||
|
||
it "allows local urls" do | ||
[ | ||
"http://foo", | ||
"https://foo", | ||
].each do |url| | ||
link.url = url | ||
expect(link).to be_valid | ||
end | ||
end | ||
end | ||
|
||
it "replaces underscores with dashes" do | ||
expect( | ||
FactoryGirl.create(:link, alias: "foo_bar").alias | ||
).to eq "foo-bar" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FactoryGirl.define do | ||
factory :link do | ||
created_at Time.now | ||
updated_at Time.now | ||
sequence(:owner) { |i| "owner_#{i}" } | ||
sequence(:url) { |i| "http://url_#{i}.com" } | ||
sequence(:alias) { |i| "alias-#{i}" } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# This file is copied to spec/ when you run 'rails generate rspec:install' | ||
ENV["RAILS_ENV"] ||= 'test' | ||
require File.expand_path("../../config/environment", __FILE__) | ||
require 'rspec/rails' | ||
|
||
RSpec.configure do |config| | ||
config.expect_with :rspec do |expectations| | ||
expectations.include_chain_clauses_in_custom_matcher_descriptions = true | ||
end | ||
|
||
config.mock_with :rspec do |mocks| | ||
mocks.verify_partial_doubles = true | ||
end | ||
end |
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
This file was deleted.
Oops, something went wrong.