Commit 05ad922f3648654bc2b055ce1aa5476134899454
1 parent
5e696f3e
Exists in
web_steps_improvements
and in
8 other branches
fix unit test and refatoring get environment enpoint
Showing
2 changed files
with
6 additions
and
9 deletions
Show diff stats
lib/noosfero/api/v1/environments.rb
@@ -10,17 +10,13 @@ module Noosfero | @@ -10,17 +10,13 @@ module Noosfero | ||
10 | present environment.signup_person_fields | 10 | present environment.signup_person_fields |
11 | end | 11 | end |
12 | 12 | ||
13 | - # Returns the given environment | ||
14 | get ':id' do | 13 | get ':id' do |
15 | - id = params[:id] | ||
16 | - if (id == "default") | 14 | + if (params[:id] == "default") |
17 | present Environment.default | 15 | present Environment.default |
16 | + elsif (params[:id] == "context") | ||
17 | + present environment | ||
18 | else | 18 | else |
19 | - if (id == "context") | ||
20 | - present Environment.find_by_name(request.host) | ||
21 | - else | ||
22 | - present Environment.find(params[:id]) | ||
23 | - end | 19 | + present Environment.find(params[:id]) |
24 | end | 20 | end |
25 | end | 21 | end |
26 | 22 |
test/unit/api/environment_test.rb
@@ -25,8 +25,9 @@ class SearchTest < ActiveSupport::TestCase | @@ -25,8 +25,9 @@ class SearchTest < ActiveSupport::TestCase | ||
25 | 25 | ||
26 | should 'return context environment' do | 26 | should 'return context environment' do |
27 | context_env = fast_create(Environment) | 27 | context_env = fast_create(Environment) |
28 | - context_env.name = "example.org" | 28 | + context_env.name = "example org" |
29 | context_env.save | 29 | context_env.save |
30 | + context_env.domains<< Domain.new(:name => 'example.org') | ||
30 | default_env = Environment.default | 31 | default_env = Environment.default |
31 | assert_not_equal context_env.id, default_env.id | 32 | assert_not_equal context_env.id, default_env.id |
32 | get "/api/v1/environment/context" | 33 | get "/api/v1/environment/context" |