Refactor maintainer-db spec and model
This commit is contained in:
parent
028e511409
commit
a4b03b53ce
|
@ -10,7 +10,7 @@ class BuildList::Package < ActiveRecord::Base
|
|||
validates :build_list_id, :project_id, :platform_id, :fullname, :package_type, :name, :release, :version, :presence => true
|
||||
validates :package_type, :inclusion => PACKAGE_TYPES
|
||||
|
||||
# This selects only the latest record for each (platform, project) pair (by 'latest' we mean it, i.e. the greatest created_at).
|
||||
# This selects only the latest record for each (platform, "package") pair (by 'latest' we mean it, i.e. the greatest created_at). The "package" is identified by its name and type.
|
||||
# We select the latest created_at-s, and join the table with itself.
|
||||
scope :maintainers, joins('join(
|
||||
select name as j_pn, package_type as j_pt, platform_id as j_plid, max(created_at) as j_ca
|
||||
|
@ -18,7 +18,7 @@ class BuildList::Package < ActiveRecord::Base
|
|||
group by j_pn, j_pt, j_plid
|
||||
) lastmaints
|
||||
on j_pn = name and j_pt = package_type and j_plid = platform_id and j_ca = created_at'
|
||||
).where('created_at = j_ca')
|
||||
)
|
||||
|
||||
def assignee
|
||||
project.owner.assignee
|
||||
|
|
|
@ -3,13 +3,13 @@ require 'spec_helper'
|
|||
|
||||
shared_examples_for 'guest user' do
|
||||
before(:each) do
|
||||
if APP_CONFIG['anonymous_access']
|
||||
else
|
||||
unless APP_CONFIG['anonymous_access']
|
||||
@user = FactoryGirl.create(:user)
|
||||
set_session_for(@user)
|
||||
end
|
||||
end
|
||||
|
||||
# Only one action for now here
|
||||
[:index].each do |action|
|
||||
it "should be able to perform #{ action } action" do
|
||||
get action, :platform_id => @platform.id
|
||||
|
@ -33,7 +33,6 @@ describe Platforms::MaintainersController do
|
|||
|
||||
it 'should not be able to get api' do
|
||||
get :assignee, @assignee_rq
|
||||
puts response.headers.inspect
|
||||
response.response_code.should equal(403)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue