Skip to content

Commit

Permalink
Feature testing group admin
Browse files Browse the repository at this point in the history
  • Loading branch information
subelsky committed Jul 27, 2017
1 parent 04f2f6a commit e1f5f45
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 13 deletions.
19 changes: 10 additions & 9 deletions app/controllers/groups_controller.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
class GroupsController < ApplicationController
# NOTE currently there are no controls for who can access Groups, see https://github.com/coyote-team/coyote/issues/116
before_filter :users
before_action :set_group, only: [:show, :edit, :update, :destroy]


def_param_group :group do
param :group, Hash do
param :title, String, required: true
Expand Down Expand Up @@ -63,13 +63,14 @@ def destroy
end

private
# Use callbacks to share common setup or constraints between actions.
def set_group
@group = Group.find(params[:id])
end

# Use callbacks to share common setup or constraints between actions.
def set_group
@group = Group.find(params[:id])
end

# Only allow a trusted parameter "white list" through.
def group_params
params.require(:group).permit(:title)
end
# Only allow a trusted parameter "white list" through.
def group_params
params.require(:group).permit(:title)
end
end
31 changes: 30 additions & 1 deletion spec/features/adding_and_editing_a_group_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,32 @@
RSpec.feature "Adding and editing a group" do
pending
context "when logged-in as an admin" do
include_context "as a logged-in admin user"

let(:group_attributes) do
attributes_for(:group).tap(&:symbolize_keys!)
end

it "succeeds" do
click_link "Groups"
click_link "New Group"
expect(page.current_path).to eq(new_group_path)

fill_in "Title", with: "Scavenger Hunt"

expect {
click_button "Create Group"
}.to change(Group,:count).from(0).to(1)

group = Group.first
expect(page.current_path).to eq(group_path(group))

click_link "Edit"
fill_in "Title", with: "Treasure Hunt"

expect {
click_button "Update Group"
group.reload
}.to change(group,:title).to("Treasure Hunt")
end
end
end
3 changes: 0 additions & 3 deletions spec/features/adding_and_editing_a_website_spec.rb

This file was deleted.

0 comments on commit e1f5f45

Please sign in to comment.