diff --git a/Gemfile.lock b/Gemfile.lock index a9ce522..b0ab3e2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - ProMotion (0.7.2) + ProMotion (0.7.3) GEM remote: https://rubygems.org/ diff --git a/lib/ProMotion/screens/_tables/_refreshable_table.rb b/lib/ProMotion/screens/_tables/_refreshable_table.rb index 2d3fbe0..ccf2a5a 100644 --- a/lib/ProMotion/screens/_tables/_refreshable_table.rb +++ b/lib/ProMotion/screens/_tables/_refreshable_table.rb @@ -14,6 +14,21 @@ module ProMotion end alias :makeRefreshable :make_refreshable + def start_refreshing + return unless @refresh_control + + @refresh_control.beginRefreshing + end + alias :begin_refreshing :start_refreshing + + def end_refreshing + return unless @refresh_control + + @refresh_control.attributedTitle = NSAttributedString.alloc.initWithString(sprintf(@updated_format, Time.now.strftime(@updated_time_format))) + @refresh_control.endRefreshing + end + alias :stop_refreshing :end_refreshing + ######### iOS methods, headless camel case ####### # UIRefreshControl Delegates @@ -26,17 +41,5 @@ module ProMotion end end - def start_refreshing - return unless @refresh_control - - @refresh_control.beginRefreshing - end - - def end_refreshing - return unless @refresh_control - - @refresh_control.attributedTitle = NSAttributedString.alloc.initWithString(sprintf(@updated_format, Time.now.strftime(@updated_time_format))) - @refresh_control.endRefreshing - end end end diff --git a/lib/ProMotion/screens/_tables/_searchable_table.rb b/lib/ProMotion/screens/_tables/_searchable_table.rb index 5a272cb..01f129e 100644 --- a/lib/ProMotion/screens/_tables/_searchable_table.rb +++ b/lib/ProMotion/screens/_tables/_searchable_table.rb @@ -49,6 +49,7 @@ module ProMotion @promotion_table_data.stop_searching @promotion_table_data_data = nil self.table_view.setScrollEnabled true + self.table_view.reloadData end def searchDisplayControllerWillBeginSearch(controller) diff --git a/spec/functional/func_searchable_table_spec.rb b/spec/functional/func_searchable_table_spec.rb new file mode 100644 index 0000000..96ece85 --- /dev/null +++ b/spec/functional/func_searchable_table_spec.rb @@ -0,0 +1,32 @@ +describe "Searchable table spec" do + tests TableScreenSearchable + + # Override controller to properly instantiate + def controller + @controller ||= TableScreenSearchable.new(nav_bar: true) + @controller.on_load + @controller.main_controller + end + + it "should be rotated in portrait mode" do + rotate_device to: :portrait, button: :bottom + true.should == true + end + + it "should show all 50 states" do + @controller.tableView(@controller.tableView, numberOfRowsInSection:0).should == 50 + end + + it "should allow searching for all the 'New' states" do + @controller.searchDisplayController(@controller, shouldReloadTableForSearchString:"New") + @controller.tableView(@controller.tableView, numberOfRowsInSection:0).should == 4 + end + + it "should allow ending searches" do + @controller.searchDisplayController(@controller, shouldReloadTableForSearchString:"North") + @controller.tableView(@controller.tableView, numberOfRowsInSection:0).should == 2 + @controller.searchDisplayControllerWillEndSearch(@controller) + @controller.tableView(@controller.tableView, numberOfRowsInSection:0).should == 50 + end + +end diff --git a/spec/helpers/table_screen_searchable.rb b/spec/helpers/table_screen_searchable.rb index c5644e9..249c5d2 100644 --- a/spec/helpers/table_screen_searchable.rb +++ b/spec/helpers/table_screen_searchable.rb @@ -1,5 +1,62 @@ class TableScreenSearchable < TestTableScreen searchable + + def table_data + @search_table_data ||= [{ + cells: [ + { title: "Alabama" }, + { title: "Alaska" }, + { title: "Arizona" }, + { title: "Arkansas" }, + { title: "California" }, + { title: "Colorado" }, + { title: "Connecticut" }, + { title: "Delaware" }, + { title: "Florida" }, + { title: "Georgia" }, + { title: "Hawaii" }, + { title: "Idaho" }, + { title: "Illinois" }, + { title: "Indiana" }, + { title: "Iowa" }, + { title: "Kansas" }, + { title: "Kentucky" }, + { title: "Louisiana" }, + { title: "Maine" }, + { title: "Maryland" }, + { title: "Massachusetts" }, + { title: "Michigan" }, + { title: "Minnesota" }, + { title: "Mississippi" }, + { title: "Missouri" }, + { title: "Montana" }, + { title: "Nebraska" }, + { title: "Nevada" }, + { title: "New Hampshire" }, + { title: "New Jersey" }, + { title: "New Mexico" }, + { title: "New York" }, + { title: "North Carolina" }, + { title: "North Dakota" }, + { title: "Ohio" }, + { title: "Oklahoma" }, + { title: "Oregon" }, + { title: "Pennsylvania" }, + { title: "Rhode Island" }, + { title: "South Carolina" }, + { title: "South Dakota" }, + { title: "Tennessee" }, + { title: "Texas" }, + { title: "Utah" }, + { title: "Vermont" }, + { title: "Virginia" }, + { title: "Washington" }, + { title: "West Virginia" }, + { title: "Wisconsin" }, + { title: "Wyoming" } + ] + }] + end -end \ No newline at end of file +end