Skip to content

Commit

Permalink
Merge pull request #1939 from bgeuken/things_for_rails5
Browse files Browse the repository at this point in the history
Things needed to be fixed for rails5
  • Loading branch information
hennevogel committed Jul 18, 2016
2 parents ad07bbf + 2897642 commit f3dcea0
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 45 deletions.
4 changes: 2 additions & 2 deletions src/api/Rakefile
@@ -1,8 +1,8 @@
#!/usr/bin/env rake2.2
#!/usr/bin/env rake2.3
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require File.expand_path('../config/application', __FILE__)
require_relative 'config/application'

OBSApi::Application.load_tasks

Expand Down
71 changes: 35 additions & 36 deletions src/api/app/controllers/application_controller.rb
Expand Up @@ -239,42 +239,6 @@ def add_api_version
response.headers["X-Opensuse-APIVersion"] = "#{CONFIG['version']}"
end

hide_action :forward_from_backend
def forward_from_backend(path)
# apache & mod_xforward case
if CONFIG['use_xforward'] and CONFIG['use_xforward'] != "false"
logger.debug "[backend] VOLLEY(mod_xforward): #{path}"
headers['X-Forward'] = "http://#{CONFIG['source_host']}:#{CONFIG['source_port']}#{path}"
headers['Cache-Control'] = 'no-transform' # avoid compression
head(200)
@skip_validation = true
return true
end

# lighttpd 1.5 case
if CONFIG['x_rewrite_host']
logger.debug "[backend] VOLLEY(lighttpd): #{path}"
headers['X-Rewrite-URI'] = path
headers['X-Rewrite-Host'] = CONFIG['x_rewrite_host']
headers['Cache-Control'] = 'no-transform' # avoid compression
head(200)
@skip_validation = true
return true
end

# nginx case
if CONFIG['use_nginx_redirect']
logger.debug "[backend] VOLLEY(nginx): #{path}"
headers['X-Accel-Redirect'] = "#{CONFIG['use_nginx_redirect']}/http/#{CONFIG['source_host']}:#{CONFIG['source_port']}#{path}"
headers['Cache-Control'] = 'no-transform' # avoid compression
head(200)
@skip_validation = true
return true
end

false
end

def volley_backend_path(path)
logger.debug "[backend] VOLLEY: #{path}"
Suse::Backend.start_test_backend
Expand Down Expand Up @@ -607,6 +571,41 @@ def validate_xml_response

private

def forward_from_backend(path)
# apache & mod_xforward case
if CONFIG['use_xforward'] and CONFIG['use_xforward'] != "false"
logger.debug "[backend] VOLLEY(mod_xforward): #{path}"
headers['X-Forward'] = "http://#{CONFIG['source_host']}:#{CONFIG['source_port']}#{path}"
headers['Cache-Control'] = 'no-transform' # avoid compression
head(200)
@skip_validation = true
return true
end

# lighttpd 1.5 case
if CONFIG['x_rewrite_host']
logger.debug "[backend] VOLLEY(lighttpd): #{path}"
headers['X-Rewrite-URI'] = path
headers['X-Rewrite-Host'] = CONFIG['x_rewrite_host']
headers['Cache-Control'] = 'no-transform' # avoid compression
head(200)
@skip_validation = true
return true
end

# nginx case
if CONFIG['use_nginx_redirect']
logger.debug "[backend] VOLLEY(nginx): #{path}"
headers['X-Accel-Redirect'] = "#{CONFIG['use_nginx_redirect']}/http/#{CONFIG['source_host']}:#{CONFIG['source_port']}#{path}"
headers['Cache-Control'] = 'no-transform' # avoid compression
head(200)
@skip_validation = true
return true
end

false
end

def shutup_rails
Rails.cache.silence! unless Rails.env.development?
end
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/models/bs_request.rb
Expand Up @@ -57,7 +57,7 @@ class SaveError < APIException

after_update :send_state_change

def save!
def save!(args = {})
new = self.created_at ? nil : 1
sanitize! if new and not @skip_sanitize
super
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/models/project.rb
Expand Up @@ -1155,7 +1155,7 @@ def expand_all_packages(packages = [], project_map = {}, package_map = {})
# this function is making the products uniq
def expand_all_products
p_map = Hash.new
products = Product.joins(:package).where("packages.project_id = ? and packages.name = '_product'", self.id)
products = Product.joins(:package).where("packages.project_id = ? and packages.name = '_product'", self.id).to_a
products.each { |p| p_map[p.cpe] = 1 } # existing packages map
# second path, all packages from indirect linked projects
self.linking_to.each do |lp|
Expand Down
6 changes: 3 additions & 3 deletions src/api/test/fixtures/history_elements.yml
Expand Up @@ -2,16 +2,16 @@ record_0:
op_object_id: 9994
type: HistoryElement::RequestCreated
comment: one group review
user_id: <%= ActiveRecord::Fixtures.identify(:Iggy) %>
user_id: <%= ActiveRecord::FixtureSet.identify(:Iggy) %>
created_at: 2012-09-28 11:56:53.000000000 Z
record_1:
op_object_id: 9994
type: HistoryElement::RequestCreated
comment: see if users can review
user_id: <%= ActiveRecord::Fixtures.identify(:Iggy) %>
user_id: <%= ActiveRecord::FixtureSet.identify(:Iggy) %>
created_at: 2012-09-28 11:56:46.000000000 Z
record_2:
op_object_id: 9994
type: HistoryElement::RequestAllReviewsApproved
user_id: <%= ActiveRecord::Fixtures.identify(:Iggy) %>
user_id: <%= ActiveRecord::FixtureSet.identify(:Iggy) %>
created_at: 2012-09-28 11:55:19.000000000 Z
2 changes: 1 addition & 1 deletion src/api/test/functional/issue_trackers_controller_test.rb
Expand Up @@ -10,7 +10,7 @@ def test_should_get_index
login_king
get '/issue_trackers'
assert_response :success
assert_not_nil assigns(:issue_trackers)
assert_select "issue-tracker", 24
end

def test_create_and_update_new_trackers
Expand Down
4 changes: 3 additions & 1 deletion src/api/test/functional/status_controller_test.rb
Expand Up @@ -105,7 +105,9 @@ def test_history
end

get "/status/history?hours=5&samples=10&key=idle_i586"
assert_not_nil assigns(@samples)
assert_select "history" do
assert_select "value", 0
end
end
end
end

0 comments on commit f3dcea0

Please sign in to comment.