forked from coyote-team/coyote
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature test website admin & fix discovered bugs, cleanup
- Loading branch information
Showing
9 changed files
with
103 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# frozen_string_literal: true | ||
|
||
module Coyote | ||
# Namespace for site/CMS-specific Coyote code | ||
# @see Coyote::Strategies::MCA | ||
module Strategies | ||
module_function | ||
|
||
# @return [Array<Class>] a list of all strategy classes | ||
def all | ||
constants.map do |constant_name| | ||
const_get(constant_name) | ||
end | ||
end | ||
end | ||
end | ||
|
||
# Eager-load all strategies so WebsitesController can see them | ||
Pathname.glob("./lib/coyote/strategies/*.rb").each do |path| | ||
require_dependency path.sub_ext("") | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
RSpec.describe "Adding and changing a Website" do | ||
context "when logged-in as an admin" do | ||
include_context "as a logged-in admin user" | ||
|
||
let(:website_attributes) do | ||
attributes_for(:website).tap(&:symbolize_keys!) | ||
end | ||
|
||
it "succeeds" do | ||
click_link "Websites" | ||
click_link "New Website" | ||
expect(page.current_path).to eq(new_website_path) | ||
|
||
fill_in "Title", with: "XYZ Museum" | ||
fill_in "Url", with: "http://example.com" | ||
|
||
select("MCA",from: "Strategy") | ||
|
||
expect { | ||
click_button "Create Website" | ||
}.to change(Website,:count).from(0).to(1) | ||
|
||
website = Website.first | ||
expect(page.current_path).to eq(website_path(website)) | ||
|
||
click_link "Edit" | ||
fill_in "Title", with: "ABC Museum" | ||
|
||
expect { | ||
click_button "Update Website" | ||
website.reload | ||
}.to change(website,:title).to("ABC Museum") | ||
end | ||
end | ||
|
||
context "when logged-in as a user" do | ||
include_context "as a logged-in user" | ||
|
||
it "is not allowed" do | ||
expect(page).not_to have_link("Websites") | ||
visit new_website_path | ||
expect(page.current_path).to eq(root_path) | ||
|
||
visit edit_website_path(create(:website)) | ||
expect(page.current_path).to eq(root_path) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require "coyote/strategies" | ||
|
||
RSpec.describe Coyote::Strategies do | ||
it ".all returns a list of eager-loaded strategy classes" do | ||
expect(Coyote::Strategies.all).to match_array([Coyote::Strategies::MCA]) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters