Sha256: 0c2da2f7e3adcc347437a8a381b80f654a17827952d19c15899715225cc1e43f
Contents?: true
Size: 1.77 KB
Versions: 18
Compression:
Stored size: 1.77 KB
Contents
require 'rails_helper' RSpec.describe ActiveAdmin::Views::Pages::Form do describe "#title" do let!(:application){ ActiveAdmin::Application.new } let(:namespace){ ActiveAdmin::Namespace.new(application, "Admin") } let!(:http_params){ { controller: "UsersController", action: "edit" } } let!(:params) { ActionController::Parameters.new(http_params) } let(:helpers) do helpers = mock_action_view allow(helpers).to receive(:active_admin_config).and_return(namespace.register(Post)) allow(helpers).to receive(:params).and_return(params) helpers end let(:arbre_context) do OpenStruct.new(params: params, helpers: helpers, assigns: {}) end context "when :title is set" do it "should show the set page title" do page = ActiveAdmin::Views::Pages::Form.new(arbre_context) expect(page).to receive(:resource) expect(page).to receive(:form_presenter).twice.and_return({ title: "My Page Title" }) expect(page.title).to eq "My Page Title" end end context "when page_title is assigned" do it "should show the set page title" do arbre_context.assigns[:page_title] = "My Page Title" page = ActiveAdmin::Views::Pages::Form.new(arbre_context) expect(page.title).to eq "My Page Title" end end context "when page_title is not assigned" do { "new" => "New Post", "create" => "New Post", "edit" => "Edit Post", "update" => "Edit Post" }.each do |action, title| it "should show the correct I18n text on the #{action} action" do params[:action] = action page = ActiveAdmin::Views::Pages::Form.new(arbre_context) expect(page.title).to eq title end end end end end
Version data entries
18 entries across 18 versions & 3 rubygems