diff --git a/app/views/build_lists/_filter.html.haml b/app/views/build_lists/_filter.html.haml index 366754f79..3b6994cfe 100644 --- a/app/views/build_lists/_filter.html.haml +++ b/app/views/build_lists/_filter.html.haml @@ -37,7 +37,7 @@ .columns.wat-cf .column.left .group - = f.label :status, t("layout.build_lists.bs_id"), :class => :label + = f.label :status, t("layout.build_lists.bs_id_search"), :class => :label = f.text_field :bs_id, :class => :text_field .column.right .group diff --git a/config/environments/test.rb b/config/environments/test.rb index 27fdd7bed..8bff1dc49 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -35,4 +35,4 @@ Rosa::Application.configure do config.active_support.deprecation = :stderr end -require 'stub_xml_rpc' +require 'stub_xml_rpc' # TODO stub XML calls through stubbers diff --git a/config/locales/ru.yml b/config/locales/ru.yml index 3d3f379ad..3819d314f 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -279,7 +279,7 @@ ru: created_at_end: "Время постановки на сборку по:" notified_at_start: "Время последнего обновления от BS с:" notified_at_end: "Время последнего обновления от BS по:" - bs_id: 'Id в ядре' + bs_id_search: 'Поиск по Id' project_name: 'Название проекта' bs_id_not_set: Id еще не присвоен items_header: Элементы сборки diff --git a/lib/stub_xml_rpc.rb b/lib/stub_xml_rpc.rb index 1a5bb33aa..8f4ab315f 100644 --- a/lib/stub_xml_rpc.rb +++ b/lib/stub_xml_rpc.rb @@ -6,7 +6,6 @@ module XMLRPC case when args.first == 'get_status' {'client_count' => 1, 'count_new_task' => 2, 'count_build_task' => 3} - # raise Timeout::Error else; 0 end end diff --git a/spec/controllers/build_lists_controller_spec.rb b/spec/controllers/build_lists_controller_spec.rb index beb60af42..a8f00c9e5 100644 --- a/spec/controllers/build_lists_controller_spec.rb +++ b/spec/controllers/build_lists_controller_spec.rb @@ -2,8 +2,6 @@ require 'spec_helper' describe BuildListsController do context 'crud' do - # let(:build_list) { Factory(:build_list) } - context 'for guest' do it 'should not be able to perform all action' do get :all @@ -24,10 +22,37 @@ describe BuildListsController do before(:each) { set_session_for Factory(:admin) } it "should be able to perform all action without exception" do + any_instance_of(XMLRPC::Client) do |xml_rpc| + stub(xml_rpc).call do |args| + raise Timeout::Error + end + end get :all - assigns[:build_server_status].should == {} # TODO stub to isolate + assigns[:build_server_status].should == {} response.should be_success - end + end + end + end + + context 'filter' do + let(:build_list1) { Factory(:build_list_core) } + let(:build_list2) { Factory(:build_list_core) } + let(:build_list3) { Factory(:build_list_core) } + before(:each) { set_session_for Factory(:admin) } + + it 'should filter by bs_id' do + get :all, :filter => {:bs_id => build_list1.bs_id, :project_name => 'fdsfdf', :any_other_field => 'do not matter'} + assigns[:build_lists].should include(build_list1) + assigns[:build_lists].should_not include(build_list2) + assigns[:build_lists].should_not include(build_list3) + end + + it 'should filter by project_name' do + # Project.where(:id => build_list2.project.id).update_all(:name => 'project_name') + get :all, :filter => {:project_name => build_list2.project.name} + assigns[:build_lists].should_not include(build_list1) + assigns[:build_lists].should include(build_list2) + assigns[:build_lists].should_not include(build_list3) end end diff --git a/spec/factories/build_list_factory.rb b/spec/factories/build_list_factory.rb index 359610e28..a4e1aa39a 100644 --- a/spec/factories/build_list_factory.rb +++ b/spec/factories/build_list_factory.rb @@ -6,4 +6,8 @@ Factory.define(:build_list) do |p| p.project_version "1.0" p.build_requires true p.update_type 'security' -end \ No newline at end of file +end + +Factory.define(:build_list_core, :parent => :build_list) do |p| + p.bs_id { Factory.next(:integer) } +end