Skip to content

Commit

Permalink
🤖
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdawkins committed Jan 21, 2019
1 parent 12e8c0a commit b90af40
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 38 deletions.
2 changes: 1 addition & 1 deletion app/controllers/adam/articles_controller.rb
Expand Up @@ -30,7 +30,7 @@ def publish
end

private

def set_article
@article = Article.find(params[:id])
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/adam/notes_controller.rb
Expand Up @@ -31,7 +31,7 @@ def publish
end

private

def set_note
@note = Note.find(params[:id])
end
Expand Down
16 changes: 11 additions & 5 deletions app/controllers/sessions_controller.rb
Expand Up @@ -3,13 +3,19 @@ def new
end

def create
if params[:password] === Rails.application.credentials.adam[:password]
session[:logged_in] = Rails.application.credentials.adam[:username]
redirect_path = session[:pre_auth_path] || root_url
redirect_to redirect_path
login
if logged_in?
redirect_to session[:pre_auth_path] || root_url
else
render :new, notice: "Wrong!"
end

end

private

def login
if params[:password] === Rails.application.credentials.adam[:password]
session[:logged_in] = Rails.application.credentials.adam[:username]
end
end
end
2 changes: 1 addition & 1 deletion app/helpers/sessions_helper.rb
@@ -1,5 +1,5 @@
module SessionsHelper
def logged_in?
session[:logged_in] == Rails.application.credentials.adam[:username]
session[:logged_in] == Rails.application.credentials.adam[:username]
end
end
2 changes: 1 addition & 1 deletion app/models/post.rb
Expand Up @@ -11,7 +11,7 @@ def validate(record)
class Post < ApplicationRecord
validates_presence_of :content
validates_with SlugValidator

has_many :syndicates

before_validation :generate_slug
Expand Down
2 changes: 1 addition & 1 deletion app/services/twitter_service.rb
Expand Up @@ -6,7 +6,7 @@
end

class TwitterService
def self.post(post)
def self.post(post)
tweet = post.content
tweet.gsub!('*', '*')
response = TwitterClient.update(tweet)
Expand Down
5 changes: 0 additions & 5 deletions spec/controllers/adam_controller_spec.rb

This file was deleted.

5 changes: 0 additions & 5 deletions spec/controllers/posts_controller_spec.rb

This file was deleted.

5 changes: 0 additions & 5 deletions spec/controllers/sessions_controller_spec.rb

This file was deleted.

5 changes: 0 additions & 5 deletions spec/controllers/short_domains_controller_spec.rb

This file was deleted.

4 changes: 2 additions & 2 deletions spec/factories/posts.rb
Expand Up @@ -2,8 +2,8 @@
factory :post do
content { "Text" }
type { Note }
trait :published do
published_at { Time.now }
trait :published do
published_at { Time.now }
end
end
end
12 changes: 6 additions & 6 deletions spec/models/post_spec.rb
Expand Up @@ -5,7 +5,7 @@
it { is_expected.to validate_presence_of :content }
# We're getting round this by actually looping through the stack of candidates
# describe "slug validation" do
# before do
# before do
# create(:post, published_at: 1.day.ago, slug: "the-same-slug")
# end
# it "requires slugs to be unique for posts on the same day" do
Expand Down Expand Up @@ -56,12 +56,12 @@
expect(post.slug).to eq "slug-2"
end

it "cleans the slug" do
post = create(:post, slug: "slug")
post.update(slug: "slug 2")
it "cleans the slug" do
post = create(:post, slug: "slug")
post.update(slug: "slug 2")

expect(post.slug).to eq "slug-2"
end
expect(post.slug).to eq "slug-2"
end
end

context "when the slug hasn't changed, but other attributes have" do
Expand Down

0 comments on commit b90af40

Please sign in to comment.