mirror of
https://github.com/zhigang1992/ProMotion.git
synced 2026-05-26 23:30:38 +08:00
Merge pull request #511 from clearsightstudio/bugfix/indexable_nil_section_title
Fixes runtime crash when using the indexable table module and a section title is nil
This commit is contained in:
@@ -12,6 +12,14 @@ class TableScreenIndexable < PM::TableScreen
|
||||
|
||||
end
|
||||
|
||||
class TableScreenIndexableNil < TableScreenIndexable
|
||||
indexable
|
||||
|
||||
def table_data
|
||||
super.push({title: nil, cells: [{ title: "Single cell for group nil" }]})
|
||||
end
|
||||
end
|
||||
|
||||
class TableScreenIndexableSearchable < TableScreenIndexable
|
||||
indexable
|
||||
searchable
|
||||
|
||||
@@ -4,7 +4,7 @@ module ProMotion
|
||||
def table_data_index
|
||||
return nil if self.promotion_table_data.filtered || !self.class.get_indexable
|
||||
|
||||
index = self.promotion_table_data.sections.collect{ |section| section[:title][0] }
|
||||
index = self.promotion_table_data.sections.collect{ |section| (section[:title] || " ")[0] } || []
|
||||
index.unshift("{search}") if self.class.get_searchable
|
||||
index
|
||||
end
|
||||
|
||||
@@ -11,6 +11,19 @@ describe "PM::Table module indexable" do
|
||||
|
||||
end
|
||||
|
||||
describe "PM::Table module indexable with nil section title" do
|
||||
|
||||
before do
|
||||
@screen = TableScreenIndexableNil.new
|
||||
end
|
||||
|
||||
it "should not crash when a section title is nil" do
|
||||
result = %w{ A G M O S U }
|
||||
@screen.sectionIndexTitlesForTableView(@screen.table_view).should == result.push(" ")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "PM::Table module indexable/searchable" do
|
||||
|
||||
before do
|
||||
|
||||
Reference in New Issue
Block a user