Cell inheritance does not work in Cells-3.7.0, rails 3.1.1

159 Views Asked by At

I have a problem using inheritance in cells-3.7.0 gem with rails 3.1.1. Looks like a bug, but I'm not sure. I have a Sidebar with a bunch of buttons that are displayed or not depending on different parameters. I am trying to use Cells to take out some logic from views. Works fine, except for inheritance. I have a cell for every button, like this:

class AddCompanyCell < Cell::Rails
  def display
    render
  end
end

class CompanyJobsCell < Cell::Rails
  def display(args)
    @company = args[:company]
    render
  end
end

Specs for these cells look like:

describe AddCompanyCell do
  context "cell rendering" do 

    context "rendering display" do
      subject { render_cell(:add_company, :display) }

      it { should have_link("Add Company", href: "/companies/new") }
    end
  end

  context "cell instance" do 
    subject { cell(:add_company) } 

    it { should respond_to(:display) }
  end
end

All specs pass.

Obviously, I have many classes like ones above. They have only one display method, but with the variable number of parameters. So, I tried to implement a parent class for all of those:

class GeneralCell < Cell::Rails
  def display(args)
    args.each do |k,v|
      eval("@#{k} = v")
    end
    render
  end
end

All specs pass for GeneralCell. But when I try to apply inheritance, like:

class AddCompanyCell < GeneralCell
end

I get failure when call render_cell:

Failure/Error: subject { render_cell(:add_company, :display, opts: {}) }
AbstractController::ActionNotFound:
The action 'display' could not be found for AddCompanyCell

Please note, that second test for AddCompanyCell (should respond_to(:display)) passes. Weird. Any ideas?

0

There are 0 best solutions below