Fix issue #368 where opening a screen twice from the same parent would cause a crash.

This commit is contained in:
Jamon Holmgren
2014-06-07 10:12:52 -07:00
parent d0f6883fce
commit c4016b18b7
3 changed files with 24 additions and 0 deletions

View File

@@ -10,3 +10,12 @@ Motion::Project::App.setup do |app|
app.device_family = [ :ipad ] # so we can test split screen capability
app.detect_dependencies = true
end
namespace :spec do
task :unit do
App.config.spec_mode = true
spec_files = App.config.spec_files - Dir.glob('./spec/functional/**/*.rb')
App.config.instance_variable_set("@spec_files", spec_files)
Rake::Task["simulator"].invoke
end
end

View File

@@ -70,6 +70,7 @@ module ProMotion
PM.logger.error "You need a nav_bar if you are going to push #{vc.to_s} onto it."
end
nav_controller ||= self.navigationController
return if nav_controller.topViewController == vc
vc.first_screen = false if vc.respond_to?(:first_screen=)
nav_controller.pushViewController(vc, animated: animated)
end

View File

@@ -212,6 +212,20 @@ describe "screen helpers" do
screen.should == new_screen
end
it "should not double-open a view controller if it's already been opened" do
parent_screen = HomeScreen.new(nav_bar: true)
new_screen = BasicScreen.new
@pushed = 0
parent_screen.navigationController.mock!("pushViewController:animated:") do |vc, animated|
@pushed += 1
parent_screen.navigationController.stub!("topViewController", return: vc)
end
parent_screen.open new_screen
@pushed.should == 1
parent_screen.open new_screen
@pushed.should == 1
end
end