Skip to content

Commit

Permalink
ArticleAdapter liefert nun url der App zurück
Browse files Browse the repository at this point in the history
Goldencobra::ArticleAdapter.base_url liefert nun anhängig von den Goldencobra Settings einen String zurück
Der den sich aus „use_ssl“ und „url“ zusammensetzt (z.b.: „https://localhost:3000“)
  • Loading branch information
marcometz committed Feb 21, 2017
1 parent b5d71e1 commit 66ccd90
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 1 deletion.
10 changes: 10 additions & 0 deletions app/adapters/goldencobra/article_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ def find_by_id(article_id)
Goldencobra::Article.find_by_id(article_id)
end

def base_url
http = case Goldencobra::Setting.for_key("goldencobra.use_ssl")

This comment has been minimized.

Copy link
@5minpause

5minpause Feb 21, 2017

Contributor

Es erscheint mir sinnvoll, dafür den Goldencobra::Url Service zu nutzen: https://github.com/ikuseiGmbH/Goldencobra/blob/master/app/services/goldencobra/url.rb
Dann ist die Logik hier nicht unnötig dupliziert.

This comment has been minimized.

Copy link
@marcometz

marcometz Feb 21, 2017

Author Member

durchaus, den habe ich gesucht und nicht gefunden!

when "true"
"https://"
else
"http://"
end
[http, Goldencobra::Setting.for_key("goldencobra.url")].join
end

private

# return url to search for
Expand Down
2 changes: 2 additions & 0 deletions doc/versionhistory
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
V2.0.29 - 21.02.2017
- ArticleAdapter returns URL of current app
V2.0.28 - 15.02.2017
- Use downcase to sort article alphabetically
- Respect sort orders like "A a B b C c", "A a berlin Brisbane"
Expand Down
2 changes: 1 addition & 1 deletion lib/goldencobra/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Goldencobra
VERSION = "2.0.28"
VERSION = "2.0.29"
end
16 changes: 16 additions & 0 deletions test/dummy/spec/adapters/article_adapter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,22 @@
before do
Goldencobra::Setting.set_value_for_key("http://www.ikusei.de", "goldencobra.url")
end
describe "getting base url" do
it "should return an complete base url of the current app" do
Goldencobra::Setting.set_value_for_key("false", "goldencobra.use_ssl")
Goldencobra::Setting.set_value_for_key("localhost:3000", "goldencobra.url")
url = Goldencobra::ArticleAdapter.base_url
expect(url).to eq("http://localhost:3000")
end

it "should return an complete base url with https of the current app" do
Goldencobra::Setting.set_value_for_key("true", "goldencobra.use_ssl")
Goldencobra::Setting.set_value_for_key("localhost:3000", "goldencobra.url")
url = Goldencobra::ArticleAdapter.base_url
expect(url).to eq("https://localhost:3000")
end
end

describe "finding articles" do
context "by a given url" do
it "should find one article id" do
Expand Down

0 comments on commit 66ccd90

Please sign in to comment.